计时器#
timer.time()#
The timer.time()
command returns the elapsed time.
这是一个非等待命令,允许下一个命令无延迟运行。
参数 |
描述 |
---|---|
单位 |
Optional. A valid TimeUnit. The default is |
**返回:**指定单位的经过时间。
计时器.清除()#
The timer.clear()
command resets the timer value to 0.
这是一个非等待命令,允许下一个命令无延迟运行。
**返回:**无。
计时器.重置()#
The timer.reset()
command resets the timer value.
这是一个非等待命令,允许下一个命令无延迟运行。
**返回:**无。
计时器.系统()#
The timer.system()
command returns the system time.
这是一个非等待命令,允许下一个命令无延迟运行。
返回: 以毫秒为单位的系统时间。
timer.system_high_res()#
The timer.system_high_res()
command returns the high-resolution system time.
这是一个非等待命令,允许下一个命令无延迟运行。
**返回:**以毫秒为单位的高分辨率系统时间。
# Get the high resolution system time in microseconds
high_res_system_time = timer_1.system_high_res()
计时器.事件()#
The timer.event()
command registers a callback function for a timer event.
这是一个非等待命令,允许下一个命令无延迟运行。
参数 |
描述 |
---|---|
打回来 |
事件发生时调用的回调函数。 |
延迟 |
回调函数被调用之前的延迟。 |
arg |
**可选。**传递给回调函数的参数。 |
**返回:**无。
# Define a function timer_event
def timer_event():
# The brain will print that timer has expired on the brain screen.
brain.screen.print('timer has expired ')
# Initialize a Timer object.
t1 = Timer()
# Run timer_event after 1000 milliseconds of delay.
t1.event(timer_event, 1000)
计时器.值()#
The timer.value()
command returns the current time in seconds.
这是一个非等待命令,允许下一个命令无延迟运行。
**返回:**当前时间(以秒为单位)。