Simple Task Scheduler. For the moment only implements continuous running tasks and periodic tasks.
Example
two blinking leds
#include "mbed.h" #include "task_scheduler.h" Serial pc(USBTX, USBRX); // tx, r class Foo { DigitalOut myled1; int counter; public: Foo(void) :myled1(LED1) { counter = 0; } void alive_task(void) { if (counter++ % 30000 == 0) { myled1 = !myled1; } } }; class Bar { DigitalOut myled2; public: Bar(void) :myled2(LED2) {} void control_task(void) { myled2 = !myled2; } }; int main() { Foo foo; Bar bar; SimpleTaskScheduler::TaskScheduler scheduler; scheduler.create_continuous_task(&foo, &Foo::alive_task); scheduler.create_periodic_task(&bar, &Bar::control_task, 1); while(1) { scheduler.update(); } }
Revisions of task_scheduler.h
Revision | Date | Message | Actions |
---|---|---|---|
3:bd96023168df | 2016-12-13 | Refactor and allow starting and stopping of tasks. | File Diff Annotate |
2:1d20f2b3c788 | 2016-07-13 | Fix: change period of periodic task to float instead of int | File Diff Annotate |
0:ba0870ec8714 | 2016-07-11 | Simple task scheduler. Alpha version. | File Diff Annotate |