计时器#
The Timer
attribute can also be called without Brain
as its own Class.
时间()#
The time(units)
method returns the elapsed time.
参数 |
描述 |
---|---|
单位 |
Optional. A valid TimeUnits type. The default is |
**返回:**指定单位的经过时间。
清除()#
The clear()
method resets the timer value to 0.
**返回:**无。
重置()#
The reset()
method resets the timer value.
**返回:**无。
系统()#
The system()
method returns the system time.
返回: 以毫秒为单位的系统时间。
系统高分辨率()#
The system_high_res()
method returns the high-resolution system time.
**返回:**以毫秒为单位的高分辨率系统时间。
事件()#
The event(callback, delay, arg)
method registers a callback function for a timer event.
参数 |
描述 |
---|---|
打回来 |
事件发生时调用的回调函数。 |
延迟 |
回调函数被调用之前的延迟。 |
arg |
**可选。**传递给回调函数的参数。 |
**返回:**无。
// 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);
}