Timer#
The Timer attribute can also be called without Brain as its own Class.
time()#
The time(units) method returns the elapsed time.
Parameters |
Description |
|---|---|
|
A valid |
Returns: The elapsed time in the specified unit.
clear()#
The clear() method resets the timer value to 0.
Returns: None.
reset()#
The reset() method resets the timer value.
Returns: None.
system()#
The system() method returns the system time.
Returns: The system time in milliseconds.
systemHighRes()#
The systemHighRes() method returns the high-resolution system time.
Returns: The high-resolution system time in milliseconds.
event()#
The event(callback, delay) method registers a callback function for a timer event.
Parameters |
Description |
|---|---|
|
The callback function to be called when the event occurs. |
|
The delay before the callback function is called. |
Returns: None.
// Create a new function timerEvent().
void timerEvent() {
Brain.Screen.print("timer event");
}
int main() {
// Run timerEvent() after 100 milliseconds.
Brain.Timer.event(timerEvent, 100);
}