Submitted by Webbot on January 1, 2009 - 11:00pm.
The library uses Timer2 for all timings.
TIMER::get() returns a reference to the timer. As this is a reference then all other routines should be accessed via the '->' operator. ie TIMER::get()->MsCur();
unsigned long MsCur(); returns the number of milliseconds since
power was switched on. Since an unsigned long can store a high value
then it provides an effective 'time of day' clock. NB If your robot can
be left switched on for a long period then you will have to take into
account that this value may wrap around to 0.
bool HasElapsed(unsigned long msStart, unsigned in msWait); This
will test if a given amount of time has passed. 'msStart' is a value
you saved previously by calling MsCur() and 'msWait' is the number of
milliseconds you want to check to see if they have passed. The method
will return immediately with either 'false' if the period hasn't
elapsed or 'true' if it has. This is useful with sensors such as sonars
which should not be called without a reasonable delay between samplings
so as to avoid ghost echoes. You can guard against this by saving the
time when the sonar was last sampled. The next time it is called you
can check that the minimum amount of time has elapsed since the last
call and, if not, you could return the previously returned value.
void WaitMs(unsigned int ms); This will not return until the given
number of milliseconds has elapsed. Note that this may be out by 1ms
either way so it's not good for small numbers.
void WaitMs(unsigned int ms, unsigned long msStart); is similar to
'HasElapsed' except that it will not return until the given period has
elapsed.