@@ -9,7 +9,11 @@ It is aimed at setting up regularly occurring tasks, timing out operations, and
What the tmr module is *not* however, is a time keeping module. While most timeouts are expressed in milliseconds or even microseconds, the accuracy is limited and compounding errors would lead to rather inaccurate time keeping. Consider using the [rtctime](rtctime.md) module for "wall clock" time.
NodeMCU provides 7 timers, numbered 0-6. It is currently up to the user to keep track of which timers are used for what.
NodeMCU provides 7 static timers, numbered 0-6, and dynamic timer creation function [`tmr.create()`](#tmrcreate).
!!! attention
Static timers are deprecated and will be removed later.
## tmr.alarm()
...
...
@@ -18,7 +22,7 @@ This is a convenience function combining [`tmr.register()`](#tmrregister) and [`
To free up the resources with this timer when done using it, call [`tmr.unregister()`](#tmrunregister) on it. For one-shot timers this is not necessary, unless they were stopped before they expired.
#### Parameters
-`id` timer id (0-6)
-`id`/`ref` timer id (0-6) or object
-`interval_ms` timer interval in milliseconds. Maximum value is 6870947 (1:54:30.947).
-`mode` timer mode:
-`tmr.ALARM_SINGLE` a one-shot alarm (and no need to call [`tmr.unregister()`](#tmrunregister))
...
...
@@ -33,10 +37,46 @@ To free up the resources with this timer when done using it, call [`tmr.unregist
Busyloops the processor for a specified number of microseconds.
...
...
@@ -64,10 +104,10 @@ tmr.delay(100)
Changes a registered timer's expiry interval.
#### Syntax
`tmr.interval(id, interval_ms)`
`tmr.interval(id/ref, interval_ms)`
#### Parameters
-`id` timer id (0-6)
-`id`/`ref` timer id (0-6) or object
-`interval_ms` new timer interval in milliseconds. Maximum value is 6870947 (1:54:30.947).
#### Returns
...
...
@@ -105,10 +145,10 @@ Configures a timer and registers the callback function to call on expiry.
To free up the resources with this timer when done using it, call [`tmr.unregister()`](#tmrunregister) on it. For one-shot timers this is not necessary, unless they were stopped before they expired.
#### Syntax
`tmr.register(id, interval_ms, mode, func)`
`tmr.register(id/ref, interval_ms, mode, func)`
#### Parameters
-`id` timer id (0-6)
-`id`/`ref` timer id (0-6) or object
-`interval_ms` timer interval in milliseconds. Maximum value is 6870947 (1:54:30.947).
-`mode` timer mode:
-`tmr.ALARM_SINGLE` a one-shot alarm (and no need to call [`tmr.unregister()`](#tmrunregister))