Library for a timer that can go for days (but only ms resolution)

Dependents:   ExtendedTimer_Example FindingTemp Final_NSR NearSpaceOzoneSensor ... more

Revision:
0:7a6067de3bff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ExtendedTimer.h	Thu Mar 09 23:05:17 2017 +0000
@@ -0,0 +1,54 @@
+#ifndef EXTENDED_TIMER_H
+#define EXTENDED_TIMER_H
+
+#include "mbed.h"
+
+/** A timer appropriate for intervals up to about 20 days
+ *
+ *  @author John M. Larkin (jlarkin@whitworth.edu)
+ *  @version 0.1
+ *  @date 2017
+ *  @copyright GNU Public License
+ */
+
+class ExtendedTimer {
+
+public:
+    ExtendedTimer();
+    
+    /** Start the timer        
+    */
+    void start();
+    
+    /** Stop the timer
+    */
+    void stop();
+    
+    /** Reset the timer to 0
+    *
+    *  If it was already counting, it will continue
+    */
+    void reset();
+
+    /** Get the time passed in milliseconds
+    */
+    int read_ms();
+    
+    /** Get the time passed in seconds
+    */
+    float read();
+    
+    /** An operator shorthand for read()
+    */
+    operator float();
+    
+
+    
+protected:
+    int _running; // whether the timer is running
+    unsigned int _time; // any accumulated time from previous slices
+    Timer usTimer;
+    Ticker usTimerWatch;
+    void usTimerReset();
+};
+#endif
\ No newline at end of file