-
Notifications
You must be signed in to change notification settings - Fork 0
DS_CAP_TIMERS
This capability add support for timers, used to execute certain actions in future. The way to define future event is determined by timer type. Grossly, there are two ways of designating future time: absolute (when system has notion of system time and can be programmed for a future timestamp) and relative (when system does not have notion of time but can be programmed for some time in future using some time counting technique relative to the original time point). The library supports several timer types:
- Absolute timer — fires at a given time in future
- Solar timer — fires at sun-related event (sunrise or sunset)
- Countdown timer (absolute) — fires after some time period from now (implemented via absolute time)
-
Countdown timer (ticker) — fires after some time period from now (implemented via
Ticker
function)
Timer actions are specified using a string called "action". When timer event fires, the library calls a user-defined callback function, which can check the timer "action" property in order to decide which code to execute.
This capability defines an abstract timer interface (ds::Timer
class); in order to actually use a timer, user has to select one of the four timer implementations listed above. ds::Timer
class has the following fields implemented:
Field | Type | Description | Default Value |
---|---|---|---|
id |
int |
Timer identifier (optional) | -1 |
type |
ds::timer_type_t |
Timer type | (none) |
action |
String |
Timer action | "undefined" |
armed |
bool |
True if timer is armed (will fire); false if ignored with no action | true |
recurrent |
bool |
True if timer should be auto-rearmed after firing; false otherwise | true |
transient |
bool |
True if timer should be disposed of after firing | false |
Marking timer as transient will render it unusable (destroy) after firing once. This normally only has meaning in the context of collection of timers, in which case the timer will be deleted from collection.
None.
None.
None.
None. See the corresponding timer implementations.
System::begin() |
Not required |
System::update() |
Not required |
Note that while this capability per se does not these calls, the underlying implementations, like absolute timer, would most likely need them to work correctly. Check their respective pages for details.
None.
- DS_CAP_APP_ID
- DS_CAP_APP_LOG
- DS_CAP_BUTTON
- DS_CAP_MDNS
- DS_CAP_SYS_FS
- DS_CAP_SYS_LED
- DS_CAP_SYS_LOG
- DS_CAP_SYS_LOG_HW
- DS_CAP_SYS_NETWORK
- DS_CAP_SYS_RESET
- DS_CAP_SYS_RTCMEM
- DS_CAP_SYS_TIME
- DS_CAP_SYS_UPTIME
- DS_CAP_TIMERS
- DS_CAP_TIMERS_ABS
- DS_CAP_TIMERS_COUNT_ABS
- DS_CAP_TIMERS_COUNT_TICK
- DS_CAP_TIMERS_SOLAR
- DS_CAP_WEB_TIMERS
- DS_CAP_WEBSERVER
- DS_CAP_WIFIMANAGER