Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Small Room Labs
committed
May 16, 2011
0 parents
commit 1ec98f3
Showing
19 changed files
with
22,451 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<AVRStudio><MANAGEMENT><ProjectName>Clock72a-avr</ProjectName><Created>13-May-2011 15:12:44</Created><LastEdit>16-May-2011 15:06:02</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-May-2011 15:12:44</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>default\Clock72a-avr.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>G:\!Projects\Work\Clock72a\AVR\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR Simulator 2</CURRENT_TARGET><CURRENT_PART>ATmega168</CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0><Variables>v1</Variables><Variables>v2</Variables><Variables>b</Variables><Variables>led</Variables><Variables>group</Variables><Variables>d</Variables></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><modules><module></module></modules><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>Clock72a.c</SOURCEFILE><OTHERFILE>default\Clock72a-avr.lss</OTHERFILE><OTHERFILE>default\Clock72a-avr.map</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>NO</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE></EXTERNALMAKEFILE><PART>atmega168</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>Clock72a-avr.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>0</ISDIRTY><OPTIONS><OPTION><FILE>Clock72a.c</FILE><OPTIONLIST></OPTIONLIST></OPTION></OPTIONS><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -ggdb -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>D:\Program Files\Atmel\AVR Tools\AVR Toolchain\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>D:\Program Files\Atmel\AVR Tools\AVR Toolchain\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files><File00000><FileId>00000</FileId><FileName>Clock72a.c</FileName><Status>259</Status></File00000></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<AVRWorkspace><IOSettings><CurrentRegisters/></IOSettings><part name="ATmega168"/><Files><File00000 Name="G:\!Projects\Work\Clock72a\AVR\Clock72a.c" Position="314 119 878 400" LineCol="129 0"/></Files></AVRWorkspace> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
#define F_CPU 16000000UL | ||
#include <stdlib.h> | ||
#include <avr/io.h> | ||
#include <util/delay.h> | ||
|
||
|
||
unsigned char hour=0; | ||
unsigned char minute=0; | ||
unsigned char second=0; | ||
unsigned char mode=0; | ||
|
||
|
||
void AllOff() { | ||
DDRD = 0x00; // INPUT | ||
PORTD = 0; | ||
DDRB = 0x00; // INPUT | ||
PORTB = 0; | ||
} | ||
|
||
|
||
void Light(unsigned char led) { | ||
unsigned char dgnd; | ||
unsigned char dpos; | ||
unsigned char dgndbitmask; | ||
unsigned char dposbitmask; | ||
unsigned char b1,b2; | ||
|
||
dgnd=led>>3; | ||
dpos=led%8; | ||
if (dgnd<=dpos) dpos++; | ||
dgndbitmask=1<<dgnd; | ||
dposbitmask=1<<dpos; | ||
b1=0; | ||
b2=0; | ||
if (dposbitmask==0) {b1=1; b2=1;} | ||
if (dgndbitmask==0) {b1=1; b2=0;} | ||
|
||
DDRD=dgndbitmask+dposbitmask; | ||
PORTD=dposbitmask; | ||
DDRB=b1; | ||
PORTB=b2; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
void BrightnessTest() { | ||
unsigned char led; | ||
|
||
for (;;) { | ||
|
||
|
||
AllOff(); | ||
for (int i=0; i<50; i++) { | ||
for (led=0; led<72; led++) { | ||
Light(led); | ||
_delay_ms(1); | ||
} | ||
} | ||
|
||
|
||
AllOff(); | ||
DDRD=0xFF; | ||
for (int i=0; i<500; i++) { | ||
PORTD=0b11111110; | ||
_delay_ms(1); | ||
PORTD=0b11111101; | ||
_delay_ms(1); | ||
PORTD=0b11111011; | ||
_delay_ms(1); | ||
PORTD=0b11110111; | ||
_delay_ms(1); | ||
PORTD=0b11101111; | ||
_delay_ms(1); | ||
PORTD=0b11011111; | ||
_delay_ms(1); | ||
PORTD=0b10111111; | ||
_delay_ms(1); | ||
PORTD=0b01111111; | ||
_delay_ms(1); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
void GetTime() { | ||
second++; | ||
if (second>59) { | ||
second=0; | ||
minute++; | ||
if (minute>59) { | ||
minute=0; | ||
hour++; | ||
if (hour>23) { | ||
hour=0; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
void ReverseHMS() { | ||
unsigned char led; | ||
|
||
for (led=0; led<72; led++) { | ||
if (led==second || led==minute || led==(60+(hour>>1))) { | ||
_delay_ms(1); | ||
} else { | ||
Light(led); | ||
_delay_ms(1); | ||
} | ||
} | ||
} | ||
|
||
|
||
void StandardHMS() { | ||
Light(60+(hour>>1)); | ||
_delay_ms(1); | ||
Light(minute); | ||
_delay_ms(1); | ||
Light(second); | ||
_delay_ms(1); | ||
} | ||
|
||
|
||
|
||
int main (void) { | ||
hour=0; | ||
minute=0; | ||
second=0; | ||
mode=0; | ||
|
||
//BrightnessTest(); | ||
|
||
|
||
for (;;) { | ||
|
||
for (int i=0; i<25; i++) { | ||
if (mode==0) StandardHMS(); | ||
if (mode==1) ReverseHMS(); | ||
} | ||
|
||
GetTime(); | ||
|
||
|
||
} | ||
|
||
|
||
return 1; | ||
} |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.