Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed FastIO FastPWM USBDevice
Diff: potSensor.h
- Revision:
- 53:9b2611964afc
- Parent:
- 52:8298b2a73eb2
--- a/potSensor.h Sat Mar 05 00:16:52 2016 +0000
+++ b/potSensor.h Fri Apr 22 17:58:35 2016 +0000
@@ -21,6 +21,8 @@
{
// start our sample timer with an arbitrary zero point of now
timer.start();
+ totScanTime = 0;
+ nScans = 0;
}
virtual void init()
@@ -73,7 +75,10 @@
}
// figure the average scan time in microseconds
- virtual uint32_t getAvgScanTime() { return uint32_t(totScanTime/nScans); }
+ virtual uint32_t getAvgScanTime()
+ {
+ return nScans != 0 ? uint32_t(totScanTime/nScans) : 0;
+ }
private:
// analog input for the pot wiper
@@ -83,6 +88,6 @@
Timer timer;
// total sensor scan time in microseconds, and number of scans completed
- long long totScanTime;
+ uint64_t totScanTime;
int nScans;
};