-
-
Notifications
You must be signed in to change notification settings - Fork 56
Closed
Description
If I want to create several global timers but not have all of them running, how would one do that? E.g,
static bool heartbeatTimerCallback (void *argument __attribute__ ((unused)));
static bool sixHourTimerCallback (void *argument __attribute__ ((unused)));
static bool motionTimerCallback (void *argument __attribute__ ((unused)));
static auto timer = timer_create_default ();
static auto heartbeatTimer = timer.every (HEARTBEAT_TIMEBASE, heartbeatTimerCallback);
static auto sixHourTimer = timer.in (0, sixHourTimerCallback);
static auto motionTimer = timer.in (0, motionTimerCallback);
You can't actually create a timer with an expiration of 0 milliseconds, so what I've done is set it for a ridiculous amount of time, then cancel it in the setup() function. The heartbeatTimer is one I do want running when I create it.
Disclaimer: Not a C++ guy, but been writing C for 40 years.
Metadata
Metadata
Assignees
Labels
No labels