mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-21 15:54:39 +01:00
Optimized size of core, fixed some warnings in libraries.
This commit is contained in:
parent
77ecc6476c
commit
4ba8ffb6ee
@ -13,19 +13,6 @@
|
|||||||
buildPhases = (
|
buildPhases = (
|
||||||
33ACA202097AF31C00BEC3A2 /* ShellScript */,
|
33ACA202097AF31C00BEC3A2 /* ShellScript */,
|
||||||
);
|
);
|
||||||
buildSettings = {
|
|
||||||
OPTIMIZATION_CFLAGS = "";
|
|
||||||
OTHER_CFLAGS = "";
|
|
||||||
OTHER_LDFLAGS = "";
|
|
||||||
OTHER_REZFLAGS = "";
|
|
||||||
PRODUCT_NAME = Distribute;
|
|
||||||
SECTORDER_FLAGS = "";
|
|
||||||
WARNING_CFLAGS = (
|
|
||||||
"-Wmost",
|
|
||||||
"-Wno-four-char-constants",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
);
|
|
||||||
};
|
|
||||||
dependencies = (
|
dependencies = (
|
||||||
33ACA1F8097AF14400BEC3A2 /* PBXTargetDependency */,
|
33ACA1F8097AF14400BEC3A2 /* PBXTargetDependency */,
|
||||||
);
|
);
|
||||||
@ -43,19 +30,6 @@
|
|||||||
33FF071D0965C1C20016AC38 /* CopyFiles */,
|
33FF071D0965C1C20016AC38 /* CopyFiles */,
|
||||||
33FF07170965BFFE0016AC38 /* ShellScript */,
|
33FF07170965BFFE0016AC38 /* ShellScript */,
|
||||||
);
|
);
|
||||||
buildSettings = {
|
|
||||||
OPTIMIZATION_CFLAGS = "";
|
|
||||||
OTHER_CFLAGS = "";
|
|
||||||
OTHER_LDFLAGS = "";
|
|
||||||
OTHER_REZFLAGS = "";
|
|
||||||
PRODUCT_NAME = Arduino;
|
|
||||||
SECTORDER_FLAGS = "";
|
|
||||||
WARNING_CFLAGS = (
|
|
||||||
"-Wmost",
|
|
||||||
"-Wno-four-char-constants",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
);
|
|
||||||
};
|
|
||||||
dependencies = (
|
dependencies = (
|
||||||
);
|
);
|
||||||
name = Setup;
|
name = Setup;
|
||||||
@ -74,24 +48,6 @@
|
|||||||
33AF61670965C4C600B514A9 /* Frameworks */,
|
33AF61670965C4C600B514A9 /* Frameworks */,
|
||||||
33CF03C809662DA200F2C9A9 /* CopyFiles */,
|
33CF03C809662DA200F2C9A9 /* CopyFiles */,
|
||||||
);
|
);
|
||||||
buildSettings = {
|
|
||||||
JAVA_COMPILER = /usr/bin/javac;
|
|
||||||
JAVA_COMPILER_FLAGS = "";
|
|
||||||
JAVA_ONLY = YES;
|
|
||||||
JAVA_SOURCE_SUBDIR = .;
|
|
||||||
OPTIMIZATION_CFLAGS = "";
|
|
||||||
OTHER_CFLAGS = "";
|
|
||||||
OTHER_LDFLAGS = "";
|
|
||||||
OTHER_REZFLAGS = "";
|
|
||||||
PRODUCT_NAME = App;
|
|
||||||
SECTORDER_FLAGS = "";
|
|
||||||
WARNING_CFLAGS = (
|
|
||||||
"-Wmost",
|
|
||||||
"-Wno-four-char-constants",
|
|
||||||
"-Wno-unknown-pragmas",
|
|
||||||
);
|
|
||||||
WRAPPER_EXTENSION = app;
|
|
||||||
};
|
|
||||||
dependencies = (
|
dependencies = (
|
||||||
33AF61710965C51E00B514A9 /* PBXTargetDependency */,
|
33AF61710965C51E00B514A9 /* PBXTargetDependency */,
|
||||||
);
|
);
|
||||||
@ -255,23 +211,6 @@
|
|||||||
33FF07FD0965C3560016AC38 /* targets in CopyFiles */ = {isa = PBXBuildFile; fileRef = 33FF07D50965C3560016AC38 /* targets */; };
|
33FF07FD0965C3560016AC38 /* targets in CopyFiles */ = {isa = PBXBuildFile; fileRef = 33FF07D50965C3560016AC38 /* targets */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXBuildStyle section */
|
|
||||||
33AF609C0965C4B700B514A9 /* Development */ = {
|
|
||||||
isa = PBXBuildStyle;
|
|
||||||
buildSettings = {
|
|
||||||
COPY_PHASE_STRIP = NO;
|
|
||||||
};
|
|
||||||
name = Development;
|
|
||||||
};
|
|
||||||
33AF609D0965C4B700B514A9 /* Deployment */ = {
|
|
||||||
isa = PBXBuildStyle;
|
|
||||||
buildSettings = {
|
|
||||||
COPY_PHASE_STRIP = YES;
|
|
||||||
};
|
|
||||||
name = Deployment;
|
|
||||||
};
|
|
||||||
/* End PBXBuildStyle section */
|
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
33ACA1F7097AF14400BEC3A2 /* PBXContainerItemProxy */ = {
|
33ACA1F7097AF14400BEC3A2 /* PBXContainerItemProxy */ = {
|
||||||
isa = PBXContainerItemProxy;
|
isa = PBXContainerItemProxy;
|
||||||
@ -993,12 +932,6 @@
|
|||||||
33FFFD3F0965B1E40016AC38 /* Project object */ = {
|
33FFFD3F0965B1E40016AC38 /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
buildConfigurationList = 33FFFD400965B1E40016AC38 /* Build configuration list for PBXProject "Arduino" */;
|
buildConfigurationList = 33FFFD400965B1E40016AC38 /* Build configuration list for PBXProject "Arduino" */;
|
||||||
buildSettings = {
|
|
||||||
};
|
|
||||||
buildStyles = (
|
|
||||||
33AF609C0965C4B700B514A9 /* Development */,
|
|
||||||
33AF609D0965C4B700B514A9 /* Deployment */,
|
|
||||||
);
|
|
||||||
hasScannedForEncodings = 0;
|
hasScannedForEncodings = 0;
|
||||||
mainGroup = 33FFFD3D0965B1E40016AC38;
|
mainGroup = 33FFFD3D0965B1E40016AC38;
|
||||||
productRefGroup = 33FFFD3D0965B1E40016AC38;
|
productRefGroup = 33FFFD3D0965B1E40016AC38;
|
||||||
@ -1228,6 +1161,7 @@
|
|||||||
33ACA1FD097AF16500BEC3A2 /* work */,
|
33ACA1FD097AF16500BEC3A2 /* work */,
|
||||||
);
|
);
|
||||||
defaultConfigurationIsVisible = 0;
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = work;
|
||||||
};
|
};
|
||||||
33AF616B0965C4CB00B514A9 /* Build configuration list for PBXApplicationTarget "App" */ = {
|
33AF616B0965C4CB00B514A9 /* Build configuration list for PBXApplicationTarget "App" */ = {
|
||||||
isa = XCConfigurationList;
|
isa = XCConfigurationList;
|
||||||
@ -1235,6 +1169,7 @@
|
|||||||
33AF616C0965C4CB00B514A9 /* work */,
|
33AF616C0965C4CB00B514A9 /* work */,
|
||||||
);
|
);
|
||||||
defaultConfigurationIsVisible = 0;
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = work;
|
||||||
};
|
};
|
||||||
33FFFD400965B1E40016AC38 /* Build configuration list for PBXProject "Arduino" */ = {
|
33FFFD400965B1E40016AC38 /* Build configuration list for PBXProject "Arduino" */ = {
|
||||||
isa = XCConfigurationList;
|
isa = XCConfigurationList;
|
||||||
@ -1242,6 +1177,7 @@
|
|||||||
33FFFD410965B1E40016AC38 /* work */,
|
33FFFD410965B1E40016AC38 /* work */,
|
||||||
);
|
);
|
||||||
defaultConfigurationIsVisible = 0;
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = work;
|
||||||
};
|
};
|
||||||
33FFFE1F0965BC300016AC38 /* Build configuration list for PBXAggregateTarget "Setup" */ = {
|
33FFFE1F0965BC300016AC38 /* Build configuration list for PBXAggregateTarget "Setup" */ = {
|
||||||
isa = XCConfigurationList;
|
isa = XCConfigurationList;
|
||||||
@ -1249,6 +1185,7 @@
|
|||||||
33FFFE200965BC300016AC38 /* work */,
|
33FFFE200965BC300016AC38 /* work */,
|
||||||
);
|
);
|
||||||
defaultConfigurationIsVisible = 0;
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = work;
|
||||||
};
|
};
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
};
|
};
|
||||||
|
17
readme.txt
17
readme.txt
@ -32,15 +32,20 @@ Arduino board and point the Windows Add Hardware wizard to the FTDI USB Drivers
|
|||||||
directory.
|
directory.
|
||||||
|
|
||||||
On the Mac, mount the FTDIUSBSerialDriver_v2_0_1.dmg disk image and run the
|
On the Mac, mount the FTDIUSBSerialDriver_v2_0_1.dmg disk image and run the
|
||||||
included FTDIUSBSerialDriver.pkg.
|
included FTDIUSBSerialDriver.pkg. Also run the macosx_setup.command (after
|
||||||
|
moving the Arduino distribution to your /Applications folder). It corrects
|
||||||
Also, on the Mac, run the macosx_setup.command (after moving the Arduino
|
permission on a few files for use with the serial port and will prompt you
|
||||||
distribution to your /Applications folder). It corrects permission on a few
|
for your password. You may need to reboot after running this script.
|
||||||
files for use with the serial port and will prompt you for your password. You
|
|
||||||
may need to reboot after running this script.
|
|
||||||
|
|
||||||
UPDATES
|
UPDATES
|
||||||
|
|
||||||
|
0005
|
||||||
|
|
||||||
|
Fixed bug that sometimes caused uploading of old versions of a sketch.
|
||||||
|
Serial monitor nows include an interface to send messages to the Arduino
|
||||||
|
board. Pressing return appends a newline, pushing the send button doesn't.
|
||||||
|
Now displaying "burning bootloader..." and "compiling..." status messages.
|
||||||
|
|
||||||
0004 - 2006.04.26
|
0004 - 2006.04.26
|
||||||
|
|
||||||
Main sketch is now compiled as C++ (instead of C).
|
Main sketch is now compiled as C++ (instead of C).
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
// which can be found at http://www.gnu.org/licenses/gpl.txt
|
// which can be found at http://www.gnu.org/licenses/gpl.txt
|
||||||
//
|
//
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// Modified by David A. Mellis, 9 July 2006.
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
@ -94,7 +96,7 @@ void timerInit(void)
|
|||||||
// enable interrupts
|
// enable interrupts
|
||||||
sei();
|
sei();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
void timer0Init()
|
void timer0Init()
|
||||||
{
|
{
|
||||||
// initialize timer 0
|
// initialize timer 0
|
||||||
@ -104,7 +106,7 @@ void timer0Init()
|
|||||||
|
|
||||||
timer0ClearOverflowCount(); // initialize time registers
|
timer0ClearOverflowCount(); // initialize time registers
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
void timer1Init(void)
|
void timer1Init(void)
|
||||||
{
|
{
|
||||||
// initialize timer 1
|
// initialize timer 1
|
||||||
@ -125,13 +127,13 @@ void timer2Init(void)
|
|||||||
timer2ClearOverflowCount(); // initialize time registers
|
timer2ClearOverflowCount(); // initialize time registers
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/*
|
||||||
void timer0SetPrescaler(u08 prescale)
|
void timer0SetPrescaler(u08 prescale)
|
||||||
{
|
{
|
||||||
// set prescaler on timer 0
|
// set prescaler on timer 0
|
||||||
outb(TCCR0, (inb(TCCR0) & ~TIMER_PRESCALE_MASK) | prescale);
|
outb(TCCR0, (inb(TCCR0) & ~TIMER_PRESCALE_MASK) | prescale);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
void timer1SetPrescaler(u08 prescale)
|
void timer1SetPrescaler(u08 prescale)
|
||||||
{
|
{
|
||||||
// set prescaler on timer 1
|
// set prescaler on timer 1
|
||||||
@ -145,13 +147,13 @@ void timer2SetPrescaler(u08 prescale)
|
|||||||
outb(TCCR2, (inb(TCCR2) & ~TIMER_PRESCALE_MASK) | prescale);
|
outb(TCCR2, (inb(TCCR2) & ~TIMER_PRESCALE_MASK) | prescale);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/*
|
||||||
u16 timer0GetPrescaler(void)
|
u16 timer0GetPrescaler(void)
|
||||||
{
|
{
|
||||||
// get the current prescaler setting
|
// get the current prescaler setting
|
||||||
return (pgm_read_word(TimerPrescaleFactor+(inb(TCCR0) & TIMER_PRESCALE_MASK)));
|
return (pgm_read_word(TimerPrescaleFactor+(inb(TCCR0) & TIMER_PRESCALE_MASK)));
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
u16 timer1GetPrescaler(void)
|
u16 timer1GetPrescaler(void)
|
||||||
{
|
{
|
||||||
// get the current prescaler setting
|
// get the current prescaler setting
|
||||||
@ -207,7 +209,7 @@ u16 timerTicsToMs(u32 tics)
|
|||||||
return (tics*1000*(prescaleDiv*256))/F_CPU;
|
return (tics*1000*(prescaleDiv*256))/F_CPU;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
void timerPause(unsigned short pause_ms)
|
void timerPause(unsigned short pause_ms)
|
||||||
{
|
{
|
||||||
// pauses for exactly <pause_ms> number of milliseconds
|
// pauses for exactly <pause_ms> number of milliseconds
|
||||||
@ -245,16 +247,14 @@ void timerPause(unsigned short pause_ms)
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* old inaccurate code, for reference
|
// old inaccurate code, for reference
|
||||||
|
|
||||||
// calculate delay for [pause_ms] milliseconds
|
// calculate delay for [pause_ms] milliseconds
|
||||||
u16 prescaleDiv = 1<<(pgm_read_byte(TimerPrescaleFactor+inb(TCCR0)));
|
//u16 prescaleDiv = 1<<(pgm_read_byte(TimerPrescaleFactor+inb(TCCR0)));
|
||||||
u32 pause = (pause_ms*(F_CPU/(prescaleDiv*256)))/1000;
|
//u32 pause = (pause_ms*(F_CPU/(prescaleDiv*256)))/1000;
|
||||||
|
|
||||||
TimerPauseReg = 0;
|
//TimerPauseReg = 0;
|
||||||
while(TimerPauseReg < pause);
|
//while(TimerPauseReg < pause);
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer0ClearOverflowCount(void)
|
void timer0ClearOverflowCount(void)
|
||||||
@ -269,7 +269,7 @@ long timer0GetOverflowCount(void)
|
|||||||
// (this is since the last timer0ClearOverflowCount() command was called)
|
// (this is since the last timer0ClearOverflowCount() command was called)
|
||||||
return Timer0Reg0;
|
return Timer0Reg0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#ifdef TCNT2 // support timer2 only if it exists
|
#ifdef TCNT2 // support timer2 only if it exists
|
||||||
void timer2ClearOverflowCount(void)
|
void timer2ClearOverflowCount(void)
|
||||||
{
|
{
|
||||||
@ -403,7 +403,7 @@ void timer1PWMBSet(u16 pwmDuty)
|
|||||||
//outp( (pwmDuty&0x00FF), OCR1BL); // set the low 8bits of OCR1B
|
//outp( (pwmDuty&0x00FF), OCR1BL); // set the low 8bits of OCR1B
|
||||||
OCR1B = pwmDuty;
|
OCR1B = pwmDuty;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
//! Interrupt handler for tcnt0 overflow interrupt
|
//! Interrupt handler for tcnt0 overflow interrupt
|
||||||
TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW0)
|
TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW0)
|
||||||
{
|
{
|
||||||
@ -416,7 +416,7 @@ TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW0)
|
|||||||
if(TimerIntFunc[TIMER0OVERFLOW_INT])
|
if(TimerIntFunc[TIMER0OVERFLOW_INT])
|
||||||
TimerIntFunc[TIMER0OVERFLOW_INT]();
|
TimerIntFunc[TIMER0OVERFLOW_INT]();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
//! Interrupt handler for tcnt1 overflow interrupt
|
//! Interrupt handler for tcnt1 overflow interrupt
|
||||||
TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW1)
|
TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW1)
|
||||||
{
|
{
|
||||||
@ -438,6 +438,7 @@ TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW2)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OCR0
|
#ifdef OCR0
|
||||||
|
/*
|
||||||
// include support for Output Compare 0 for new AVR processors that support it
|
// include support for Output Compare 0 for new AVR processors that support it
|
||||||
//! Interrupt handler for OutputCompare0 match (OC0) interrupt
|
//! Interrupt handler for OutputCompare0 match (OC0) interrupt
|
||||||
TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE0)
|
TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE0)
|
||||||
@ -446,6 +447,7 @@ TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE0)
|
|||||||
if(TimerIntFunc[TIMER0OUTCOMPARE_INT])
|
if(TimerIntFunc[TIMER0OUTCOMPARE_INT])
|
||||||
TimerIntFunc[TIMER0OUTCOMPARE_INT]();
|
TimerIntFunc[TIMER0OUTCOMPARE_INT]();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//! Interrupt handler for CutputCompare1A match (OC1A) interrupt
|
//! Interrupt handler for CutputCompare1A match (OC1A) interrupt
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
wiring.c - Wiring API Partial Implementation
|
wiring.c - Partial implementation of the Wiring API for the ATmega8.
|
||||||
Part of Arduino - http://arduino.berlios.de/
|
Part of Arduino - http://www.arduino.cc/
|
||||||
|
|
||||||
Copyright (c) 2005-2006 David A. Mellis
|
Copyright (c) 2005-2006 David A. Mellis
|
||||||
|
|
||||||
@ -48,6 +48,10 @@
|
|||||||
|
|
||||||
#include "wiring.h"
|
#include "wiring.h"
|
||||||
|
|
||||||
|
// The number of times timer 0 has overflowed since the program started.
|
||||||
|
// Must be volatile or gcc will optimize away some uses of it.
|
||||||
|
volatile unsigned long timer0_overflow_count;
|
||||||
|
|
||||||
// Get the hardware port of the given virtual pin number. This comes from
|
// Get the hardware port of the given virtual pin number. This comes from
|
||||||
// the pins_*.c file for the active board configuration.
|
// the pins_*.c file for the active board configuration.
|
||||||
int digitalPinToPort(int pin)
|
int digitalPinToPort(int pin)
|
||||||
@ -315,19 +319,30 @@ void print(const char *format, ...)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW0)
|
||||||
|
{
|
||||||
|
timer0_overflow_count++;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned long millis()
|
unsigned long millis()
|
||||||
{
|
{
|
||||||
// timer 0 increments every timer0GetPrescaler() cycles, and
|
// timer 0 increments every 8 cycles, and overflows when it reaches 256.
|
||||||
// overflows when it reaches 256. we calculate the total
|
// we calculate the total number of clock cycles, then divide by the
|
||||||
// number of clock cycles, then divide by the number of clock
|
// number of clock cycles per millisecond.
|
||||||
// cycles per millisecond.
|
//return timer0_overflow_count * 8UL * 256UL / (F_CPU / 1000UL);
|
||||||
return (unsigned long) timer0GetOverflowCount() *
|
|
||||||
timer0GetPrescaler() * 2UL / (F_CPU / 128000UL);
|
// calculating the total number of clock cycles overflows an
|
||||||
|
// unsigned long, so instead find 1/128th the number of clock cycles
|
||||||
|
// and divide by 1/128th the number of clock cycles per millisecond.
|
||||||
|
return timer0_overflow_count * 8UL * 2UL / (F_CPU / 128000UL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void delay(unsigned long ms)
|
void delay(unsigned long ms)
|
||||||
{
|
{
|
||||||
timerPause(ms);
|
unsigned long start = millis();
|
||||||
|
|
||||||
|
while (millis() - start < ms)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delay for the given number of microseconds. Assumes a 16 MHz clock.
|
/* Delay for the given number of microseconds. Assumes a 16 MHz clock.
|
||||||
@ -389,7 +404,7 @@ unsigned long pulseIn(int pin, int state)
|
|||||||
{
|
{
|
||||||
// cache the port and bit of the pin in order to speed up the
|
// cache the port and bit of the pin in order to speed up the
|
||||||
// pulse width measuring loop and achieve finer resolution. calling
|
// pulse width measuring loop and achieve finer resolution. calling
|
||||||
// digitalWrite() instead yields much coarser resolution.
|
// digitalRead() instead yields much coarser resolution.
|
||||||
int r = port_to_input[digitalPinToPort(pin)];
|
int r = port_to_input[digitalPinToPort(pin)];
|
||||||
int bit = digitalPinToBit(pin);
|
int bit = digitalPinToBit(pin);
|
||||||
int mask = 1 << bit;
|
int mask = 1 << bit;
|
||||||
@ -423,7 +438,12 @@ int main(void)
|
|||||||
sei();
|
sei();
|
||||||
|
|
||||||
// timer 0 is used for millis() and delay()
|
// timer 0 is used for millis() and delay()
|
||||||
timer0Init();
|
//timer0Init();
|
||||||
|
timer0_overflow_count = 0;
|
||||||
|
// set timer 0 prescale factor to 8
|
||||||
|
sbi(TCCR0, CS01);
|
||||||
|
// enable timer 0 overflow interrupt
|
||||||
|
sbi(TIMSK, TOIE0);
|
||||||
|
|
||||||
// timers 1 & 2 are used for the hardware pwm
|
// timers 1 & 2 are used for the hardware pwm
|
||||||
timer1Init();
|
timer1Init();
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
wiring.h - Wiring API Partial Implementation
|
wiring.h - Partial implementation of the Wiring API for the ATmega8.
|
||||||
Part of Arduino / Wiring Lite
|
Part of Arduino - http://www.arduino.cc/
|
||||||
|
|
||||||
Copyright (c) 2005 David A. Mellis
|
Copyright (c) 2005-2006 David A. Mellis
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
@ -55,9 +55,6 @@ extern "C"{
|
|||||||
#define degrees(rad) ((rad)*RAD_TO_DEG)
|
#define degrees(rad) ((rad)*RAD_TO_DEG)
|
||||||
#define sq(x) ((x)*(x))
|
#define sq(x) ((x)*(x))
|
||||||
|
|
||||||
#define NOT_A_PIN 0
|
|
||||||
#define NOT_A_PORT -1
|
|
||||||
|
|
||||||
typedef uint8_t boolean;
|
typedef uint8_t boolean;
|
||||||
typedef uint8_t byte;
|
typedef uint8_t byte;
|
||||||
|
|
||||||
@ -82,7 +79,6 @@ void printBinary(unsigned long n);
|
|||||||
|
|
||||||
unsigned long millis(void);
|
unsigned long millis(void);
|
||||||
void delay(unsigned long);
|
void delay(unsigned long);
|
||||||
void delay_ms(unsigned short ms);
|
|
||||||
void delayMicroseconds(unsigned int us);
|
void delayMicroseconds(unsigned int us);
|
||||||
unsigned long pulseIn(int pin, int state);
|
unsigned long pulseIn(int pin, int state);
|
||||||
|
|
||||||
@ -90,6 +86,9 @@ void setup(void);
|
|||||||
void loop(void);
|
void loop(void);
|
||||||
|
|
||||||
// XXX: internal definitions, should be moved to another header file
|
// XXX: internal definitions, should be moved to another header file
|
||||||
|
#define NOT_A_PIN 0
|
||||||
|
#define NOT_A_PORT -1
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int port;
|
int port;
|
||||||
int bit;
|
int bit;
|
||||||
|
@ -129,7 +129,9 @@ void Matrix::setRegister(uint8_t reg, uint8_t data)
|
|||||||
void Matrix::syncRow(uint8_t row)
|
void Matrix::syncRow(uint8_t row)
|
||||||
{
|
{
|
||||||
if (!_buffer) return;
|
if (!_buffer) return;
|
||||||
if (row < 0 || row >= 8) return;
|
|
||||||
|
// uint8_t's can't be negative, so don't test for negative row
|
||||||
|
if (row >= 8) return;
|
||||||
digitalWrite(_pinLoad, HIGH); // begin
|
digitalWrite(_pinLoad, HIGH); // begin
|
||||||
for(uint8_t i = 0; i < _screens; ++i){
|
for(uint8_t i = 0; i < _screens; ++i){
|
||||||
putByte(8 - row); // specify register
|
putByte(8 - row); // specify register
|
||||||
@ -162,7 +164,9 @@ void Matrix::setBrightness(uint8_t value)
|
|||||||
void Matrix::buffer(uint8_t x, uint8_t y, uint8_t value)
|
void Matrix::buffer(uint8_t x, uint8_t y, uint8_t value)
|
||||||
{
|
{
|
||||||
if (!_buffer) return;
|
if (!_buffer) return;
|
||||||
if (x < 0 || x >= _maximumX || y < 0 || y >= 8) return;
|
|
||||||
|
// uint8_t's can't be negative, so don't test for negative x and y.
|
||||||
|
if (x >= _maximumX || y >= 8) return;
|
||||||
|
|
||||||
uint8_t offset = x; // record x
|
uint8_t offset = x; // record x
|
||||||
x %= 8; // make x relative to a single matrix
|
x %= 8; // make x relative to a single matrix
|
||||||
|
@ -75,7 +75,9 @@ uint8_t Sprite::height() const
|
|||||||
void Sprite::write(uint8_t x, uint8_t y, uint8_t value)
|
void Sprite::write(uint8_t x, uint8_t y, uint8_t value)
|
||||||
{
|
{
|
||||||
if (!_buffer) return;
|
if (!_buffer) return;
|
||||||
if (x < 0 || x >= _width || y < 0 || y >= _height) return;
|
|
||||||
|
// uint8_t's can't be negative, so don't test for negative x and y.
|
||||||
|
if (x >= _width || y >= _height) return;
|
||||||
|
|
||||||
// we need to bitwise-or the value of the other pixels in the byte with
|
// we need to bitwise-or the value of the other pixels in the byte with
|
||||||
// the new value, masked and shifted into the proper bits.
|
// the new value, masked and shifted into the proper bits.
|
||||||
@ -85,7 +87,9 @@ void Sprite::write(uint8_t x, uint8_t y, uint8_t value)
|
|||||||
uint8_t Sprite::read(uint8_t x, uint8_t y) const
|
uint8_t Sprite::read(uint8_t x, uint8_t y) const
|
||||||
{
|
{
|
||||||
if (!_buffer) return 0;
|
if (!_buffer) return 0;
|
||||||
if (x < 0 || x >= _width || y < 0 || y >= _height) return 0;
|
|
||||||
|
// uint8_t's can't be negative, so don't test for negative x and y.
|
||||||
|
if (x >= _width || y >= _height) return 0;
|
||||||
|
|
||||||
return (_buffer[y] >> x) & 0x01;
|
return (_buffer[y] >> x) & 0x01;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user