Rev 311 | Rev 341 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 311 | Rev 312 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | */ |
15 | */ |
16 | /******************************************************************/ |
16 | /******************************************************************/ |
Line 17... | Line 17... | ||
17 | 17 | ||
18 | #include "main.h" |
18 | #include "main.h" |
- | 19 | #include "timer.h" |
|
19 | #include "timer.h" |
20 | #include "analog.h" |
Line 20... | Line 21... | ||
20 | #include "lprg.h" |
21 | #include "lprg.h" |
21 | 22 | ||
22 | /* Strings zum definieren von Dauer-Ein Dauer-Aus */ |
23 | /* Strings zum definieren von Dauer-Ein Dauer-Aus */ |
Line 35... | Line 36... | ||
35 | // LED: |
36 | // LED: |
36 | // A-an a-aus |
37 | // A-an a-aus |
Line 37... | Line 38... | ||
37 | 38 | ||
38 | // Rot+Grün blitzen dreimal kurz, zeitlich leicht versetzt, alle 1,5s |
39 | // 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 | // 2 weisse und 2 blaue LEDs sind an und gehen alle 3s reihum kurz aus |
40 | char *led_posflash[] = { |
41 | char *led_posflash1[] = { |
41 | "A:aIA:aIA:aSV", // LED #1 rot |
42 | "A:aIA:aIA:aSV", // LED #1 rot |
42 | ".", // LED #2 |
43 | ".", // LED #2 |
43 | "NNaIASSNNN", // LED #3 blau |
44 | "NNaIASSNNN", // LED #3 blau |
44 | ".", // LED #4 |
45 | ".", // LED #4 |
Line 48... | Line 49... | ||
48 | "aIASSNNNNN", // LED #8 weiss |
49 | "aIASSNNNNN", // LED #8 weiss |
49 | ".", // LED #9 |
50 | ".", // LED #9 |
50 | "NNNaIASSNN" // LED #10 blau |
51 | "NNNaIASSNN" // LED #10 blau |
51 | }; |
52 | }; |
Line -... | Line 53... | ||
- | 53 | ||
- | 54 | // dasselbe, nur sind w/b dauer-an |
|
- | 55 | char *led_posflash[] = { |
|
- | 56 | "A:aIA:aIA:aSV", // LED #1 rot |
|
- | 57 | ".", // LED #2 |
|
- | 58 | "A", // LED #3 blau |
|
- | 59 | ".", // LED #4 |
|
- | 60 | "A", // LED #5 weiss |
|
- | 61 | "NA:aIA:aIA:aMS", // LED #6 grün |
|
- | 62 | ".", // LED #7 |
|
- | 63 | "A", // LED #8 weiss |
|
- | 64 | ".", // LED #9 |
|
- | 65 | "A" // LED #10 blau |
|
- | 66 | }; |
|
Line 52... | Line 67... | ||
52 | 67 | ||
53 | 68 | ||
54 | char *led_aus[] = { |
69 | char *led_aus[] = { |
55 | l_off, // LED #1 rot |
70 | l_off, // LED #1 rot |
Line 89... | Line 104... | ||
89 | "aMAM", // LED #8 weiss |
104 | "aMAM", // LED #8 weiss |
90 | "aMAM", // LED #9 |
105 | "aMAM", // LED #9 |
91 | "aMAM" // LED #10 |
106 | "aMAM" // LED #10 |
92 | }; |
107 | }; |
Line -... | Line 108... | ||
- | 108 | ||
- | 109 | // low Volatage Warning: alle LEDs toggeln synchron, 100ms Leucht/Aus-Dauer |
|
- | 110 | char *led_lowVolt[] = { |
|
- | 111 | "aIAI", // LED #1 rot |
|
- | 112 | "aIAI", // LED #2 blau |
|
- | 113 | "aIAI", // LED #3 blau |
|
- | 114 | "aIAI", // LED #4 |
|
- | 115 | "aIAI", // LED #5 weiss |
|
- | 116 | "aIAI", // LED #6 grün |
|
- | 117 | "aIAI", // LED #7 |
|
- | 118 | "aIAI", // LED #8 weiss |
|
- | 119 | "aIAI", // LED #9 |
|
- | 120 | "aIAI" // LED #10 |
|
- | 121 | }; |
|
93 | 122 | ||
94 | // alle LEDs toggeln mit verschiednen Zykluszeiten |
123 | // alle LEDs toggeln mit verschiednen Zykluszeiten |
95 | char *led_flash2[] = { |
124 | char *led_flash2[] = { |
96 | "a.A.", // LED #1 rot |
125 | "a.A.", // LED #1 rot |
97 | "a:A:", // LED #2 blau |
126 | "a:A:", // LED #2 blau |
Line 105... | Line 134... | ||
105 | "aSAS" // LED #10 |
134 | "aSAS" // LED #10 |
106 | }; |
135 | }; |
Line 107... | Line 136... | ||
107 | 136 | ||
108 | - | ||
Line 109... | Line 137... | ||
109 | // Hier die zu verwendenden LichtProgramme einfach eintragen. |
137 | |
- | 138 | // Hier die zu verwendenden LichtProgramme einfach eintragen. |
|
Line 110... | Line 139... | ||
110 | void *modes[]= { led_an, led_posflash, led_aus, led_flash1, led_flash2 }; |
139 | |
Line 111... | Line -... | ||
111 | - | ||
112 | void nextMode() { |
140 | int current = 0; |
- | 141 | void *modes[]= { led_posflash, led_an, led_aus }; |
|
113 | 142 | ||
114 | static int current = 0; |
143 | void nextMode() { |
Line 115... | Line 144... | ||
115 | 144 | ||
116 | lprg_init(modes[current]); |
145 | current = ++current % (sizeof(modes)/sizeof(void *)); |
Line 127... | Line 156... | ||
127 | 156 | ||
Line 128... | Line 157... | ||
128 | 157 | ||
- | 158 | ||
Line 129... | Line 159... | ||
129 | 159 | int main() { |
|
130 | int main() { |
160 | |
131 | 161 | int tim1s, tim3s, tim10s; |
|
132 | int tim10s, tim1s; |
162 | int Vcurr; |
Line 156... | Line 186... | ||
156 | ALLES_OFF; |
186 | ALLES_OFF; |
Line 157... | Line 187... | ||
157 | 187 | ||
Line 158... | Line 188... | ||
158 | STATUS_ON; |
188 | STATUS_ON; |
- | 189 | ||
159 | 190 | Timer_Init(); |
|
160 | Timer_Init(); |
191 | |
- | 192 | lprg_init(modes[current]); |
|
161 | nextMode(); |
193 | tim10s = SetDelay(10000); |
Line -... | Line 194... | ||
- | 194 | tim3s = SetDelay(3000); |
|
162 | tim10s = SetDelay(10000); |
195 | tim1s = SetDelay(1000); |
Line 163... | Line 196... | ||
163 | tim1s = SetDelay(1000); |
196 | |
Line 164... | Line 197... | ||
164 | 197 | ||
165 | sei(); //interrupts einschalten |
198 | sei(); //interrupts einschalten |
166 | 199 | ||
167 | while (1) { |
200 | while (1) { |
Line -... | Line 201... | ||
- | 201 | ||
168 | 202 | if(flag10ms) { // every 10ms |
|
- | 203 | flag10ms = 0; |
|
169 | if(flag10ms) { // every 10ms |
204 | lprg_step(); // next step in light prog |
170 | flag10ms = 0; |
205 | } |
171 | lprg_step(); // next step in light prog |
206 | |
172 | } |
- | |
173 | 207 | // 1s-Task: Status-LED toggeln, Spannung checken |
|
174 | if(CheckDelay(tim10s)) { // alle 10 sec programm wechseln |
208 | if(CheckDelay(tim1s)) { |
175 | nextMode(); |
209 | Vcurr = getVcurr(); |
- | 210 | if(Vcurr < 180) { |
|
- | 211 | lprg_init(led_lowVolt); |
|
- | 212 | } |
|
- | 213 | STATUS_TOGGLE; |
|
- | 214 | tim1s = SetDelay(1000); |
|
- | 215 | } |
|
- | 216 | ||
- | 217 | // 3s-Task: Unterspannungswarnung ggf. zurücknehmen |
|
- | 218 | if(CheckDelay(tim3s)) { |
|
- | 219 | if(Vcurr>=180) { |
|
- | 220 | lprg_init(modes[current]); |
|
- | 221 | } |
|
- | 222 | tim3s = SetDelay(3000); |
|
- | 223 | } |
|
- | 224 | ||
- | 225 | // 10s-Task: DEMO: programm wechseln |
|
- | 226 | if(CheckDelay(tim10s)) { |
|
176 | tim10s = SetDelay(10000); |
227 | // nextMode(); |
Line 177... | Line 228... | ||
177 | } |
228 | tim10s = SetDelay(10000); |