Timer for accumulating 10 ms intervals that does not overflow after ~30 min
Embed:
(wiki syntax)
Show/hide line numbers
RunTimer.h
00001 /** RunTimer class. 00002 * J. Bradshaw 20160519 00003 * library for building a 10 millisecond running timer 00004 * 00005 * Example: 00006 * @code 00007 * #include "mbed.h" 00008 * #include "RunTimer.h" 00009 * 00010 * Serial pc(USBTX,USBRX); 00011 * RunTimer runTime; 00012 * 00013 * int main() { 00014 * while(1){ 00015 * 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) 00016 * wait(.02); 00017 * } 00018 * } 00019 * @endcode 00020 */ 00021 #ifndef MBED_RUNTIMER_H 00022 #define MBED_RUNTIMER_H 00023 00024 #include "mbed.h" 00025 00026 class RunTimer{ 00027 00028 public: 00029 RunTimer(); 00030 00031 void timeAcc(void); 00032 void Reset(void); 00033 00034 Ticker timer_10ms; //Ticker for adding 10ms 00035 00036 float ms_total; 00037 unsigned int ms; 00038 unsigned int sec; 00039 unsigned int min; 00040 unsigned int hour; 00041 unsigned int day; 00042 }; 00043 00044 #endif
Generated on Sat Jul 16 2022 08:37:27 by 1.7.2