Difference between revisions of "Timer Functions"
m |
m (Protected "Timer Functions" ([edit=sysop] (expires 20:42, 10 June 2011 (UTC)) [move=sysop] (expires 20:42, 10 June 2011 (UTC)))) |
(No difference)
|
Revision as of 20:42, 10 May 2011
Timers may become inaccurate at higher resolutions due to overhead. The code to actually control the timers is fairly accurate, however, the macro may not be able to process data fast enough to keep up with the timers. This should not be an issue unless you are going into nanosecond timers.
Note:
The MicroMacro library also provides "simple", automatic timers. These will save you some time and learning. It is highly recommended to use automatic timers instead. Automatic timer functions are provided in the Library.
Contents
newTimer
newTimer(name)
Creates a new timer with the given name.
Example
newTimer("my_timer");
removeTimer
removeTimer(name)
Removes a timer with the given name, freeing it's used resources.
Example
removeTimer("my_timer");
startTimer
startTimer(name, time)
Starts or restarts a timer with the given name, with a given time value in miliseconds (1/1000th of a second).
Example
startTimer( "my_timer", 1000 );
isTriggered
bool isTriggered(name)
Returns if a timer has been triggered or not. Returns true if it has, false otherwise.
Remember to (re)start timers after they have been triggered.
Example
if( isTriggered("my_timer") ) then
do_something();
startTimer("my_timer", 1000);
end