will be read-only starting December 31st, 2018. For more info please look at this Forum Post

TaskScheduler Library:

Simple Task Scheduler

This is basically a set of timers and a very simple round-robin, run-to-completion scheduler. The scheduler runs off the millis() counter so all delays are in milliseconds.

Currently supported:

  • 256 tasks
  • 65535 ms max delay


Each task has 4 states:

  • TASK_OFF - completely disabled and will not run, regardless of its timer
  • TASK_STOP - task has run to competion and has not been put to sleep
  • TASK_PEND - pending on its timer (sleeping, waiting for timeout)
  • TASK_RUN - task is running (or ready to run)

In your program you need to set up a task block array, where each entry is the starting parameters for a task. Here is an example of what should be at the top of your sketch. The enumeration and NUM_TASKS are optional, if you just want to use the actual numbers.

// Task list where each line matches a line in the task block

// The task block with starting values
TaskBlock taskBlock[] =
   // Entry Point    State     Starting Count
   {&ledBlinkTask,   TASK_RUN, 0},  // LED_BLINK_TASK
   {&helloWorldTask, TASK_RUN, 0}   // HELLO_WORLD_TASK

// The number of tasks (automatically calculated
#define NUM_TASKS (sizeof(taskBlock)/sizeof(TaskBlock))

Then in your setup():

   // put other setup stuff here
   void TS.initialize(taskBlock, NUM_TASKS);