|
|
@@ -8,18 +8,29 @@
|
|
|
*/
|
|
|
|
|
|
|
|
|
-// #define _TASK_TIMECRITICAL // Enable monitoring scheduling overruns
|
|
|
-#define _TASK_SLEEP_ON_IDLE_RUN // Enable 1 ms SLEEP_IDLE powerdowns between tasks if no callback methods were invoked during the pass
|
|
|
-#define _TASK_STATUS_REQUEST // Compile with support for StatusRequest functionality - triggering tasks on status change events in addition to time only
|
|
|
-// #define _TASK_WDT_IDS // Compile with support for wdt control points and task ids
|
|
|
-// #define _TASK_LTS_POINTER // Compile with support for local task storage pointer
|
|
|
-// #define _TASK_PRIORITY // Support for layered scheduling priority
|
|
|
-// #define _TASK_MICRO_RES // Support for microsecond resolution
|
|
|
-// #define _TASK_STD_FUNCTION // Support for std::function (ESP8266 and ESP32 ONLY)
|
|
|
-// #define _TASK_DEBUG // Make all methods and variables public for debug purposes
|
|
|
-// #define _TASK_INLINE // Make all methods "inline" - needed to support some multi-tab, multi-file implementations
|
|
|
-// #define _TASK_TIMEOUT // Support for overall task timeout
|
|
|
-// #define _TASK_OO_CALLBACKS // Support for dynamic callback method binding
|
|
|
+// ----------------------------------------
|
|
|
+// The following "defines" control library functionality at compile time,
|
|
|
+// and should be used in the main sketch depending on the functionality required
|
|
|
+//
|
|
|
+// #define _TASK_TIMECRITICAL // Enable monitoring scheduling overruns
|
|
|
+#define _TASK_SLEEP_ON_IDLE_RUN // Enable 1 ms SLEEP_IDLE powerdowns between runs if no callback methods were invoked during the pass
|
|
|
+#define _TASK_STATUS_REQUEST // Compile with support for StatusRequest functionality - triggering tasks on status change events in addition to time only
|
|
|
+// #define _TASK_WDT_IDS // Compile with support for wdt control points and task ids
|
|
|
+// #define _TASK_LTS_POINTER // Compile with support for local task storage pointer
|
|
|
+// #define _TASK_PRIORITY // Support for layered scheduling priority
|
|
|
+// #define _TASK_MICRO_RES // Support for microsecond resolution
|
|
|
+// #define _TASK_STD_FUNCTION // Support for std::function (ESP8266 ONLY)
|
|
|
+// #define _TASK_DEBUG // Make all methods and variables public for debug purposes
|
|
|
+// #define _TASK_INLINE // Make all methods "inline" - needed to support some multi-tab, multi-file implementations
|
|
|
+// #define _TASK_TIMEOUT // Support for overall task timeout
|
|
|
+// #define _TASK_OO_CALLBACKS // Support for callbacks via inheritance
|
|
|
+// #define _TASK_EXPOSE_CHAIN // Methods to access tasks in the task chain
|
|
|
+// #define _TASK_SCHEDULING_OPTIONS // Support for multiple scheduling options
|
|
|
+// #define _TASK_DEFINE_MILLIS // Force forward declaration of millis() and micros() "C" style
|
|
|
+// #define _TASK_EXTERNAL_TIME // Custom millis() and micros() methods
|
|
|
+// #define _TASK_THREAD_SAFE // Enable additional checking for thread safety
|
|
|
+// #define _TASK_SELF_DESTRUCT // Enable tasks to "self-destruct" after disable
|
|
|
+
|
|
|
#include <TScheduler.hpp>
|
|
|
|
|
|
// Debug and Test options
|
|
|
@@ -40,7 +51,7 @@
|
|
|
#endif
|
|
|
|
|
|
// Scheduler
|
|
|
-TaskScheduler ts;
|
|
|
+TsScheduler ts;
|
|
|
|
|
|
/*
|
|
|
Approach 1: LED is driven by the boolean variable; false = OFF, true = ON
|
|
|
@@ -48,7 +59,7 @@ TaskScheduler ts;
|
|
|
#define PERIOD1 500
|
|
|
#define DURATION 10000
|
|
|
void blink1CB();
|
|
|
-Task tBlink1 ( PERIOD1 * TASK_MILLISECOND, DURATION / PERIOD1, &blink1CB, &ts, true );
|
|
|
+TsTask tBlink1 ( PERIOD1 * TASK_MILLISECOND, DURATION / PERIOD1, &blink1CB, &ts, true );
|
|
|
|
|
|
/*
|
|
|
Approac 2: two callback methods: one turns ON, another turns OFF
|
|
|
@@ -56,14 +67,14 @@ Task tBlink1 ( PERIOD1 * TASK_MILLISECOND, DURATION / PERIOD1, &blink1CB, &ts, t
|
|
|
#define PERIOD2 400
|
|
|
void blink2CB_ON();
|
|
|
void blink2CB_OFF();
|
|
|
-Task tBlink2 ( PERIOD2 * TASK_MILLISECOND, DURATION / PERIOD2, &blink2CB_ON, &ts, false );
|
|
|
+TsTask tBlink2 ( PERIOD2 * TASK_MILLISECOND, DURATION / PERIOD2, &blink2CB_ON, &ts, false );
|
|
|
|
|
|
/*
|
|
|
Approach 3: Use RunCounter
|
|
|
*/
|
|
|
#define PERIOD3 300
|
|
|
void blink3CB();
|
|
|
-Task tBlink3 (PERIOD3 * TASK_MILLISECOND, DURATION / PERIOD3, &blink3CB, &ts, false);
|
|
|
+TsTask tBlink3 (PERIOD3 * TASK_MILLISECOND, DURATION / PERIOD3, &blink3CB, &ts, false);
|
|
|
|
|
|
/*
|
|
|
Approach 4: Use status request objects to pass control from one task to the other
|
|
|
@@ -73,8 +84,8 @@ bool blink41OE();
|
|
|
void blink41();
|
|
|
void blink42();
|
|
|
void blink42OD();
|
|
|
-Task tBlink4On ( PERIOD4 * TASK_MILLISECOND, TASK_ONCE, blink41, &ts, false, &blink41OE );
|
|
|
-Task tBlink4Off ( PERIOD4 * TASK_MILLISECOND, TASK_ONCE, blink42, &ts, false, NULL, &blink42OD );
|
|
|
+TsTask tBlink4On ( PERIOD4 * TASK_MILLISECOND, TASK_ONCE, blink41, &ts, false, &blink41OE );
|
|
|
+TsTask tBlink4Off ( PERIOD4 * TASK_MILLISECOND, TASK_ONCE, blink42, &ts, false, NULL, &blink42OD );
|
|
|
|
|
|
|
|
|
/*
|
|
|
@@ -85,8 +96,8 @@ bool blink51OE();
|
|
|
void blink51();
|
|
|
void blink52();
|
|
|
void blink52OD();
|
|
|
-Task tBlink5On ( 600 * TASK_MILLISECOND, DURATION / PERIOD5, &blink51, &ts, false, &blink51OE );
|
|
|
-Task tBlink5Off ( 600 * TASK_MILLISECOND, DURATION / PERIOD5, &blink52, &ts, false, NULL, &blink52OD );
|
|
|
+TsTask tBlink5On ( 600 * TASK_MILLISECOND, DURATION / PERIOD5, &blink51, &ts, false, &blink51OE );
|
|
|
+TsTask tBlink5Off ( 600 * TASK_MILLISECOND, DURATION / PERIOD5, &blink52, &ts, false, NULL, &blink52OD );
|
|
|
|
|
|
|
|
|
/*
|
|
|
@@ -96,7 +107,7 @@ Task tBlink5Off ( 600 * TASK_MILLISECOND, DURATION / PERIOD5, &blink52, &ts, fal
|
|
|
void blink6CB();
|
|
|
bool blink6OE();
|
|
|
void blink6OD();
|
|
|
-Task tBlink6 ( PERIOD6 * TASK_MILLISECOND, DURATION / PERIOD6, &blink6CB, &ts, false, &blink6OE, &blink6OD );
|
|
|
+TsTask tBlink6 ( PERIOD6 * TASK_MILLISECOND, DURATION / PERIOD6, &blink6CB, &ts, false, &blink6OE, &blink6OD );
|
|
|
|
|
|
void setup() {
|
|
|
// put your setup code here, to run once:
|
|
|
@@ -212,7 +223,7 @@ void blink41() {
|
|
|
// _PP(millis());
|
|
|
// _PL(": blink41");
|
|
|
LEDOn();
|
|
|
- StatusRequest* r = tBlink4On.getInternalStatusRequest();
|
|
|
+ TsStatusRequest* r = tBlink4On.getInternalStatusRequest();
|
|
|
tBlink4Off.waitForDelayed( r );
|
|
|
counter++;
|
|
|
}
|
|
|
@@ -221,7 +232,7 @@ void blink42() {
|
|
|
// _PP(millis());
|
|
|
// _PL(": blink42");
|
|
|
LEDOff();
|
|
|
- StatusRequest* r = tBlink4Off.getInternalStatusRequest();
|
|
|
+ TsStatusRequest* r = tBlink4Off.getInternalStatusRequest();
|
|
|
tBlink4On.waitForDelayed( r );
|
|
|
counter++;
|
|
|
}
|