aboutsummaryrefslogtreecommitdiff
path: root/examples/Scheduler_example5_StatusRequest/Scheduler_example5_StatusRequest.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_example5_StatusRequest/Scheduler_example5_StatusRequest.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_example5_StatusRequest/Scheduler_example5_StatusRequest.ino')
-rw-r--r--examples/Scheduler_example5_StatusRequest/Scheduler_example5_StatusRequest.ino27
1 files changed, 17 insertions, 10 deletions
diff --git a/examples/Scheduler_example5_StatusRequest/Scheduler_example5_StatusRequest.ino b/examples/Scheduler_example5_StatusRequest/Scheduler_example5_StatusRequest.ino
index d1f2e5c..ff2d850 100644
--- a/examples/Scheduler_example5_StatusRequest/Scheduler_example5_StatusRequest.ino
+++ b/examples/Scheduler_example5_StatusRequest/Scheduler_example5_StatusRequest.ino
@@ -7,22 +7,29 @@
#define _TASK_SLEEP_ON_IDLE_RUN
#define _TASK_STATUS_REQUEST
-
#include <TaskScheduler.h>
-
-
-
StatusRequest measure;
Scheduler ts;
-Task tCycle(10000, -1, &CycleCallback, &ts, true);
-Task tMeasure(1000, 1, &MeasureCallback, &ts, false, &MeasureEnable, &MeasureDisable);
+// Callback methods prototypes
+void CycleCallback();
+void MeasureCallback();
+bool MeasureEnable();
+void MeasureDisable();
+void CalcCallback();
+void S1Callback(); bool S1Enable();
+void S2Callback(); bool S2Enable();
+void S3Callback(); bool S3Enable();
+
+// Tasks
+Task tCycle(10000, TASK_FOREVER, &CycleCallback, &ts, true);
+Task tMeasure(1000, TASK_ONCE, &MeasureCallback, &ts, false, &MeasureEnable, &MeasureDisable);
Task tCalculate(&CalcCallback, &ts);
-Task tSensor1(0, 1, &S1Callback, &ts, false, &S1Enable);
-Task tSensor2(0, 1, &S2Callback, &ts, false, &S2Enable);
-Task tSensor3(0, 1, &S3Callback, &ts, false, &S3Enable);
+Task tSensor1(0, TASK_ONCE, &S1Callback, &ts, false, &S1Enable);
+Task tSensor2(0, TASK_ONCE, &S2Callback, &ts, false, &S2Enable);
+Task tSensor3(0, TASK_ONCE, &S3Callback, &ts, false, &S3Enable);
long distance, d1, d2, d3;
@@ -162,4 +169,4 @@ void loop() {
ts.execute();
-}
+} \ No newline at end of file