Timer Functions

From SolarStrike wiki
Revision as of 09:18, 15 July 2008 by Elverion (talk | contribs)
Jump to: navigation, search

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.


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