Time (seconds) counter based on TimerSubscriber
Revision 1:49c28e93d358, committed 2014-06-06
- Comitter:
- Waldek
- Date:
- Fri Jun 06 09:04:55 2014 +0000
- Parent:
- 0:b72c7c2ee5f3
- Commit message:
- Time dependent on TimerSubscriber
Changed in this revision
TimeCounter.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r b72c7c2ee5f3 -r 49c28e93d358 TimeCounter.h --- a/TimeCounter.h Wed Jun 04 22:36:51 2014 +0000 +++ b/TimeCounter.h Fri Jun 06 09:04:55 2014 +0000 @@ -6,11 +6,21 @@ (c) W.D. 2014 +Usage example + +#include "TimeCounter.h" + +TimerSubscriber timer_user(10, 1000); // 10 in table, 1ms period +TimeCounter time_counter; + +main() +{ + long int Second = time_counter.ReadSeconds(); +} -------------------------------------------------------------*/ /* ------ sample usage------ */ -#define SAMPLES_TO_DEBOUNCE 64 extern TimerSubscriber timer_user; @@ -19,9 +29,9 @@ public: TimeCounter(); virtual ~TimeCounter(); - inline long int ReadSeconds(void){return ticks / TicksPerSecond;}; + inline long int ReadSeconds(void){return this->ticks / this->TicksPerSecond;}; inline long int ReadTicks(void){return ticks;}; - inline void SetSeconds(long int InSeconds){this->ticks = InSeconds * TicksPerSecond;}; + inline void SetSeconds(long int InSeconds){this->ticks = InSeconds * this->TicksPerSecond;}; virtual void TimerEvent(void); private: long long int ticks;