Skip to content

Commit

Permalink
Berry fast_loop every 5ms
Browse files Browse the repository at this point in the history
  • Loading branch information
s-hadinger authored Sep 2, 2023
1 parent 9338499 commit 7b8fb00
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/Berry.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,17 @@ tasmota.add_driver(d1)

## Fast Loop

Beyond the events above, a specific mechanism is available for near-real-time events or fast loops (above 50 times per second).
Beyond the events above, a specific mechanism is available for near-real-time events or fast loops (200 times per second, or 5ms).

Special attention is made so that there is no or very little impact on performance. Until a first callback is registered, performance is not impacted and Berry is not called. This protects any current use from any performance impact.

Once a callback is registered, it is called separately from Berry drivers to ensure minimal overhead.

`tasmota.add_fast_loop(cl:function) -> nil` registers a callback to be called in fast loop mode.

The callback is called without any parameter and does not need to return anything. The callback is called at each iteration of Tasmota event loop. The frequency is tightly linked to the `Speed <x>` command. By default, the sleep period is 50ms, hence fast_loop is called every 50ms. You can reduce the time with `Sleep 10` (10ms) hence calling 100 times per second. If you set `Sleep 0`, the callback is called as frequently as possible (discouraged unless you have a good reason).
The callback is called without any parameter and does not need to return anything. The callback is called at each iteration of Tasmota event loop. The frequency is set to 200Hz or 5ms.

Note: since v13.1.0.2, the frequency of `fast_loop` does not depend anymore on the value of the `Sleep <x>` command.

`tasmota.remove_fast_loop(cl:function) -> nil` removes a previously registered function or closure. You need to pass the exact same closure reference.

Expand Down

0 comments on commit 7b8fb00

Please sign in to comment.