aboutsummaryrefslogtreecommitdiff
path: root/examples/Scheduler_example3/Scheduler_example3.ino
diff options
context:
space:
mode:
authorAnatoli Arkhipenko <arkhipenko@hotmail.com>2015-11-14 17:46:16 -0500
committerAnatoli Arkhipenko <arkhipenko@hotmail.com>2015-11-14 17:46:16 -0500
commitdc152db48e325a5d03be0d48a07c119d97d11e59 (patch)
tree72fdcd4c9feee8da743e9540ce58580e7392a7d9 /examples/Scheduler_example3/Scheduler_example3.ino
parentef2329bdeade723f560cd0f7e933c9f3119677f3 (diff)
Version 1.8.3 number of addtions and improvementsv1.8.3
* support for task activation on a status request with arbitrary interval and number of iterations (0 and 1 are still default values) * implement waitForDelayed() method to allow task activation on the status request completion delayed for one current interval * added callback methods prototypes to all examples for Arduino IDE 1.6.6 compatibility * added several constants to be used as task parameters for readability (e.g, TASK_FOREVER, TASK_SECOND, etc.) * significant optimization of the scheduler's execute loop, including millis() rollover fix option
Diffstat (limited to 'examples/Scheduler_example3/Scheduler_example3.ino')
-rw-r--r--examples/Scheduler_example3/Scheduler_example3.ino17
1 files changed, 13 insertions, 4 deletions
diff --git a/examples/Scheduler_example3/Scheduler_example3.ino b/examples/Scheduler_example3/Scheduler_example3.ino
index 7111ac3..115f7bc 100644
--- a/examples/Scheduler_example3/Scheduler_example3.ino
+++ b/examples/Scheduler_example3/Scheduler_example3.ino
@@ -1,7 +1,7 @@
/**
* TaskScheduler Test of OnEnable and OnDisable methods and illustration of using wrapper tasks for timout purposes
*
- * A wrapper task runs every 30 seconds and initiates the test case
+ * A wrapper task runs every 10 seconds and initiates the test case
* Another task is run once for 5 seconds, and serves as a LED blinking timeout - 5 seconds
* Finally, a dedicated task which controls LED is running periodically until stopped, and makes the LED blink with 0.5 to 1 second interval.
*
@@ -14,9 +14,17 @@
Scheduler ts;
-Task tWrapper(30000L, -1, &WrapperCallback, &ts, true);
-Task tBlink(5000, 1, NULL, &ts, false, &BlinkOnEnable, &BlinkOnDisable);
-Task tLED(0, -1, NULL, &ts, false, NULL, &LEDOff);
+// Callback methods prototypes
+void WrapperCallback();
+bool BlinkOnEnable();
+void BlinkOnDisable();
+void LEDOn();
+void LEDOff();
+
+// Tasks
+Task tWrapper(10000L, TASK_FOREVER, &WrapperCallback, &ts, true);
+Task tBlink(5000, TASK_ONCE, NULL, &ts, false, &BlinkOnEnable, &BlinkOnDisable);
+Task tLED(0, TASK_FOREVER, NULL, &ts, false, NULL, &LEDOff);
void WrapperCallback() {
tBlink.restartDelayed(); // LED blinking is initiated
@@ -61,6 +69,7 @@ void LEDOff () {
void setup() {
// put your setup code here, to run once:
+ pinMode(LEDPIN, OUTPUT);
}
void loop() {