Rev 312 | Rev 342 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 312 | Rev 341 | ||
---|---|---|---|
Line 51... | Line 51... | ||
51 | "NNNaIASSNN" // LED #10 blau |
51 | "NNNaIASSNN" // LED #10 blau |
52 | }; |
52 | }; |
Line 53... | Line 53... | ||
53 | 53 | ||
54 | // dasselbe, nur sind w/b dauer-an |
54 | // dasselbe, nur sind w/b dauer-an |
55 | char *led_posflash[] = { |
55 | char *led_posflash[] = { |
56 | "A:aIA:aIA:aSV", // LED #1 rot |
56 | "A", // LED #1 rot |
57 | ".", // LED #2 |
57 | "A", // LED #2 |
58 | "A", // LED #3 blau |
58 | "A", // LED #3 blau |
59 | ".", // LED #4 |
59 | "A", // LED #4 |
60 | "A", // LED #5 weiss |
60 | "A:aIA:aIA:aSV", // LED #5 weiss |
61 | "NA:aIA:aIA:aMS", // LED #6 grün |
61 | "NA:aIA:aIA:aMS", // LED #6 grün |
62 | ".", // LED #7 |
62 | "A", // LED #7 |
63 | "A", // LED #8 weiss |
63 | "A", // LED #8 weiss |
64 | ".", // LED #9 |
64 | "A", // LED #9 |
65 | "A" // LED #10 blau |
65 | "A" // LED #10 blau |
Line 66... | Line 66... | ||
66 | }; |
66 | }; |
Line 136... | Line 136... | ||
136 | 136 | ||
Line 137... | Line 137... | ||
137 | 137 | ||
- | 138 | // Hier die zu verwendenden LichtProgramme einfach eintragen. |
|
138 | // Hier die zu verwendenden LichtProgramme einfach eintragen. |
139 | |
Line 139... | Line 140... | ||
139 | 140 | int current = 0; |
|
Line 140... | Line 141... | ||
140 | int current = 0; |
141 | |
141 | void *modes[]= { led_posflash, led_an, led_aus }; |
142 | void *modes[]= { led_posflash, led_an, led_aus }; |
Line 142... | Line 143... | ||
142 | 143 | ||
Line 153... | Line 154... | ||
153 | nextMode(); |
154 | nextMode(); |
Line 154... | Line 155... | ||
154 | 155 | ||
Line -... | Line 156... | ||
- | 156 | } |
|
Line 155... | Line -... | ||
155 | } |
- | |
156 | - | ||
157 | 157 | ||
158 | 158 | ||
Line -... | Line 159... | ||
- | 159 | int main(void) { |
|
- | 160 | ||
- | 161 | int tim1s, tim3s, tim10s, analog_state=0; |
|
159 | int main() { |
162 | int Vcurr; |
160 | 163 | ||
161 | int tim1s, tim3s, tim10s; |
164 | SFIOR = 0x00; // Analog Comperator aus |
162 | int Vcurr; |
165 | ADCSRA = 0xD3; // Converter ein, single |
163 | 166 | ||
Line 198... | Line 201... | ||
198 | sei(); //interrupts einschalten |
201 | sei(); //interrupts einschalten |
Line 199... | Line 202... | ||
199 | 202 | ||
Line 200... | Line 203... | ||
200 | while (1) { |
203 | while (1) { |
201 | 204 | ||
202 | if(flag10ms) { // every 10ms |
205 | if(flag10ms) { // every 10ms |
- | 206 | flag10ms = 0; |
|
- | 207 | lprg_step(); // next step in light prog |
|
- | 208 | ||
- | 209 | if(!analog_state) { // Sampling der SPannung starten |
|
- | 210 | ADMUX = 0 | 0xC0; // Kanal 0, interne Referenz |
|
- | 211 | ADCSRA |= 0x10; // Ready löschen |
|
- | 212 | ADCSRA |= 0x40; // Start |
|
- | 213 | analog_state++; // erst wieder sampeln, wenn der Wert ausgelesen wurde |
|
203 | flag10ms = 0; |
214 | } |
Line 204... | Line 215... | ||
204 | lprg_step(); // next step in light prog |
215 | |
205 | } |
216 | } |
- | 217 | ||
206 | 218 | // 1s-Task: Status-LED toggeln, Spannung checken |
|
- | 219 | if(CheckDelay(tim1s)) { |
|
- | 220 | if (ADCSRA & 0x10) { // Spannungs-Messung beendet? |
|
- | 221 | ADCSRA = 0xD3; |
|
207 | // 1s-Task: Status-LED toggeln, Spannung checken |
222 | Vcurr = ADCW; // Wert merken |
208 | if(CheckDelay(tim1s)) { |
223 | analog_state = 0; |
- | 224 | } |
|
- | 225 | if(Vcurr < 180) { |
|
- | 226 | lprg_init(led_lowVolt); |
|
209 | Vcurr = getVcurr(); |
227 | } |
210 | if(Vcurr < 180) { |
228 | if(Vcurr>=180) { |
211 | lprg_init(led_lowVolt); |
229 | lprg_init(modes[current]); |
212 | } |
230 | } |
Line 213... | Line 231... | ||
213 | STATUS_TOGGLE; |
231 | STATUS_TOGGLE; |
214 | tim1s = SetDelay(1000); |
232 | tim1s = SetDelay(1000); |
215 | } |
- | |
216 | - | ||
217 | // 3s-Task: Unterspannungswarnung ggf. zurücknehmen |
233 | } |
218 | if(CheckDelay(tim3s)) { |
234 | |
219 | if(Vcurr>=180) { |
235 | // 3s-Task: Unterspannungswarnung ggf. zurücknehmen |
Line 220... | Line 236... | ||
220 | lprg_init(modes[current]); |
236 | if(CheckDelay(tim3s)) { |
221 | } |
237 |