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 |
|---|---|
|
Optional. 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.
system_high_res()#
The system_high_res() method returns the high-resolution system time.
Returns: The high-resolution system time in milliseconds.
event()#
The event(callback, delay, arg) 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. |
|
Optional. The arguments to pass to the callback function. |
Returns: None.
// Create a new function timer_event().
void timer_event() {
Brain.Screen.print("timer event");
}
int main() {
// Run timer_event() after 100 milliseconds.
Brain.Timer.event(timer_event, 100);
}