Learning classes...

Dependencies:   C12832

Dependents:   PURS_ZI_001

Revision:
0:2fab4c84205a
Child:
1:4be9b47b9af5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Stoperica.cpp	Wed Feb 03 15:29:46 2016 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+#include "C12832.h"
+#include "Stoperica.h"
+
+Stoperica::Stoperica(PinName startPin, PinName stopPin) : start(startPin), stop(stopPin), lcd(p5, p7, p6, p8, p11) {
+    start.rise(this, &Stoperica::startPressed);
+    stop.rise(this, &Stoperica::stopPressed);
+    debounceStart.start();
+    debounceStop.start();
+    lcd.cls();
+    lcd.locate(0,3);
+    lcd.printf("PURS_ZI_001\nPress start/stop button");
+}
+
+void Stoperica::startPressed() {
+    if(debounceStart.read_ms() > 5) {
+        passedTime.start();
+        debounceStart.reset();
+        lcd.cls();
+        lcd.locate(0,3);
+        lcd.printf("Measurement in progress");
+    }
+}
+
+void Stoperica::stopPressed() {
+    if(debounceStop.read_ms() > 5) {
+        passedTime.stop();
+        debounceStart.reset();
+        lcd.cls();
+        lcd.locate(0,3);
+        lcd.printf("Passed time: %g", passedTime.read());
+        passedTime.reset();
+    }
+}
\ No newline at end of file