计时器#

The Timer attribute can also be called without Brain as its own Class.

时间()#

The time(units) method returns the elapsed time.

参数

描述

单位

A valid timeUnits type. The default is msec.

**返回:**以指定单位计算的经过时间。

清除()#

The clear() method resets the timer value to 0.

**返回:**无。

重置()#

The reset() method resets the timer value.

**返回:**无。

系统()#

The system() method returns the system time.

返回: 以毫秒为单位的系统时间。

事件()#

The event(callback, delay) method registers a callback function for a timer event.

参数

描述

打回来

事件发生时调用的回调函数。

延迟

回调函数被调用之前的延迟。

**返回:**无。

// 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);
}