TaskScehduler Arduino中Task的参数

parameters of Task in TaskScehduler Arduino

在 TaskScheduler Arduino Library 的 Task class 中使用了哪些不同的参数?

   #include <TaskScheduler.h>
   Scheduler runner;
   Task t2(3000, TASK_FOREVER, &t2Callback, &runner, true)

Task Scheduler 中使用的不同回调是什么?

谢谢

库的API在这个document中有很好的记载。对应栏目如下:

Task(unsigned long aInterval, long aIterations, void (aCallback)(), Scheduler aScheduler, bool aEnable, bool (*aOnEnable)(), void (aOnDisable)()) `- or - Task(unsigned long aInterval, long aIterations, TaskCallback aCallback, Scheduler aScheduler, bool aEnable, TaskOnEnable aOnEnable, TaskOnDisable aOnDisable)

Constructor with parameters. Creates a task that is scheduled to run every milliseconds, times, executing method on every pass.

  1. aInterval is in milliseconds (or microseconds) (default = 0)
  2. aIteration in number of times, -1 for indefinite execution (default = -1) Note: Tasks do not remember the number of iteration set initially. After the iterations are done, internal iteration counter is 0. If you need to perform another set of iterations, you need to set the number of iterations again. Note: Tasks which performed all their iterations remain active.
  3. aCallback is a pointer to a void callback method without parameters (default = NULL)
  4. aScheduler – optional reference to existing scheduler. If supplied (not NULL) this task will be appended to the task chain of the current scheduler). (default = NULL)
  5. aEnable – optional. Value of true will create task enabled. (default = false)
  6. aOnEnable is a pointer to a bool callback method without parameters, invoked when task is enabled. If OnEnable method returns true, task is enabled. If OnEnable method return false, task remains disabled (default = NULL)
  7. aOnDisable is a pointer to a void callback method without parameters, invoked when task is disabled (default = NULL)

All tasks are created disabled by default (unless aEnable = true). You have to explicitly enable the task for execution.

这 API 没有很好的记录。上面的link也是404。 约翰·麦克马汉