8
8
*/
9
9
10
10
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
+
23
34
#include < TScheduler.hpp>
24
35
25
36
// Debug and Test options
40
51
#endif
41
52
42
53
// Scheduler
43
- TaskScheduler ts;
54
+ TsScheduler ts;
44
55
45
56
/*
46
57
Approach 1: LED is driven by the boolean variable; false = OFF, true = ON
47
58
*/
48
59
#define PERIOD1 500
49
60
#define DURATION 10000
50
61
void blink1CB ();
51
- Task tBlink1 ( PERIOD1 * TASK_MILLISECOND, DURATION / PERIOD1, &blink1CB, &ts, true );
62
+ TsTask tBlink1 ( PERIOD1 * TASK_MILLISECOND, DURATION / PERIOD1, &blink1CB, &ts, true );
52
63
53
64
/*
54
65
Approac 2: two callback methods: one turns ON, another turns OFF
55
66
*/
56
67
#define PERIOD2 400
57
68
void blink2CB_ON ();
58
69
void 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 );
60
71
61
72
/*
62
73
Approach 3: Use RunCounter
63
74
*/
64
75
#define PERIOD3 300
65
76
void blink3CB ();
66
- Task tBlink3 (PERIOD3 * TASK_MILLISECOND, DURATION / PERIOD3, &blink3CB, &ts, false );
77
+ TsTask tBlink3 (PERIOD3 * TASK_MILLISECOND, DURATION / PERIOD3, &blink3CB, &ts, false );
67
78
68
79
/*
69
80
Approach 4: Use status request objects to pass control from one task to the other
@@ -73,8 +84,8 @@ bool blink41OE();
73
84
void blink41 ();
74
85
void blink42 ();
75
86
void 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 );
78
89
79
90
80
91
/*
@@ -85,8 +96,8 @@ bool blink51OE();
85
96
void blink51 ();
86
97
void blink52 ();
87
98
void 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 );
90
101
91
102
92
103
/*
@@ -96,7 +107,7 @@ Task tBlink5Off ( 600 * TASK_MILLISECOND, DURATION / PERIOD5, &blink52, &ts, fal
96
107
void blink6CB ();
97
108
bool blink6OE ();
98
109
void 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 );
100
111
101
112
void setup () {
102
113
// put your setup code here, to run once:
@@ -212,7 +223,7 @@ void blink41() {
212
223
// _PP(millis());
213
224
// _PL(": blink41");
214
225
LEDOn ();
215
- StatusRequest * r = tBlink4On.getInternalStatusRequest ();
226
+ TsStatusRequest * r = tBlink4On.getInternalStatusRequest ();
216
227
tBlink4Off.waitForDelayed ( r );
217
228
counter++;
218
229
}
@@ -221,7 +232,7 @@ void blink42() {
221
232
// _PP(millis());
222
233
// _PL(": blink42");
223
234
LEDOff ();
224
- StatusRequest * r = tBlink4Off.getInternalStatusRequest ();
235
+ TsStatusRequest * r = tBlink4Off.getInternalStatusRequest ();
225
236
tBlink4On.waitForDelayed ( r );
226
237
counter++;
227
238
}
0 commit comments