![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Hier könnte funktionieren
main.cpp@0:0bec2b815282, 2016-01-15 (annotated)
- Committer:
- PinguPanda
- Date:
- Fri Jan 15 11:59:57 2016 +0000
- Revision:
- 0:0bec2b815282
Hier Garantier nichts
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
PinguPanda | 0:0bec2b815282 | 1 | #include "mbed.h" |
PinguPanda | 0:0bec2b815282 | 2 | |
PinguPanda | 0:0bec2b815282 | 3 | |
PinguPanda | 0:0bec2b815282 | 4 | Ticker Tick; |
PinguPanda | 0:0bec2b815282 | 5 | |
PinguPanda | 0:0bec2b815282 | 6 | Serial pc(USBTX, USBRX); |
PinguPanda | 0:0bec2b815282 | 7 | |
PinguPanda | 0:0bec2b815282 | 8 | C12832 lcd(p5, p7, p6, p8, p11); |
PinguPanda | 0:0bec2b815282 | 9 | |
PinguPanda | 0:0bec2b815282 | 10 | int msek; |
PinguPanda | 0:0bec2b815282 | 11 | int sek; |
PinguPanda | 0:0bec2b815282 | 12 | int min; |
PinguPanda | 0:0bec2b815282 | 13 | int stund; |
PinguPanda | 0:0bec2b815282 | 14 | int wert; |
PinguPanda | 0:0bec2b815282 | 15 | int nr; |
PinguPanda | 0:0bec2b815282 | 16 | bool state;//true =countdownmode //false == inputmode |
PinguPanda | 0:0bec2b815282 | 17 | |
PinguPanda | 0:0bec2b815282 | 18 | void zaehl() |
PinguPanda | 0:0bec2b815282 | 19 | { |
PinguPanda | 0:0bec2b815282 | 20 | if(state) |
PinguPanda | 0:0bec2b815282 | 21 | { |
PinguPanda | 0:0bec2b815282 | 22 | wert--; |
PinguPanda | 0:0bec2b815282 | 23 | msek=wert % 1000; |
PinguPanda | 0:0bec2b815282 | 24 | nr=wert-msek; |
PinguPanda | 0:0bec2b815282 | 25 | sek=nr % 60; |
PinguPanda | 0:0bec2b815282 | 26 | nr=nr-sek; |
PinguPanda | 0:0bec2b815282 | 27 | min=nr %60; |
PinguPanda | 0:0bec2b815282 | 28 | nr=nr-min; |
PinguPanda | 0:0bec2b815282 | 29 | stund=nr %24; |
PinguPanda | 0:0bec2b815282 | 30 | } |
PinguPanda | 0:0bec2b815282 | 31 | } |
PinguPanda | 0:0bec2b815282 | 32 | |
PinguPanda | 0:0bec2b815282 | 33 | int main() { |
PinguPanda | 0:0bec2b815282 | 34 | Tick.attach(&zaehl, 0.001); |
PinguPanda | 0:0bec2b815282 | 35 | while(1) { |
PinguPanda | 0:0bec2b815282 | 36 | if(!state) |
PinguPanda | 0:0bec2b815282 | 37 | { |
PinguPanda | 0:0bec2b815282 | 38 | pc.printf("Setze deinen Countdown Wert in Millisekunden"); |
PinguPanda | 0:0bec2b815282 | 39 | pc.scanf("%i", &wert); |
PinguPanda | 0:0bec2b815282 | 40 | } |
PinguPanda | 0:0bec2b815282 | 41 | } |
PinguPanda | 0:0bec2b815282 | 42 | } |