Skip to content
Michael Miller edited this page Jun 11, 2016 · 2 revisions

The TaskManager will manage the running tasks and allow you to start and stop tasks as you need.

Methods

void Setup()

This will initialize the TaskManager and prepare it for use. Call this first within Setup().

void Loop(uint16_t watchdogTimeOutFlag = WDTO_500MS)

This will allow the taskmanager to schedule tasks for work and call them to do work. This should be called in the loop() of the sketch and often should now be the only thing called in it.

void StartTask(Task* pTask)

This will start given task. The tasks OnStart() method will be called. After this the OnUpdate() will periodically be called.

void StopTask(Task* pTask)

This will stop the given task. The tasks OnStop() method will be called. After this the OnUpdate() will no longer be called.

void ResetTask(Task* pTask)

This will stop the given task and then restart it. This is an easy way to keep an "idle" timer running.

(AVR) void EnterSleep(uint8_t sleepMode = SLEEP_MODE_PWR_DOWN);

This will enter sleep mode for the AVR boards. See [Sleep Mode for AVR]{https://github.com/Makuna/Task/wiki/Sleep-Mode-for-AVR} for more details.

(Esp8266) void EnterSleep(uint32_t microSeconds, void* state = NULL, uint16_t sizeofState = 0, WakeMode mode = WAKE_RF_DEFAULT);

This will enter sleep mode for the Esp8266 boards. See Sleep Mode for Esp8266 for more details.

(esp8266) bool RestartedFromSleep(void* state = NULL, uint16_t sizeofState = 0 );

This will check if the sketch was started due to being awaken for the Esp8266 boards. See Sleep Mode for Esp8266 for more details.

uint32_t CurrentTaskTime()

Return the current time when the last Loop() was called.
Normally you might call millis() or micros() to get the current time. But this returns the value exactly when you call it; so often you might call it once and cache the value to use for multiple checks latter down in the code. This method can replace that as the time returned is the already cached time. See Task Time for more details.