![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
nein
Dependencies: Debouncer DigitDisplay Led-libary PCF8563 mbed
Fork of WS_7_Seg_mit_LM1635 by
main.cpp@1:838565907c81, 2016-04-29 (annotated)
- Committer:
- sophia
- Date:
- Fri Apr 29 06:32:42 2016 +0000
- Revision:
- 1:838565907c81
- Parent:
- 0:925e9ab5be17
bla
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sophia | 0:925e9ab5be17 | 1 | #include "mbed.h" |
sophia | 0:925e9ab5be17 | 2 | #include "DigitDisplay.h" |
sophia | 1:838565907c81 | 3 | #include "WS2812B.h" |
sophia | 1:838565907c81 | 4 | #include "PCF8563.h" |
sophia | 0:925e9ab5be17 | 5 | |
sophia | 1:838565907c81 | 6 | #define rGb (0x0f0000) //Rot |
sophia | 1:838565907c81 | 7 | #define Rgb (0x00ff00) //Grün |
sophia | 1:838565907c81 | 8 | #define rgB (0x0000ff) //Blau |
sophia | 1:838565907c81 | 9 | #define RgB (0x00ffff) //Violet |
sophia | 1:838565907c81 | 10 | #define rGB (0xff00ff) //Türkis |
sophia | 1:838565907c81 | 11 | #define RGb (0xffff00) //Rot-Grün |
sophia | 1:838565907c81 | 12 | #define RGB (0xffffff) //Weiß |
sophia | 1:838565907c81 | 13 | #define rgb (0x000000) //Aus |
sophia | 1:838565907c81 | 14 | //halbe Helligkeit |
sophia | 1:838565907c81 | 15 | #define hrGb (0x0f0000) //Rot |
sophia | 1:838565907c81 | 16 | #define hRgb (0x000f00) //Grün |
sophia | 1:838565907c81 | 17 | #define hrgB (0x00000f) //Blau |
sophia | 1:838565907c81 | 18 | #define hRgB (0x000f0f) //Violet |
sophia | 1:838565907c81 | 19 | #define hrGB (0x0f000f) //Türkis |
sophia | 1:838565907c81 | 20 | #define hRGb (0x0f0f00) //Rot-Grün |
sophia | 1:838565907c81 | 21 | #define hRGB (0x0f0f0f) //Weiß |
sophia | 1:838565907c81 | 22 | |
sophia | 1:838565907c81 | 23 | |
sophia | 1:838565907c81 | 24 | Timeout timer; |
sophia | 1:838565907c81 | 25 | PCF8563 rtc; |
sophia | 0:925e9ab5be17 | 26 | |
sophia | 1:838565907c81 | 27 | DigitalOut Led1(LED1); |
sophia | 1:838565907c81 | 28 | DigitalOut Led2(LED2); |
sophia | 1:838565907c81 | 29 | DigitalOut Led3(LED3); |
sophia | 1:838565907c81 | 30 | DigitalOut Led4(LED4); |
sophia | 1:838565907c81 | 31 | |
sophia | 1:838565907c81 | 32 | InterruptIn Taster1(p17); |
sophia | 1:838565907c81 | 33 | InterruptIn Taster2(p18); |
sophia | 1:838565907c81 | 34 | InterruptIn Taster3(p19); |
sophia | 1:838565907c81 | 35 | InterruptIn Taster4(p20); |
sophia | 1:838565907c81 | 36 | InterruptIn InternTaster1(P1_16); |
sophia | 1:838565907c81 | 37 | InterruptIn InternTaster2(P0_23); |
sophia | 1:838565907c81 | 38 | InterruptIn InternTaster3(P0_10); |
sophia | 1:838565907c81 | 39 | InterruptIn InternTaster4(P0_15); |
sophia | 1:838565907c81 | 40 | |
sophia | 1:838565907c81 | 41 | PwmOut Summer(p6); |
sophia | 1:838565907c81 | 42 | |
sophia | 1:838565907c81 | 43 | LedOut RGBStripe(p25); |
sophia | 1:838565907c81 | 44 | // (CLK, I/O) |
sophia | 1:838565907c81 | 45 | DigitDisplay TimerDisplay(p21, p22); |
sophia | 1:838565907c81 | 46 | // (CLK, I/O) |
sophia | 1:838565907c81 | 47 | DigitDisplay UhrDisplay(p23, p24); |
sophia | 1:838565907c81 | 48 | uint8_t hour, minute, sec; |
sophia | 1:838565907c81 | 49 | |
sophia | 1:838565907c81 | 50 | int zahl =02; // Schmiedi mach was mit den Tastern, dass man die Zahl einstellen kann |
sophia | 1:838565907c81 | 51 | int second = 00; |
sophia | 0:925e9ab5be17 | 52 | int t; |
sophia | 0:925e9ab5be17 | 53 | int h; |
sophia | 0:925e9ab5be17 | 54 | int z; |
sophia | 0:925e9ab5be17 | 55 | int e; |
sophia | 0:925e9ab5be17 | 56 | bool colon = true; |
sophia | 1:838565907c81 | 57 | int vergleich=(zahl*60); |
sophia | 0:925e9ab5be17 | 58 | |
sophia | 0:925e9ab5be17 | 59 | |
sophia | 1:838565907c81 | 60 | int color; |
sophia | 1:838565907c81 | 61 | |
sophia | 1:838565907c81 | 62 | Serial pc(USBTX, USBRX); |
sophia | 1:838565907c81 | 63 | |
sophia | 0:925e9ab5be17 | 64 | void berechne() |
sophia | 0:925e9ab5be17 | 65 | { |
sophia | 0:925e9ab5be17 | 66 | t= zahl/10; |
sophia | 0:925e9ab5be17 | 67 | h= (zahl-(t*10))/1; |
sophia | 1:838565907c81 | 68 | z= second/10; |
sophia | 1:838565907c81 | 69 | e= (second-(z*10))/1; |
sophia | 1:838565907c81 | 70 | } |
sophia | 1:838565907c81 | 71 | |
sophia | 1:838565907c81 | 72 | void ausgabe() |
sophia | 1:838565907c81 | 73 | { |
sophia | 1:838565907c81 | 74 | TimerDisplay.write(0, t); |
sophia | 1:838565907c81 | 75 | TimerDisplay.write(1, h); |
sophia | 1:838565907c81 | 76 | TimerDisplay.write(2, z); |
sophia | 1:838565907c81 | 77 | TimerDisplay.write(3, e); |
sophia | 1:838565907c81 | 78 | pc.printf("\n %d %d : %d %d" ,t, h ,z,e); |
sophia | 1:838565907c81 | 79 | |
sophia | 0:925e9ab5be17 | 80 | } |
sophia | 0:925e9ab5be17 | 81 | |
sophia | 1:838565907c81 | 82 | |
sophia | 1:838565907c81 | 83 | |
sophia | 1:838565907c81 | 84 | |
sophia | 1:838565907c81 | 85 | |
sophia | 1:838565907c81 | 86 | void StripeOut() |
sophia | 1:838565907c81 | 87 | { |
sophia | 1:838565907c81 | 88 | __disable_irq(); //Interrupt deaktivieren |
sophia | 1:838565907c81 | 89 | |
sophia | 1:838565907c81 | 90 | for(int r=0; r<=10; r++) |
sophia | 1:838565907c81 | 91 | RGBStripe.WriteLed(color); //Farbe rausschreiben |
sophia | 1:838565907c81 | 92 | |
sophia | 1:838565907c81 | 93 | __enable_irq(); //Interrupt reaktivieren |
sophia | 1:838565907c81 | 94 | } |
sophia | 1:838565907c81 | 95 | |
sophia | 1:838565907c81 | 96 | void UhrOut() |
sophia | 0:925e9ab5be17 | 97 | { |
sophia | 1:838565907c81 | 98 | hour = rtc.read(HOURS); |
sophia | 1:838565907c81 | 99 | minute = rtc.read(MINUTES); |
sophia | 1:838565907c81 | 100 | sec = rtc.read(SECONDS); |
sophia | 1:838565907c81 | 101 | |
sophia | 1:838565907c81 | 102 | UhrDisplay.write(0, (minute >> 4)- 8); |
sophia | 1:838565907c81 | 103 | UhrDisplay.write(1, (minute & 0x0F)); |
sophia | 1:838565907c81 | 104 | UhrDisplay.setColon(1); |
sophia | 1:838565907c81 | 105 | UhrDisplay.write(2, (sec >> 4)- 8); |
sophia | 1:838565907c81 | 106 | UhrDisplay.write(3, (sec & 0x0F)); |
sophia | 1:838565907c81 | 107 | |
sophia | 1:838565907c81 | 108 | } |
sophia | 1:838565907c81 | 109 | |
sophia | 1:838565907c81 | 110 | void changecolor() |
sophia | 1:838565907c81 | 111 | { |
sophia | 1:838565907c81 | 112 | color = hRGb; |
sophia | 0:925e9ab5be17 | 113 | } |
sophia | 0:925e9ab5be17 | 114 | |
sophia | 1:838565907c81 | 115 | int main() |
sophia | 0:925e9ab5be17 | 116 | { |
sophia | 1:838565907c81 | 117 | |
sophia | 1:838565907c81 | 118 | |
sophia | 0:925e9ab5be17 | 119 | while(1) { |
sophia | 1:838565907c81 | 120 | |
sophia | 1:838565907c81 | 121 | |
sophia | 1:838565907c81 | 122 | |
sophia | 1:838565907c81 | 123 | for( int x = (zahl+1); x > 0; x--) { |
sophia | 0:925e9ab5be17 | 124 | |
sophia | 1:838565907c81 | 125 | |
sophia | 1:838565907c81 | 126 | for (int y=second; y > 0; y--) { |
sophia | 1:838565907c81 | 127 | |
sophia | 1:838565907c81 | 128 | //color = hrGb; |
sophia | 1:838565907c81 | 129 | |
sophia | 1:838565907c81 | 130 | // timer.attach(&changecolor, vergleich*0.2); |
sophia | 1:838565907c81 | 131 | if((y+x*60)<=vergleich*0.2) |
sophia | 1:838565907c81 | 132 | color = hRGb; |
sophia | 1:838565907c81 | 133 | |
sophia | 1:838565907c81 | 134 | else |
sophia | 1:838565907c81 | 135 | color = hrGb; |
sophia | 1:838565907c81 | 136 | |
sophia | 1:838565907c81 | 137 | TimerDisplay.setColon(colon); |
sophia | 1:838565907c81 | 138 | |
sophia | 1:838565907c81 | 139 | second--; |
sophia | 1:838565907c81 | 140 | berechne(); |
sophia | 1:838565907c81 | 141 | ausgabe(); |
sophia | 1:838565907c81 | 142 | StripeOut(); |
sophia | 1:838565907c81 | 143 | UhrOut(); |
sophia | 1:838565907c81 | 144 | wait(0.2); |
sophia | 1:838565907c81 | 145 | |
sophia | 1:838565907c81 | 146 | } |
sophia | 1:838565907c81 | 147 | |
sophia | 1:838565907c81 | 148 | zahl--; |
sophia | 1:838565907c81 | 149 | second = 60; |
sophia | 1:838565907c81 | 150 | |
sophia | 0:925e9ab5be17 | 151 | |
sophia | 0:925e9ab5be17 | 152 | } |
sophia | 1:838565907c81 | 153 | |
sophia | 1:838565907c81 | 154 | TimerDisplay.on(); |
sophia | 0:925e9ab5be17 | 155 | wait(0.5); |
sophia | 1:838565907c81 | 156 | TimerDisplay.off(); |
sophia | 0:925e9ab5be17 | 157 | wait(0.5); |
sophia | 1:838565907c81 | 158 | |
sophia | 0:925e9ab5be17 | 159 | } |
sophia | 0:925e9ab5be17 | 160 | } |