diff options
| author | Anatoli Arkhipenko <arkhipenko@hotmail.com> | 2015-12-23 17:04:21 -0500 |
|---|---|---|
| committer | Anatoli Arkhipenko <arkhipenko@hotmail.com> | 2015-12-23 17:12:06 -0500 |
| commit | 965f1b768d3d0675e2483ca62fa6d0565c389a31 (patch) | |
| tree | 8bae4e1eee8275efaab252b35cb26c6a304fb015 /examples/Scheduler_example09_TimeCritical/Scheduler_example09_TimeCritical.ino | |
| parent | 42d8d776e3fdb3c48700a3d88c8615dbf81da23f (diff) | |
Version 2.0.0 support for layered task prioritizationv2.0.0
* _TASK_PRIORITY - support for layered task prioritization
Diffstat (limited to 'examples/Scheduler_example09_TimeCritical/Scheduler_example09_TimeCritical.ino')
| -rw-r--r-- | examples/Scheduler_example09_TimeCritical/Scheduler_example09_TimeCritical.ino | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/examples/Scheduler_example09_TimeCritical/Scheduler_example09_TimeCritical.ino b/examples/Scheduler_example09_TimeCritical/Scheduler_example09_TimeCritical.ino new file mode 100644 index 0000000..b330d6f --- /dev/null +++ b/examples/Scheduler_example09_TimeCritical/Scheduler_example09_TimeCritical.ino @@ -0,0 +1,57 @@ +/** + * TaskScheduler Test + * Illustration of use of Time Critical Information + * + * Task1 runs every 1 second indefinitely + * On each run it reports how delayed the invokation of the callback method was, + * and what was the scheduling overun. + * Each run task 1 is dealyed randomly for up to 2 seconds, thus simulating scheduling overrun + */ + + #define _TASK_TIMECRITICAL + #define _TASK_SLEEP_ON_IDLE_RUN +#include <TaskScheduler.h> + +// Callback methods prototypes +void t1Callback(); + + +//Tasks +Task t1(1000, -1, &t1Callback); + +Scheduler runner; + + +void t1Callback() { + Serial.print(millis()); + Serial.print(": overrun = "); + Serial.print(t1.getOverrun()); + Serial.print(", start delayed by "); + Serial.println(t1.getStartDelay()); + + int i = random(2000); + Serial.print("Delaying for "); Serial.println(i); + delay(i); +} + +void setup () { + Serial.begin(115200); + Serial.println("Scheduler TimeCritical TEST"); + + runner.init(); + Serial.println("Initialized scheduler"); + + runner.addTask(t1); + Serial.println("added t1. Waiting for 5 seconds."); + + delay(5000); + + t1.enable(); + + Serial.println("Enabled t1"); +} + + +void loop () { + runner.execute(); +} |
