ESP-LiveControl
1.99.1
HTTP server, AJAX API backend and Vue.js web application implementing self-contained, zero-install WiFi remote control of hardware modules attached to the Espressif ESP32 SoC
|
Ticker timer derivative allowing for a fixed number of repeated calls. More...
#include <multi_timer.hpp>
Classes | |
struct | type_identity |
Public Types | |
template<class T > | |
using | type_identity_t = typename type_identity< T >::type |
using | callback_with_arg_and_count_t = void(*)(void *, uint32_t) |
Public Member Functions | |
template<typename TArg > | |
esp_err_t | attach_static_ms (uint32_t milliseconds, uint32_t total_repeat_count, void(*callback)(type_identity_t< TArg >, uint32_t), TArg arg, bool first_tick_nodelay=false) |
Attach a free function, static member function or a non-capturing lambda function to the timer. More... | |
template<typename TArg > | |
esp_err_t | attach_static_ms (uint32_t milliseconds, uint32_t total_repeat_count, void(*callback)(type_identity_t< TArg >), TArg arg, bool first_tick_nodelay=false) |
esp_err_t | attach_static_ms (uint32_t milliseconds, uint32_t total_repeat_count, callback_t callback, bool first_tick_nodelay=false) |
void | start () |
void | start (uint32_t interval_ms) |
void | stop () |
esp_err_t | stop_return_errors () |
void | pause () |
esp_err_t | pause_return_errors () |
void | resume () |
esp_err_t | resume_return_errors () |
Protected Member Functions | |
esp_err_t | _attach_ms (uint32_t arg) |
void | _mutex_take () |
void | _mutex_give () |
Ticker timer derivative allowing for a fixed number of repeated calls.
This also allows unlimited on-demand restarting of the already attached callback without deleting the existing timer first.
Like for the original Ticker.h version, all callbacks are invoked from "esp_timer" task, which is a high-priority task. For this reason, the callbacks should only perform a minimum amount of work and refer to other tasks via message passing to do any blocking action.
|
inline |
Attach a free function, static member function or a non-capturing lambda function to the timer.
This timer is created without activating it.
The callback can receive zero, one or two arguments:
The macros TICKER_MEMBER_CALL() and TICKER_MEMBER_CALL_WITH_COUNT() are a short-cut for calling non-static member functions from a calling class object by inserting a lambda in place of the member function name:
==> Please note: This software timer is only relatively accurate. That menas, for each repeat, the timer is stopped and started again immediately if the total number of repeats is not yet reached. This means that for multiple repeats, each small timing error will sum up to a larger value. If you need accurate timing for a large (or infinite) number of repeats, please use the Ticker class which features the periodic attach_ms() which has better long-term accuracy.
milliseconds | Timer interval in milliseconds |
total_repeat_count | Timer is stopped after this many repeats |
callback | Callback function to register into this timer |
arg | Numeric arg or pointer to object, e.g. calling class instance |
first_tick_nodelay | If set to true, call callback immediately when the start() function is invoked, the first tick counts as a normal repeat and is repeated until total repeat count is reached |
|
inline |
Without return value, we don't get this out of the lambda without another class member..