Timer for accumulating 10 ms intervals that does not overflow after ~30 min
This class simply creates a timer that accumulates 10 millisecond intervals which does not overflow after about 30 min.
Diff: RunTimer.h
- Revision:
- 0:21dc6ad1a795
- Child:
- 2:67e16d628edc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RunTimer.h Thu May 19 13:37:02 2016 +0000 @@ -0,0 +1,43 @@ +/** RunTimer class. + * J. Bradshaw 20160519 + * library for building a 10 millisecond running timer + * + * Example: + * @code + * #include "mbed.h" + * #include "RunTimer.h" + * + * Serial pc(USBTX,USBRX); + * RunTimer runTime; + * + * int main() { + * while(1){ + * pc.printf("Time=day=%02d hour=%02d min=%02d sec=%02d ms=%02d \r\n", runTime.day,runTime.hour,runTime.min,runTime.sec,runTime.ms) + * wait(.02); + * } + * } + * @endcode + */ +#ifndef MBED_RUNTIMER_H +#define MBED_RUNTIMER_H + +#include "mbed.h" + +class RunTimer{ + +public: + RunTimer(); + + void timeAcc(void); + void Reset(void); + + Ticker timer_10ms; //Ticker for adding 10ms + + unsigned int ms; + unsigned int sec; + unsigned int min; + unsigned int hour; + unsigned int days; +}; + +#endif \ No newline at end of file