Learning classes...
Dependencies: C12832
Stoperica.cpp
00001 #include "mbed.h" 00002 #include "C12832.h" 00003 #include "Stoperica.h" 00004 00005 Stoperica::Stoperica(PinName startPausePin, PinName stopPin) : startPause(startPausePin), stop(stopPin), lcd(p5, p7, p6, p8, p11) { 00006 isMeasurementStarted = false; 00007 startPause.rise(this, &Stoperica::startPausePressed); 00008 stop.rise(this, &Stoperica::stopPressed); 00009 debounceStartPause.start(); 00010 debounceStop.start(); 00011 lcd.cls(); 00012 lcd.locate(0,3); 00013 lcd.printf("PURS_ZI_002\nStart measurement"); 00014 } 00015 00016 void Stoperica::startPausePressed() { 00017 if(debounceStartPause.read_ms() > 5) { 00018 if (!isMeasurementStarted) { 00019 passedTime.start(); 00020 isMeasurementStarted = true; 00021 } else { 00022 passedTime.stop(); 00023 isMeasurementStarted = false; 00024 } 00025 debounceStartPause.reset(); 00026 lcd.cls(); 00027 lcd.locate(0,3); 00028 lcd.printf("Passed time: %g", passedTime.read()); 00029 } 00030 } 00031 00032 void Stoperica::stopPressed() { 00033 if(debounceStop.read_ms() > 5) { 00034 passedTime.stop(); 00035 passedTime.reset(); 00036 debounceStop.reset(); 00037 lcd.cls(); 00038 lcd.locate(0,3); 00039 lcd.printf("PURS_ZI_002\nStart measurement"); 00040 } 00041 }
Generated on Thu Jul 14 2022 22:49:43 by 1.7.2