Rev 311 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
* Blitzdings main.c
* (c) pangu
*/
#include "main.h"
#include "timer.h"
#include "lprg.h"
/* Strings zum definieren von Dauer-Ein Dauer-Aus */
const char l_on[]="A";
const char l_off[]="a";
// Wait flags:
// . 10 ms
// : 20 ms
// ; 50 ms
// I 100 ms
// N 200 ms
// M 300 ms
// V 500 ms
// S 1s
// LED:
// A-an a-aus
// 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[] = {
"A:aIA:aIA:aSV", // LED #1 rot
".", // LED #2
"NNaIASSNNN", // LED #3 blau
".", // LED #4
"NaIASSNNNN", // LED #5 weiss
"NA:aIA:aIA:aMS", // LED #6 grün
".", // LED #7
"aIASSNNNNN", // LED #8 weiss
".", // LED #9
"NNNaIASSNN" // LED #10 blau
};
char *led_aus[] = {
l_off, // LED #1 rot
l_off, // LED #2 blau
l_off, // LED #3 blau
l_off, // LED #4
l_off, // LED #5 weiss
l_off, // LED #6 grün
l_off, // LED #7
l_off, // LED #8 weiss
l_off, // LED #9
l_off // LED #10
};
char *led_an[] = {
l_on, // LED #1 rot
l_on, // LED #2 blau
l_on, // LED #3 blau
l_on, // LED #4
l_on, // LED #5 weiss
l_on, // LED #6 grün
l_on, // LED #7
l_on, // LED #8 weiss
l_on, // LED #9
l_on // LED #10
};
// alle LEDs toggeln synchron, 300ms Leucht/Aus-Dauer
char *led_flash1[] = {
"aMAM", // LED #1 rot
"aMAM", // LED #2 blau
"aMAM", // LED #3 blau
"aMAM", // LED #4
"aMAM", // LED #5 weiss
"aMAM", // LED #6 grün
"aMAM", // LED #7
"aMAM", // LED #8 weiss
"aMAM", // LED #9
"aMAM" // LED #10
};
// alle LEDs toggeln mit verschiednen Zykluszeiten
char *led_flash2[] = {
"a.A.", // LED #1 rot
"a:A:", // LED #2 blau
"a;A;", // LED #3 blau
"aIAI", // LED #4
"aNAN", // LED #5 weiss
"aMAM", // LED #6 grün
"aMIAMI", // LED #7
"aVAV", // LED #8 weiss
"aVIAVI", // LED #9
"aSAS" // LED #10
};
// Hier die zu verwendenden LichtProgramme einfach eintragen.
void *modes[]= { led_an, led_posflash, led_aus, led_flash1, led_flash2 };
void nextMode() {
static int current = 0;
lprg_init(modes[current]);
current = ++current % (sizeof(modes)/sizeof(void *));
}
ISR(INT1_vect)
{
nextMode();
}
int main() {
int tim10s, tim1s;
// Ports einstellen
// Pin B |7|6|5|4|3|2|1|0
// Binär:|0|0|0|0|0|1|0|1 (b) => #05 (h)
// Pin B0 und B2 als Ausgänge festlegen
DDRB = 0x05;
// Pin C |7|6|5|4|3|2|1|0
// Binär:|0|0|1|1|1|1|1|0 (b) => #3E (h)
// Pin C1 bis C5 als Ausgänge festlegen
DDRC = 0x3E;
// Pin D |7|6|5|4|3|2|1|0
// Binär:|1|1|1|1|0|0|0|0 (b) => #F0 (h)
DDRD = 0xF0;
//Pullup für PD3 aktivieren
PORTD |= (1 << PD3);
//interrupt konfigurueren
GIMSK = 1<<INT1;
MCUCR = 1<<ISC10;
ALLES_OFF;
STATUS_ON;
Timer_Init();
nextMode();
tim10s = SetDelay(10000);
tim1s = SetDelay(1000);
sei(); //interrupts einschalten
while (1) {
if(flag10ms) { // every 10ms
flag10ms = 0;
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
STATUS_TOGGLE;
tim1s = SetDelay(1000);
}
}
}