Timer driver

Timer type

A timer has 3 states: stopped, running, and ringing. When running, a timer counts down to 0, at which point it goes to the ringing state and fires an event.

Properties

state
The current state of the timer.
Possible values: stopped, running, ringing.
expire
The last time the timer expired.
Format: DDD HH:MM:SS.
remain
This property is intended for showing the remaining time in the explorer. It is not very useful for actions.
The interpretation of this property depends on the current state of the timer:
  • Running - The time the timer will expire, unless intervened with, in ms after the epoch (Jan 1, 1970 00:00:00 UTC).
  • Stopped, Ringing - The remaining time in ms (which will be 0 in the ringing state).

Wide (64-bits).

Events

state
Fires whenever the timer state changes.
expire
Fires when the timer expires (transitions from "running" to "ringing").
remain
Never fires.

Commands

start value
Load the timer with the specified value and start it running. This changes the state of the timer to "running".
resume
Restart the timer with its previous value as the starting value. This changes the state of the timer to "running".
stop
Halt the timer. If the timer was in "running" state, it will change to the "stopped" state.
clear
Reset the timer. This clears the remaining time of the timer and set its state to "stopped".

Functions

remain
The remaining time in milliseconds before the device reaches 0.