Very simple cooperative round-robin task scheduler. See examples.

Dependents:   Garage_Control

Embed: (wiki syntax)

« Back to documentation index

SimpleScheduler Class Reference

SimpleScheduler Class Reference

SimpleScheduler. More...

#include <SimpleScheduler.h>

Detailed Description


Manages a set of function or class.methods as tasks to be called at a scheduled frquency. Simple round-robin task caller. Note, it's cooperative. That means your task functions must return BEFORE another task can be called.

See also:
 #include "mbed.h"
 #include "SimpleScheduler.h"
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
 DigitalOut led3(LED3);
 void f1(SimpleTask *task) { led1 = !led1; }
 void f2(SimpleTask *task) { led2 = !led2; }
 void f3(SimpleTask *task) { led3 = !led3; }
 SimpleScheduler *scheduler;
 int main() {
     scheduler = new SimpleScheduler;
         ->addTask( new SimpleTask(0,   f1) ) // As often as possible
         ->addTask( new SimpleTask(200, f2) ) // Every 200milliseconds
         ->addTask( new SimpleTask(1.0, f3) ) // Once a second

Definition at line 180 of file SimpleScheduler.h.