88*/
99
1010
11- // #define _TASK_TIMECRITICAL // Enable monitoring scheduling overruns
12- #define _TASK_SLEEP_ON_IDLE_RUN // Enable 1 ms SLEEP_IDLE powerdowns between tasks if no callback methods were invoked during the pass
13- #define _TASK_STATUS_REQUEST // Compile with support for StatusRequest functionality - triggering tasks on status change events in addition to time only
14- // #define _TASK_WDT_IDS // Compile with support for wdt control points and task ids
15- // #define _TASK_LTS_POINTER // Compile with support for local task storage pointer
16- // #define _TASK_PRIORITY // Support for layered scheduling priority
17- // #define _TASK_MICRO_RES // Support for microsecond resolution
18- // #define _TASK_STD_FUNCTION // Support for std::function (ESP8266 and ESP32 ONLY)
19- // #define _TASK_DEBUG // Make all methods and variables public for debug purposes
20- // #define _TASK_INLINE // Make all methods "inline" - needed to support some multi-tab, multi-file implementations
21- // #define _TASK_TIMEOUT // Support for overall task timeout
22- // #define _TASK_OO_CALLBACKS // Support for dynamic callback method binding
11+ // ----------------------------------------
12+ // The following "defines" control library functionality at compile time,
13+ // and should be used in the main sketch depending on the functionality required
14+ //
15+ // #define _TASK_TIMECRITICAL // Enable monitoring scheduling overruns
16+ #define _TASK_SLEEP_ON_IDLE_RUN // Enable 1 ms SLEEP_IDLE powerdowns between runs if no callback methods were invoked during the pass
17+ #define _TASK_STATUS_REQUEST // Compile with support for StatusRequest functionality - triggering tasks on status change events in addition to time only
18+ // #define _TASK_WDT_IDS // Compile with support for wdt control points and task ids
19+ // #define _TASK_LTS_POINTER // Compile with support for local task storage pointer
20+ // #define _TASK_PRIORITY // Support for layered scheduling priority
21+ // #define _TASK_MICRO_RES // Support for microsecond resolution
22+ // #define _TASK_STD_FUNCTION // Support for std::function (ESP8266 ONLY)
23+ // #define _TASK_DEBUG // Make all methods and variables public for debug purposes
24+ // #define _TASK_INLINE // Make all methods "inline" - needed to support some multi-tab, multi-file implementations
25+ // #define _TASK_TIMEOUT // Support for overall task timeout
26+ // #define _TASK_OO_CALLBACKS // Support for callbacks via inheritance
27+ // #define _TASK_EXPOSE_CHAIN // Methods to access tasks in the task chain
28+ // #define _TASK_SCHEDULING_OPTIONS // Support for multiple scheduling options
29+ // #define _TASK_DEFINE_MILLIS // Force forward declaration of millis() and micros() "C" style
30+ // #define _TASK_EXTERNAL_TIME // Custom millis() and micros() methods
31+ // #define _TASK_THREAD_SAFE // Enable additional checking for thread safety
32+ // #define _TASK_SELF_DESTRUCT // Enable tasks to "self-destruct" after disable
33+
2334#include < TScheduler.hpp>
2435
2536// Debug and Test options
4051#endif
4152
4253// Scheduler
43- TaskScheduler ts;
54+ TsScheduler ts;
4455
4556/*
4657 Approach 1: LED is driven by the boolean variable; false = OFF, true = ON
4758*/
4859#define PERIOD1 500
4960#define DURATION 10000
5061void blink1CB ();
51- Task tBlink1 ( PERIOD1 * TASK_MILLISECOND, DURATION / PERIOD1, &blink1CB, &ts, true );
62+ TsTask tBlink1 ( PERIOD1 * TASK_MILLISECOND, DURATION / PERIOD1, &blink1CB, &ts, true );
5263
5364/*
5465 Approac 2: two callback methods: one turns ON, another turns OFF
5566*/
5667#define PERIOD2 400
5768void blink2CB_ON ();
5869void blink2CB_OFF ();
59- Task tBlink2 ( PERIOD2 * TASK_MILLISECOND, DURATION / PERIOD2, &blink2CB_ON, &ts, false );
70+ TsTask tBlink2 ( PERIOD2 * TASK_MILLISECOND, DURATION / PERIOD2, &blink2CB_ON, &ts, false );
6071
6172/*
6273 Approach 3: Use RunCounter
6374*/
6475#define PERIOD3 300
6576void blink3CB ();
66- Task tBlink3 (PERIOD3 * TASK_MILLISECOND, DURATION / PERIOD3, &blink3CB, &ts, false );
77+ TsTask tBlink3 (PERIOD3 * TASK_MILLISECOND, DURATION / PERIOD3, &blink3CB, &ts, false );
6778
6879/*
6980 Approach 4: Use status request objects to pass control from one task to the other
@@ -73,8 +84,8 @@ bool blink41OE();
7384void blink41 ();
7485void blink42 ();
7586void blink42OD ();
76- Task tBlink4On ( PERIOD4 * TASK_MILLISECOND, TASK_ONCE, blink41, &ts, false , &blink41OE );
77- Task tBlink4Off ( PERIOD4 * TASK_MILLISECOND, TASK_ONCE, blink42, &ts, false , NULL , &blink42OD );
87+ TsTask tBlink4On ( PERIOD4 * TASK_MILLISECOND, TASK_ONCE, blink41, &ts, false , &blink41OE );
88+ TsTask tBlink4Off ( PERIOD4 * TASK_MILLISECOND, TASK_ONCE, blink42, &ts, false , NULL , &blink42OD );
7889
7990
8091/*
@@ -85,8 +96,8 @@ bool blink51OE();
8596void blink51 ();
8697void blink52 ();
8798void blink52OD ();
88- Task tBlink5On ( 600 * TASK_MILLISECOND, DURATION / PERIOD5, &blink51, &ts, false , &blink51OE );
89- Task tBlink5Off ( 600 * TASK_MILLISECOND, DURATION / PERIOD5, &blink52, &ts, false , NULL , &blink52OD );
99+ TsTask tBlink5On ( 600 * TASK_MILLISECOND, DURATION / PERIOD5, &blink51, &ts, false , &blink51OE );
100+ TsTask tBlink5Off ( 600 * TASK_MILLISECOND, DURATION / PERIOD5, &blink52, &ts, false , NULL , &blink52OD );
90101
91102
92103/*
@@ -96,7 +107,7 @@ Task tBlink5Off ( 600 * TASK_MILLISECOND, DURATION / PERIOD5, &blink52, &ts, fal
96107void blink6CB ();
97108bool blink6OE ();
98109void blink6OD ();
99- Task tBlink6 ( PERIOD6 * TASK_MILLISECOND, DURATION / PERIOD6, &blink6CB, &ts, false , &blink6OE, &blink6OD );
110+ TsTask tBlink6 ( PERIOD6 * TASK_MILLISECOND, DURATION / PERIOD6, &blink6CB, &ts, false , &blink6OE, &blink6OD );
100111
101112void setup () {
102113 // put your setup code here, to run once:
@@ -212,7 +223,7 @@ void blink41() {
212223 // _PP(millis());
213224 // _PL(": blink41");
214225 LEDOn ();
215- StatusRequest * r = tBlink4On.getInternalStatusRequest ();
226+ TsStatusRequest * r = tBlink4On.getInternalStatusRequest ();
216227 tBlink4Off.waitForDelayed ( r );
217228 counter++;
218229}
@@ -221,7 +232,7 @@ void blink42() {
221232 // _PP(millis());
222233 // _PL(": blink42");
223234 LEDOff ();
224- StatusRequest * r = tBlink4Off.getInternalStatusRequest ();
235+ TsStatusRequest * r = tBlink4Off.getInternalStatusRequest ();
225236 tBlink4On.waitForDelayed ( r );
226237 counter++;
227238}
0 commit comments