Tuer-Schild/Door/Door.cpp

115 lines
4.0 KiB
C++
Raw Normal View History

2014-09-05 01:39:40 +02:00
/*
* Door.cpp
*
* Created: 04.09.2014 22:06:23
* Author: netz
*/
2014-11-19 23:57:35 +01:00
#include "peripheral.h"
2014-09-05 01:39:40 +02:00
#include <util/delay.h>
2014-11-19 23:57:35 +01:00
uartclass Serial;
stripeclass stripe;
ledclass led;
compclass comp;
irclass ir;
2014-09-05 01:39:40 +02:00
const static uint8_t remotetimer = 10;
2014-09-05 01:39:40 +02:00
int main(void)
{
2014-11-19 23:57:35 +01:00
sei();
uint8_t doorstatus = 0;
stripe.setcolor(stripe.RED);
Serial.println("Rot!");
_delay_ms(100);
stripe.setcolor(stripe.GREEN);
Serial.println("Gr<EFBFBD>n!");
_delay_ms(100);
stripe.setcolor(stripe.BLUE);
Serial.println("Blau!");
_delay_ms(100);
stripe.setcolor(stripe.WHITE);
Serial.println("Wei<EFBFBD>, alles Initialisert! Habe Fertig und damit ab zum Normalbetrieb!");
_delay_ms(100);
2014-11-19 23:57:35 +01:00
led.green(1);
stripe.setcolor(stripe.BLACK);
uint8_t annoing_speed = 0;
2014-09-05 01:39:40 +02:00
while(1)
{
uint8_t c = ir.getCode();
switch(c) {
case 255: break; //Kein Code empfangen
case 0: if(annoing_speed<255) annoing_speed++; break; //Button High
case 1: if(annoing_speed>0) annoing_speed--; break; //Button Low
case 2: stripe.off(); break; //Button OFF
case 3: stripe.on(); break; //Button ON
case 4: stripe.fadeto(0xFF,0x00,0x00,remotetimer); break; //Button R
case 5: stripe.fadeto(0x00,0xFF,0x00,remotetimer); break; //Button G
case 6: stripe.fadeto(0x00,0x00,0xFF,remotetimer); break; //Button B
case 7: stripe.fadeto(0xFF,0xFF,0xFF,remotetimer); break; //Button W
case 8: stripe.fadeto(0xFF,0x40,0x00,remotetimer); break; //Color Red 100 % + Green 25 %
case 9: stripe.fadeto(0x00,0xFF,0x40,remotetimer); break; //Color Green 100 % + Blue 25 %
case 10: stripe.fadeto(0x40,0x00,0xFF,remotetimer); break; //Color Blue 100 % + Red 25 %
case 11: //Button Flash
stripe.setfadecolor(0, 0xFF, 0xFF, 0xFF, annoing_speed); //We use the Last Color for that.
stripe.setfadecolor(1, 0x00, 0x00, 0x00, annoing_speed);
stripe.fade(2);
break; //Button FlashEND
case 12: stripe.fadeto(0xFF,0x80,0x00,remotetimer); break; //Color Red 100 % + Green 50 %
case 13: stripe.fadeto(0x00,0xFF,0x80,remotetimer); break; //Color Green 100 % + Blue 50 %
case 14: stripe.fadeto(0x80,0x00,0xFF,remotetimer); break; //Color Blue 100 % + Red 50 %
case 15: //Button STROBE
stripe.setfadecolor(0, stripe.gp(0), stripe.gp(1), stripe.gp(2), annoing_speed); //We use the Last Color for that.
stripe.setfadecolor(1, 0x00, 0x00, 0x00, annoing_speed);
stripe.fade(2);
break; //Button STROBE
case 16: stripe.fadeto(0xFF,0xC0,0x00,remotetimer); break; //Color Red 100 % + Green 75 %
case 17: stripe.fadeto(0x00,0xFF,0xC0,remotetimer); break; //Color Green 100 % + Blue 75 %
case 18: stripe.fadeto(0xC0,0x00,0xFF,remotetimer); break; //Color Blue 100 % + Red 75 %
case 19:
stripe.setfadecolor(0, 0xFF, 0x00, 0x00, 255);
stripe.setfadecolor(1, 0xFF, 0xFF, 0x00, 255);
stripe.setfadecolor(2, 0x00, 0xFF, 0x00, 255);
stripe.setfadecolor(3, 0x00, 0xFF, 0xFF, 255);
stripe.setfadecolor(4, 0x00, 0x00, 0xFF, 255);
stripe.setfadecolor(5, 0xFF, 0x00, 0xFF, 255);
stripe.fade(6);
break; //Button FADE
case 20: stripe.fadeto(0xFF,0xFF,0x00,remotetimer); break; //Color Red 100 % + Green 100 %
case 21: stripe.fadeto(0x00,0xFF,0xFF,remotetimer); break; //Color Green 100 % + Blue 100 %
case 22: stripe.fadeto(0xFF,0x00,0xFF,remotetimer); break; //Color Blue 100 % + Red 100 %
case 23:
stripe.setfadecolor(0, 0x00, 0xFF, 0x10, 25);
stripe.setfadecolor(1, 0x00, 0xAA, 0x10, 15);
stripe.fade(2);
break; //Button SMOOTH
default: Serial.printDec(c); Serial.println(" Pressed!"); break; //Code den ich nicht kenne
}
if(comp.is_active()) {
if(doorstatus == 0) {
doorstatus = 1;
stripe.fadeto(0xFF,0x00,0x00,100);
Serial.println("T<EFBFBD>r Zu...");
}
} else {
if(doorstatus == 1) {
doorstatus = 0;
Serial.println("T<EFBFBD>r Offen...");
stripe.fadeto(0x00,0xFF,0x00,50);
}
}
_delay_ms(1);
led.green(0);
_delay_ms(99);
led.green(1);
2014-11-19 23:57:35 +01:00
}
}
ISR(INT0_vect) {
ir.interrupt();
}
2014-11-19 23:57:35 +01:00
ISR(TIMER1_OVF_vect) {
stripe.interrupt();
}