Learning classes...

Dependencies:   C12832

Dependents:   PURS_ZI_002

Committer:
tbjazic
Date:
Tue Feb 09 12:07:55 2016 +0000
Revision:
1:315ad27c0acb
Parent:
0:5f60bb287bd0
debounce stop tipkala popravljen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tbjazic 0:5f60bb287bd0 1 #include "mbed.h"
tbjazic 0:5f60bb287bd0 2 #include "C12832.h"
tbjazic 0:5f60bb287bd0 3 #include "Stoperica.h"
tbjazic 0:5f60bb287bd0 4
tbjazic 0:5f60bb287bd0 5 Stoperica::Stoperica(PinName startPausePin, PinName stopPin) : startPause(startPausePin), stop(stopPin), lcd(p5, p7, p6, p8, p11) {
tbjazic 0:5f60bb287bd0 6 isMeasurementStarted = false;
tbjazic 0:5f60bb287bd0 7 startPause.rise(this, &Stoperica::startPausePressed);
tbjazic 0:5f60bb287bd0 8 stop.rise(this, &Stoperica::stopPressed);
tbjazic 0:5f60bb287bd0 9 debounceStartPause.start();
tbjazic 0:5f60bb287bd0 10 debounceStop.start();
tbjazic 0:5f60bb287bd0 11 lcd.cls();
tbjazic 0:5f60bb287bd0 12 lcd.locate(0,3);
tbjazic 0:5f60bb287bd0 13 lcd.printf("PURS_ZI_002\nStart measurement");
tbjazic 0:5f60bb287bd0 14 }
tbjazic 0:5f60bb287bd0 15
tbjazic 0:5f60bb287bd0 16 void Stoperica::startPausePressed() {
tbjazic 0:5f60bb287bd0 17 if(debounceStartPause.read_ms() > 5) {
tbjazic 0:5f60bb287bd0 18 if (!isMeasurementStarted) {
tbjazic 0:5f60bb287bd0 19 passedTime.start();
tbjazic 0:5f60bb287bd0 20 isMeasurementStarted = true;
tbjazic 0:5f60bb287bd0 21 } else {
tbjazic 0:5f60bb287bd0 22 passedTime.stop();
tbjazic 0:5f60bb287bd0 23 isMeasurementStarted = false;
tbjazic 0:5f60bb287bd0 24 }
tbjazic 0:5f60bb287bd0 25 debounceStartPause.reset();
tbjazic 0:5f60bb287bd0 26 lcd.cls();
tbjazic 0:5f60bb287bd0 27 lcd.locate(0,3);
tbjazic 0:5f60bb287bd0 28 lcd.printf("Passed time: %g", passedTime.read());
tbjazic 0:5f60bb287bd0 29 }
tbjazic 0:5f60bb287bd0 30 }
tbjazic 0:5f60bb287bd0 31
tbjazic 0:5f60bb287bd0 32 void Stoperica::stopPressed() {
tbjazic 0:5f60bb287bd0 33 if(debounceStop.read_ms() > 5) {
tbjazic 0:5f60bb287bd0 34 passedTime.stop();
tbjazic 0:5f60bb287bd0 35 passedTime.reset();
tbjazic 1:315ad27c0acb 36 debounceStop.reset();
tbjazic 0:5f60bb287bd0 37 lcd.cls();
tbjazic 0:5f60bb287bd0 38 lcd.locate(0,3);
tbjazic 0:5f60bb287bd0 39 lcd.printf("PURS_ZI_002\nStart measurement");
tbjazic 0:5f60bb287bd0 40 }
tbjazic 0:5f60bb287bd0 41 }