Arnaud VALLEY / Mbed 2 deprecated Pinscape_Controller_V2_arnoz

Dependencies:   mbed FastIO FastPWM USBDevice

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;
 };