80 attach_arg(ms, repeat,
reinterpret_cast<TaskArgCallback>(callback),
nullptr);
93 attach_arg(ms, repeat,
reinterpret_cast<TaskArgCallback>(callback),
reinterpret_cast<volatile void *
>(arg));
101 esp_timer_stop(mpTimer);
102 esp_timer_delete(mpTimer);
114 return mpTimer !=
nullptr;
118 esp_timer_handle_t mpTimer;
128 void attach_arg(uint32_t ms,
bool repeat,
TaskArgCallback callback,
volatile void *arg) {
129 esp_timer_create_args_t timerConfig;
130 timerConfig.callback =
reinterpret_cast<esp_timer_cb_t
>(callback);
131 timerConfig.arg =
const_cast<void*
>(arg);
132 timerConfig.dispatch_method = ESP_TIMER_TASK;
133 timerConfig.name =
"Task";
136 esp_timer_stop(mpTimer);
137 esp_timer_delete(mpTimer);
140 esp_timer_create(&timerConfig, &mpTimer);
143 esp_timer_start_periodic(mpTimer, ms * 1000);
145 esp_timer_start_once(mpTimer, ms * 1000);
void(*)(volatile T) TaskTypeCallback
Templated callback function with typed argument.
Definition ESP32Task.h:57
void detach()
Stop and detach the timer.
Definition ESP32Task.h:99
virtual ~ESP32Task()
Destructor that ensures the timer is detached.
Definition ESP32Task.h:68
void attach(uint32_t ms, bool repeat, TaskCallback callback)
Attach a simple callback to run periodically.
Definition ESP32Task.h:79
void(*)(void) TaskCallback
Callback function with no arguments.
Definition ESP32Task.h:46
ESP32Task()
Constructor.
Definition ESP32Task.h:62
bool isAttached()
Check if the timer is attached.
Definition ESP32Task.h:113
void attach(uint32_t ms, bool repeat, TaskTypeCallback< volatile T > callback, volatile T arg)
Attach a typed callback with argument to run periodically.
Definition ESP32Task.h:92
void(*)(void *) TaskArgCallback
Callback function with void pointer argument.
Definition ESP32Task.h:51
Contains all classes and functions related to the Uniot Core.