Rev 310 | Rev 312 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
310 | pangu | 1 | /* |
2 | * Blitzdings main.c |
||
3 | * (c) pangu |
||
4 | */ |
||
311 | pangu | 5 | |
6 | /******************************************************************/ |
||
7 | /* WICHTIG: Fusebits in Ponyprog für 8MHz setzen: |
||
8 | |||
9 | Häkchen in Ponyprog: |
||
10 | CKSEL3 gesetzt |
||
11 | CKSEL2 nicht gesetzt |
||
12 | CKSEL1 gesetzt |
||
13 | CKSEL0 gesetzt |
||
14 | |||
15 | */ |
||
16 | /******************************************************************/ |
||
310 | pangu | 17 | |
18 | #include "main.h" |
||
19 | #include "timer.h" |
||
20 | #include "lprg.h" |
||
21 | |||
22 | /* Strings zum definieren von Dauer-Ein Dauer-Aus */ |
||
23 | const char l_on[]="A"; |
||
24 | const char l_off[]="a"; |
||
25 | |||
26 | // Wait flags: |
||
27 | // . 10 ms |
||
28 | // : 20 ms |
||
29 | // ; 50 ms |
||
30 | // I 100 ms |
||
31 | // N 200 ms |
||
32 | // M 300 ms |
||
33 | // V 500 ms |
||
34 | // S 1s |
||
35 | // LED: |
||
36 | // A-an a-aus |
||
37 | |||
38 | // Rot+Grün blitzen dreimal kurz, zeitlich leicht versetzt, alle 1,5s |
||
39 | // 2 weisse und 2 blaue LEDs sind an und gehen alle 3s reihum kurz aus |
||
40 | char *led_posflash[] = { |
||
41 | "A:aIA:aIA:aSV", // LED #1 rot |
||
42 | ".", // LED #2 |
||
43 | "NNaIASSNNN", // LED #3 blau |
||
44 | ".", // LED #4 |
||
45 | "NaIASSNNNN", // LED #5 weiss |
||
46 | "NA:aIA:aIA:aMS", // LED #6 grün |
||
47 | ".", // LED #7 |
||
48 | "aIASSNNNNN", // LED #8 weiss |
||
49 | ".", // LED #9 |
||
50 | "NNNaIASSNN" // LED #10 blau |
||
51 | }; |
||
52 | |||
53 | |||
54 | char *led_aus[] = { |
||
55 | l_off, // LED #1 rot |
||
56 | l_off, // LED #2 blau |
||
57 | l_off, // LED #3 blau |
||
58 | l_off, // LED #4 |
||
59 | l_off, // LED #5 weiss |
||
60 | l_off, // LED #6 grün |
||
61 | l_off, // LED #7 |
||
62 | l_off, // LED #8 weiss |
||
63 | l_off, // LED #9 |
||
64 | l_off // LED #10 |
||
65 | }; |
||
66 | |||
67 | char *led_an[] = { |
||
68 | l_on, // LED #1 rot |
||
69 | l_on, // LED #2 blau |
||
70 | l_on, // LED #3 blau |
||
71 | l_on, // LED #4 |
||
72 | l_on, // LED #5 weiss |
||
73 | l_on, // LED #6 grün |
||
74 | l_on, // LED #7 |
||
75 | l_on, // LED #8 weiss |
||
76 | l_on, // LED #9 |
||
77 | l_on // LED #10 |
||
78 | }; |
||
79 | |||
80 | // alle LEDs toggeln synchron, 300ms Leucht/Aus-Dauer |
||
81 | char *led_flash1[] = { |
||
82 | "aMAM", // LED #1 rot |
||
83 | "aMAM", // LED #2 blau |
||
84 | "aMAM", // LED #3 blau |
||
85 | "aMAM", // LED #4 |
||
86 | "aMAM", // LED #5 weiss |
||
87 | "aMAM", // LED #6 grün |
||
88 | "aMAM", // LED #7 |
||
89 | "aMAM", // LED #8 weiss |
||
90 | "aMAM", // LED #9 |
||
91 | "aMAM" // LED #10 |
||
92 | }; |
||
93 | |||
94 | // alle LEDs toggeln mit verschiednen Zykluszeiten |
||
95 | char *led_flash2[] = { |
||
96 | "a.A.", // LED #1 rot |
||
97 | "a:A:", // LED #2 blau |
||
98 | "a;A;", // LED #3 blau |
||
99 | "aIAI", // LED #4 |
||
100 | "aNAN", // LED #5 weiss |
||
101 | "aMAM", // LED #6 grün |
||
102 | "aMIAMI", // LED #7 |
||
103 | "aVAV", // LED #8 weiss |
||
104 | "aVIAVI", // LED #9 |
||
105 | "aSAS" // LED #10 |
||
106 | }; |
||
107 | |||
108 | |||
109 | // Hier die zu verwendenden LichtProgramme einfach eintragen. |
||
110 | void *modes[]= { led_an, led_posflash, led_aus, led_flash1, led_flash2 }; |
||
111 | |||
112 | void nextMode() { |
||
113 | |||
114 | static int current = 0; |
||
115 | |||
116 | lprg_init(modes[current]); |
||
117 | current = ++current % (sizeof(modes)/sizeof(void *)); |
||
118 | |||
119 | } |
||
120 | |||
121 | ISR(INT1_vect) |
||
122 | { |
||
123 | |||
124 | nextMode(); |
||
125 | |||
126 | } |
||
127 | |||
128 | |||
129 | |||
130 | int main() { |
||
131 | |||
132 | int tim10s, tim1s; |
||
133 | |||
134 | // Ports einstellen |
||
135 | // Pin B |7|6|5|4|3|2|1|0 |
||
136 | // Binär:|0|0|0|0|0|1|0|1 (b) => #05 (h) |
||
137 | // Pin B0 und B2 als Ausgänge festlegen |
||
138 | DDRB = 0x05; |
||
139 | |||
140 | // Pin C |7|6|5|4|3|2|1|0 |
||
141 | // Binär:|0|0|1|1|1|1|1|0 (b) => #3E (h) |
||
142 | // Pin C1 bis C5 als Ausgänge festlegen |
||
143 | DDRC = 0x3E; |
||
144 | |||
145 | // Pin D |7|6|5|4|3|2|1|0 |
||
146 | // Binär:|1|1|1|1|0|0|0|0 (b) => #F0 (h) |
||
147 | DDRD = 0xF0; |
||
148 | //Pullup für PD3 aktivieren |
||
149 | PORTD |= (1 << PD3); |
||
150 | |||
151 | |||
152 | //interrupt konfigurueren |
||
153 | GIMSK = 1<<INT1; |
||
154 | MCUCR = 1<<ISC10; |
||
155 | |||
156 | ALLES_OFF; |
||
157 | |||
158 | STATUS_ON; |
||
159 | |||
160 | Timer_Init(); |
||
161 | nextMode(); |
||
162 | tim10s = SetDelay(10000); |
||
163 | tim1s = SetDelay(1000); |
||
164 | |||
165 | sei(); //interrupts einschalten |
||
166 | |||
167 | while (1) { |
||
168 | |||
169 | if(flag10ms) { // every 10ms |
||
170 | flag10ms = 0; |
||
171 | lprg_step(); // next step in light prog |
||
172 | } |
||
173 | |||
174 | if(CheckDelay(tim10s)) { // alle 10 sec programm wechseln |
||
175 | nextMode(); |
||
176 | tim10s = SetDelay(10000); |
||
177 | } |
||
178 | if(CheckDelay(tim1s)) { // alle 1 sec STatus-LED toggeln |
||
179 | STATUS_TOGGLE; |
||
180 | tim1s = SetDelay(1000); |
||
181 | } |
||
182 | } |
||
183 | |||
184 | } |
||
185 | |||
186 | |||
187 | |||
188 | |||
189 |