Dependencies: DigitDisplay PCF8563 Led-libary dPrell mbed
Revision 0:c7b01fe7c67c, committed 2016-06-03
- Comitter:
- 04M04
- Date:
- Fri Jun 03 08:25:06 2016 +0000
- Commit message:
Changed in this revision
diff -r 000000000000 -r c7b01fe7c67c DigitDisplay.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DigitDisplay.lib Fri Jun 03 08:25:06 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/seeed/code/DigitDisplay/#d3173c8bfd48
diff -r 000000000000 -r c7b01fe7c67c PCF8563.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PCF8563.lib Fri Jun 03 08:25:06 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/Ladner-Schmied/code/PCF8563/#d7f120bcedd7
diff -r 000000000000 -r c7b01fe7c67c WS2812.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WS2812.lib Fri Jun 03 08:25:06 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/Ladner-Schmied/code/Led-libary/#a2549b9f2785
diff -r 000000000000 -r c7b01fe7c67c dPrell.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dPrell.lib Fri Jun 03 08:25:06 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/Ladner-Schmied/code/dPrell/#7a8af0d62537
diff -r 000000000000 -r c7b01fe7c67c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 03 08:25:06 2016 +0000 @@ -0,0 +1,259 @@ +//______________________________________________________Bibliotheken +#include "mbed.h" +#include "WS2812B.h" +#include "PCF8563.h" +#include "DigitDisplay.h" +#include "dPrell.h" +//______________________________________________________Farbdefinitionen +// G R B +// | | | +#define rGb (0x0f0000) //Grün +#define Rgb (0x00ff00) //Rot +#define rgB (0x0000ff) //Blau +#define RgB (0x00ffff) //Violet +#define rGB (0xff00ff) //Türkis +#define RGb (0xffff00) //Rot-Grün +#define RGB (0xffffff) //Weiß +#define rgb (0x000000) //Aus +//halbe Helligkeit +#define hrGb (0x0f0000) //Grün +#define hRgb (0x000f00) //Rot +#define hrgB (0x00000f) //Blau +#define hRgB (0x000f0f) //Violet +#define hrGB (0x0f000f) //Türkis +#define hRGb (0x0f0f00) //Rot-Grün +#define hRGB (0x0f0f0f) //Weiß +//______________________________________________________Schnittstellen +Ticker TickerOutput; + +PCF8563 rtc; + +DigitalOut Led1(LED1); +DigitalOut Led2(LED2); +DigitalOut Led3(LED3); +DigitalOut Led4(LED4); + +dPrell Taster1(p17); +dPrell Taster2(p18); +dPrell Taster3(p19); +dPrell Taster4(p20); +dPrell InternTaster1(P1_16); +dPrell InternTaster2(P0_23); +dPrell InternTaster3(P0_10); +dPrell InternTaster4(P0_15); + +PwmOut Summer(p6); + +LedOut RGBStripe(p25); +// (CLK, I/O) +DigitDisplay TimerDisplay(p21, p22); +// (CLK, I/O) +DigitDisplay UhrDisplay(p23, p24); + +Serial pc(USBTX, USBRX); +//______________________________________________________Variablen + +uint8_t hour, minute, sec; + +int color = rgb; +int ColorTime = 0; +int Prozent = 0; +int TimerZeit = 0; +int TimerMinuten = 0; +int TimerSekunden = 0; +int UhrZeit = 0; +int SetMenu = 0; +int StartStop = 0; +int End = 0; +//______________________________________________________Funktionen + +void Set(); +void Plus(); +void Minus(); +void TimerStartStop(); +void TasterTrig(); + +void TimerIn(); +void TimerPlay(); +void TimerOut(); +void ChangeColor(); +void StripeOut(); +void UhrOut(); +void SummerOut(); +void Output(); +void EndSignal(); +//______________________________________________________Main +int main() +{ + TickerOutput.attach(&Output, 0.1); + + Taster1.rise(&Set); + Taster2.rise(&Plus); + Taster3.rise(&Minus); + Taster4.rise(&TimerStartStop); + InternTaster1.rise(&Set); + InternTaster2.rise(&Plus); + InternTaster3.rise(&Minus); + InternTaster4.rise(&TimerStartStop); + while(1) { + if(SetMenu == 0 && (TimerMinuten > 0 || TimerSekunden > 0) && StartStop == 1) { + TimerPlay(); + } else if(SetMenu == 0 && StartStop >=0) { + StartStop = 0; + } + if(End > 0) { + EndSignal(); + } + } +} +//______________________________________________________Interrupts + +void Set() +{ + Led1 = !Led1; + if (SetMenu == 0 && StartStop == 0) { + SetMenu++; + } else if (SetMenu >= 1 && StartStop == 0) { + SetMenu = 0; + } + End = 0; + Summer.pulsewidth(0); + TasterTrig(); +} +void Plus() +{ + Led2 = !Led2; + if(SetMenu==1) { + TimerMinuten++; + TimerSekunden = 0; + } + TasterTrig(); + +} +void Minus() +{ + Led3 = !Led3; + if(SetMenu==1 && minute>0) { + TimerMinuten--; + TimerSekunden = 0; + } + TasterTrig(); + +} +void TimerStartStop() +{ + Led4 = !Led4; + if(SetMenu == 0 && (TimerMinuten > 0 || TimerSekunden > 0) && StartStop == 0) { + StartStop++; + } else if(SetMenu == 0 && StartStop >=1) { + StartStop = 0; + } + TasterTrig(); +} +//______________________________________________________Funktionen + +void TasterTrig() +{ + Taster1.trig(); + Taster2.trig(); + Taster3.trig(); + Taster4.trig(); + InternTaster1.trig(); + InternTaster2.trig(); + InternTaster3.trig(); + InternTaster4.trig(); +} +//______________________________________________________Timer-Bereich + +void TimerPlay() +{ + while(TimerMinuten > 0) { + if(TimerSekunden == 0) { + TimerMinuten--; + TimerSekunden = 60; + } + while(TimerSekunden >0) { + TimerSekunden--; + wait(1); + if(StartStop==0) { + return; + } + } + } + if(TimerMinuten < 1 && TimerSekunden < 1) { + End++; + StartStop = 0; + } + return; +} + +void TimerOut() +{ + TimerZeit = (TimerMinuten * 100) + TimerSekunden; + TimerDisplay.write(TimerZeit); + TimerDisplay.setColon(1); +} +//______________________________________________________RGB-,Uhr-,Summer-Bereich + +void ChangeColor() +{ + if(ColorTime <= 10) { + color = Rgb; + } else if(ColorTime <= 50) { + color = rGB; + } else + color = rGb; +} + +void StripeOut() +{ + __disable_irq(); //Interrupt deaktivieren + + for(int r=1; r<=Prozent; r++) + RGBStripe.WriteLed(color); //Farbe rausschreiben + + __enable_irq(); //Interrupt reaktivieren +} + +void UhrOut() +{ + hour = rtc.read(HOURS); + minute = rtc.read(MINUTES); + sec = rtc.read(SECONDS); + + UhrDisplay.write(0, (minute >> 4)- 8); + UhrDisplay.write(1, (minute & 0x0F)); + UhrDisplay.setColon(1); + UhrDisplay.write(2, (sec >> 4)- 8); + UhrDisplay.write(3, (sec & 0x0F)); +} + +void SummerOut() +{ + // specify period first, then everything else + Summer.period(0.001f); // 0.001 second period + Summer.pulsewidth(0.0004); // 0.0004 second pulse (on) + // led flashing + wait(4); + Summer.pulsewidth(0); +} + +void Output() +{ + TimerOut(); + //StripeOut(); + UhrOut(); +} + +void EndSignal() +{ + __disable_irq(); + color = Rgb; + Prozent = 10; + StripeOut(); + SummerOut(); + color = rgb; + StripeOut(); + End = 0; + __enable_irq(); +} \ No newline at end of file
diff -r 000000000000 -r c7b01fe7c67c mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jun 03 08:25:06 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/082adc85693f \ No newline at end of file