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.
RunTimer.cpp
- Committer:
- jebradshaw
- Date:
- 2016-05-19
- Revision:
- 1:134292d456c9
- Parent:
- 0:21dc6ad1a795
- Child:
- 2:67e16d628edc
File content as of revision 1:134292d456c9:
#include "RunTimer.h" RunTimer::RunTimer(){ this->ms=0; this->sec =0; this->min = 0; this->hour = 0; this->days = 0; this->timer_10ms.attach(this, &RunTimer::timeAcc, .01); } void RunTimer::timeAcc(void){ this->ms +=10; if(this->ms == 1000){ this->ms = 0; this->sec++; if(this->sec==60){ this->sec=0; this->min++; if(this->min == 60){ this->min=0; this->hour++; if(this->hour==24){ this->hour=0; days++; } } } } }//timeAcc void RunTimer::Reset(void){ this->ms=0; this->sec =0; this->min = 0; this->hour = 0; this->days = 0; }