Learning classes...
Dependencies: C12832
Diff: Stoperica.cpp
- Revision:
- 0:5f60bb287bd0
- Child:
- 1:315ad27c0acb
diff -r 000000000000 -r 5f60bb287bd0 Stoperica.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Stoperica.cpp Wed Feb 03 15:32:23 2016 +0000 @@ -0,0 +1,41 @@ +#include "mbed.h" +#include "C12832.h" +#include "Stoperica.h" + +Stoperica::Stoperica(PinName startPausePin, PinName stopPin) : startPause(startPausePin), stop(stopPin), lcd(p5, p7, p6, p8, p11) { + isMeasurementStarted = false; + startPause.rise(this, &Stoperica::startPausePressed); + stop.rise(this, &Stoperica::stopPressed); + debounceStartPause.start(); + debounceStop.start(); + lcd.cls(); + lcd.locate(0,3); + lcd.printf("PURS_ZI_002\nStart measurement"); +} + +void Stoperica::startPausePressed() { + if(debounceStartPause.read_ms() > 5) { + if (!isMeasurementStarted) { + passedTime.start(); + isMeasurementStarted = true; + } else { + passedTime.stop(); + isMeasurementStarted = false; + } + debounceStartPause.reset(); + lcd.cls(); + lcd.locate(0,3); + lcd.printf("Passed time: %g", passedTime.read()); + } +} + +void Stoperica::stopPressed() { + if(debounceStop.read_ms() > 5) { + passedTime.stop(); + passedTime.reset(); + debounceStartPause.reset(); + lcd.cls(); + lcd.locate(0,3); + lcd.printf("PURS_ZI_002\nStart measurement"); + } +} \ No newline at end of file