17,6 → 17,7 |
|
#include "main.h" |
#include "timer.h" |
#include "analog.h" |
#include "lprg.h" |
|
/* Strings zum definieren von Dauer-Ein Dauer-Aus */ |
37,7 → 38,7 |
|
// Rot+Grün blitzen dreimal kurz, zeitlich leicht versetzt, alle 1,5s |
// 2 weisse und 2 blaue LEDs sind an und gehen alle 3s reihum kurz aus |
char *led_posflash[] = { |
char *led_posflash1[] = { |
"A:aIA:aIA:aSV", // LED #1 rot |
".", // LED #2 |
"NNaIASSNNN", // LED #3 blau |
50,7 → 51,21 |
"NNNaIASSNN" // LED #10 blau |
}; |
|
// dasselbe, nur sind w/b dauer-an |
char *led_posflash[] = { |
"A:aIA:aIA:aSV", // LED #1 rot |
".", // LED #2 |
"A", // LED #3 blau |
".", // LED #4 |
"A", // LED #5 weiss |
"NA:aIA:aIA:aMS", // LED #6 grün |
".", // LED #7 |
"A", // LED #8 weiss |
".", // LED #9 |
"A" // LED #10 blau |
}; |
|
|
char *led_aus[] = { |
l_off, // LED #1 rot |
l_off, // LED #2 blau |
91,6 → 106,20 |
"aMAM" // LED #10 |
}; |
|
// low Volatage Warning: alle LEDs toggeln synchron, 100ms Leucht/Aus-Dauer |
char *led_lowVolt[] = { |
"aIAI", // LED #1 rot |
"aIAI", // LED #2 blau |
"aIAI", // LED #3 blau |
"aIAI", // LED #4 |
"aIAI", // LED #5 weiss |
"aIAI", // LED #6 grün |
"aIAI", // LED #7 |
"aIAI", // LED #8 weiss |
"aIAI", // LED #9 |
"aIAI" // LED #10 |
}; |
|
// alle LEDs toggeln mit verschiednen Zykluszeiten |
char *led_flash2[] = { |
"a.A.", // LED #1 rot |
107,15 → 136,15 |
|
|
// Hier die zu verwendenden LichtProgramme einfach eintragen. |
void *modes[]= { led_an, led_posflash, led_aus, led_flash1, led_flash2 }; |
|
int current = 0; |
void *modes[]= { led_posflash, led_an, led_aus }; |
|
void nextMode() { |
|
static int current = 0; |
|
current = ++current % (sizeof(modes)/sizeof(void *)); |
lprg_init(modes[current]); |
current = ++current % (sizeof(modes)/sizeof(void *)); |
|
|
} |
|
ISR(INT1_vect) |
129,7 → 158,8 |
|
int main() { |
|
int tim10s, tim1s; |
int tim1s, tim3s, tim10s; |
int Vcurr; |
|
// Ports einstellen |
// Pin B |7|6|5|4|3|2|1|0 |
158,10 → 188,13 |
STATUS_ON; |
|
Timer_Init(); |
nextMode(); |
|
lprg_init(modes[current]); |
tim10s = SetDelay(10000); |
tim3s = SetDelay(3000); |
tim1s = SetDelay(1000); |
|
|
sei(); //interrupts einschalten |
|
while (1) { |
171,14 → 204,32 |
lprg_step(); // next step in light prog |
} |
|
if(CheckDelay(tim10s)) { // alle 10 sec programm wechseln |
nextMode(); |
tim10s = SetDelay(10000); |
} |
if(CheckDelay(tim1s)) { // alle 1 sec STatus-LED toggeln |
// 1s-Task: Status-LED toggeln, Spannung checken |
if(CheckDelay(tim1s)) { |
Vcurr = getVcurr(); |
if(Vcurr < 180) { |
lprg_init(led_lowVolt); |
} |
STATUS_TOGGLE; |
tim1s = SetDelay(1000); |
} |
|
// 3s-Task: Unterspannungswarnung ggf. zurücknehmen |
if(CheckDelay(tim3s)) { |
if(Vcurr>=180) { |
lprg_init(modes[current]); |
} |
tim3s = SetDelay(3000); |
} |
|
// 10s-Task: DEMO: programm wechseln |
if(CheckDelay(tim10s)) { |
// nextMode(); |
tim10s = SetDelay(10000); |
} |
|
|
|
} |
|
} |