What are the different parameters used in the Task class of TaskScheduler Arduino Library?
#include <TaskScheduler.h>
Scheduler runner;
Task t2(3000, TASK_FOREVER, &t2Callback, &runner, true)
What are the different callbacks that be used in Task Scheduler?
ThankYou
The API of the library is well documented in the wiki on GitHub. The corresponding section is the following:
Task(unsigned long aInterval, long aIterations, void (*aCallback)(), Scheduler* aScheduler, bool aEnable, bool (*aOnEnable)(), void (*aOnDisable)(), bool aSelfdestruct); // OR Task(unsigned long aInterval, long aIterations, TaskCallback aCallback, Scheduler* aScheduler, bool aEnable, TaskOnEnable aOnEnable, TaskOnDisable aOnDisable, bool aSelfdestruct);
Constructor with parameters.
Creates a task that is scheduled to run every <aInterval
> milliseconds, <aIterations
> times, executing <aCallback
> method on every pass.
aInterval
is inmilliseconds
(ormicroseconds
) (default = 0 or TASK_IMMEDIATE
)aIteration
in number of times,-1 or TASK_FOREVER
for indefinite execution (default = 0
)
Note: Tasks remember the number of iteration set initially, and could be restarted. After the iterations are done, the internal iteration counter is0
. If you need to perform a different set of iterations, you need to set the number of iterations explicitly.
Note: Tasks which performed all their iterations will be disabled during next scheduling run.aCallback
is a pointer to a void callback method without parameters (default = NULL
)aScheduler
– optional reference to existing scheduler. If supplied (notNULL
) this task will be appended to the task chain of the current scheduler). (default = NULL
)aEnable
– optional. Value of true will create task enabled. (default = false
)aOnEnable
is a pointer to a bool callback method without parameters, invoked when task isenabled
. IfOnEnable
method returnstrue
, task isenabled
. IfOnEnable
method returnfalse
, task remainsdisabled
(default = NULL
)aOnDisable
is a pointer to a void callback method without parameters, invoked when task isdisabled
(default = NULL
)All tasks are created disabled by default (unless
aEnable = true
). You have to explicitlyenable
the task for execution.