100 static_assert(
sizeof(
volatile T) <=
sizeof(uint32_t),
"sizeof arg must be <= sizeof(uint32_t), i.e 4 bytes");
101 attach_arg(ms, repeat,
reinterpret_cast<TaskArgCallback>(callback),
reinterpret_cast<volatile void *
>(arg));
109 os_timer_disarm(mpTimer);
122 return mpTimer !=
nullptr;
136 void attach_arg(uint32_t ms,
bool repeat,
TaskArgCallback callback,
volatile void *arg) {
138 os_timer_disarm(mpTimer);
143 os_timer_setfn(mpTimer,
reinterpret_cast<ETSTimerFunc *
>(callback),
const_cast<void*
>(arg));
144 os_timer_arm(mpTimer, ms, repeat);
ESP8266Task()
Constructor.
Definition ESP8266Task.h:69
virtual ~ESP8266Task()
Destructor that ensures the timer is detached.
Definition ESP8266Task.h:75
void attach(uint32_t ms, bool repeat, TaskTypeCallback< volatile T > callback, volatile T arg)
Attach a typed callback with argument to run periodically.
Definition ESP8266Task.h:99
void(*)(void *) TaskArgCallback
Callback function with void pointer argument.
Definition ESP8266Task.h:58
void attach(uint32_t ms, bool repeat, TaskCallback callback)
Attach a simple callback to run periodically.
Definition ESP8266Task.h:86
void detach()
Stop and detach the timer.
Definition ESP8266Task.h:107
void(*)(volatile T) TaskTypeCallback
Templated callback function with typed argument.
Definition ESP8266Task.h:64
void(*)(void) TaskCallback
Callback function with no arguments.
Definition ESP8266Task.h:53
bool isAttached()
Check if the timer is attached.
Definition ESP8266Task.h:121
Contains all classes and functions related to the Uniot Core.
struct _ETSTIMER_ ETSTimer
Definition ESP8266Task.h:35