Jovica D.
/
FeuerwehrStoppuhr0805
stoppuhr s
Fork of FeuerwehrStoppuhr by
Diff: main.cpp
- Revision:
- 3:6f6ee868bf8c
- Parent:
- 2:9c7ca5717309
diff -r 9c7ca5717309 -r 6f6ee868bf8c main.cpp --- a/main.cpp Fri Apr 26 09:10:33 2013 +0000 +++ b/main.cpp Wed May 08 13:59:35 2013 +0000 @@ -2,23 +2,17 @@ #include "PinDetect.h" #include "stdlib.h" #include "TextLCD.h" -// must import Cookbook PinDetct library into project -// URL: http://mbed.org/users/AjK/libraries/PinDetect/lkyxpw -//TST was here + DigitalOut myled(LED1); Timer t; -TextLCD lcd(p36, p34, p9, p10, p15, p16); // rs, e, d0-d3 +TextLCD lcd(p36, p34, p24, p23, p15, p16); // rs, e, d0-d3 PinDetect pb1(p18); PinDetect pb2(p19); Serial pc(USBTX, USBRX); - -// SPST Pushbutton debounced count demo using interrupts and callback -// no external PullUp resistor needed -// Pushbutton from P8 to GND. -// Second Pushbutton from P7 to GND. -// A pb hit generates an interrupt and activates the callback function -// after the switch is debounced +Serial hm(p9, p10); // definiere UART für HM-TPR433 Modul +DigitalOut config(p22); +DigitalOut enable(p21); // Global count variable int volatile count=0; @@ -28,6 +22,7 @@ int volatile sblock=0; int volatile reset=0; int volatile D=0; +//int volatile send=0; int ms; int sec; int min; @@ -37,6 +32,36 @@ char zwischenzeit1[9]; /*Funktions Dekleration*/ + +void empfangen() { + // Note: you need to actually read from the serial to clear the RX interrupt + + // send = 1; + t.stop(); + if(sblock==1) + { + lcd.cls(); + lcd.printf("RESET: START LANGE DRUEKEN!"); + wait(1); + } + pc.printf("Gesamtzeit: %s\n", buffer); + pc.printf("Zwischenzeit: %s\n", zwischenzeit); + pc.printf("Zwischenzeit: %s\n", zwischenzeit1); + sblock=1; + lcd.printf("%c\n", hm.getc()); + return; +} + +void konfiguration(void) +{ + config = 0; + enable = 0; + hm.printf("AA FA F0"); + wait(0.1); + config = 1; + return; +} + void stoppuhr(void) { ms = t.read_ms(); //hole mir den TimerWert in ms @@ -51,8 +76,7 @@ } void reset_halten( void ) -{ - +{ if(sblock==1) { t.stop(); @@ -111,7 +135,7 @@ } resetcnt=resetcnt++; } - +/* // Callback routine is interrupt activated by a debounced pb2 hit void pb2_hit_callback (void) { t.stop(); @@ -127,20 +151,28 @@ pc.printf("Zwischenzeit: %s\n", zwischenzeit1); sblock=1; } +*/ int main() { - + + konfiguration(); + hm.attach(&empfangen); + // Setup Interrupt callback functions for a pb hit pb1.attach_deasserted(&pb1_hit_callback); pb1.attach_deasserted_held(&reset_halten); - pb2.attach_deasserted(&pb2_hit_callback); + // pb2.attach_deasserted(&pb2_hit_callback); // Start sampling pb inputs using interrupts pb1.setSampleFrequency(); - pb2.setSampleFrequency(); - + // pb2.setSampleFrequency(); + + while (1) { wait(.1); lcd.cls(); + // if(send=1){ + + //} myled = !myled; // LED1 blickt stoppuhr(); //rufe Funktion stoppuhr auf lcd.locate(0, 0); //setze den curser auf Zeihen 0 Reihe 1 @@ -157,8 +189,7 @@ lcd.locate(8, 1); lcd.printf("B%s", zwischenzeit1); } - // wait(.1); - // lcd.cls(); + } }