Răsfoiți Sursa

v3.1.7: warning fix: unused parameter 'aRecursive' (Issue #99)

Anatoli Arkhipenko 5 ani în urmă
părinte
comite
07073c1371

+ 81 - 20
examples/Scheduler_template/Scheduler_template.ino

@@ -1,3 +1,42 @@
+/*
+    Your code description here
+    (c) you, 20XX
+    All rights reserved.
+
+    Functionality: 
+    
+    Version log:
+    
+    20XX-MM-DD:
+        v1.0.0  - Initial release
+        
+*/
+// ==== DEFINES ===================================================================================
+
+// ==== Debug and Test options ==================
+#define _DEBUG_
+//#define _TEST_
+
+//===== Debugging macros ========================
+#ifdef _DEBUG_
+#define SerialD Serial
+#define _PM(a) SerialD.print(millis()); SerialD.print(": "); SerialD.println(a)
+#define _PP(a) SerialD.print(a)
+#define _PL(a) SerialD.println(a)
+#define _PX(a) SerialD.println(a, HEX)
+#else
+#define _PM(a)
+#define _PP(a)
+#define _PL(a)
+#define _PX(a)
+#endif
+
+
+
+
+// ==== INCLUDES ==================================================================================
+
+// ==== Uncomment desired compile options =================================
 // #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
@@ -12,30 +51,19 @@
 // #define _TASK_OO_CALLBACKS      // Support for dynamic callback method binding
 // #define _TASK_DEFINE_MILLIS     // Force forward declaration of millis() and micros() "C" style
 // #define _TASK_EXPOSE_CHAIN      // Methods to access tasks in the task chain
-
 #include <TaskScheduler.h>
 
-// Debug and Test options
-#define _DEBUG_
-//#define _TEST_
-
-#ifdef _DEBUG_
-#define _PP(a) Serial.print(a);
-#define _PL(a) Serial.println(a);
-#else
-#define _PP(a)
-#define _PL(a)
-#endif
 
 
-// Scheduler
+// ==== GLOBALS ===================================================================================
+// ==== Scheduler ==============================
 Scheduler ts;
 
 void task1Callback();
 void task2Callback();
 
+// ==== Scheduling defines (cheat sheet) =====================
 /*
-  Scheduling defines:
   TASK_MILLISECOND
   TASK_SECOND
   TASK_MINUTE
@@ -46,10 +74,21 @@ void task2Callback();
   TASK_NOTIMEOUT
 */
 
+// ==== Task definitions ========================
 Task t1 (100 * TASK_MILLISECOND, TASK_FOREVER, &task1Callback, &ts, true);
 Task t2 (TASK_IMMEDIATE, 100, &task2Callback, &ts, true);
 
 
+
+// ==== CODE ======================================================================================
+
+/**************************************************************************/
+/*!
+    @brief    Standard Arduino SETUP method - initialize sketch
+    @param    none
+    @returns  none
+*/
+/**************************************************************************/
 void setup() {
   // put your setup code here, to run once:
 #if defined(_DEBUG_) || defined(_TEST_)
@@ -59,21 +98,43 @@ void setup() {
 #endif
 }
 
+
+/**************************************************************************/
+/*!
+    @brief    Standard Arduino LOOP method - using with TaskScheduler there 
+              should be nothing here but ts.execute()
+    @param    none
+    @returns  none
+*/
+/**************************************************************************/
 void loop() {
   ts.execute();
 }
 
 
+/**************************************************************************/
+/*!
+    @brief    Callback method of task1 - explain
+    @param    none
+    @returns  none
+*/
+/**************************************************************************/
 void task1Callback() {
-_PP(millis());
-_PL(": task1Callback()");
-
+_PM("task1Callback()");
+//  task code
 }
 
-void task2Callback() {
-_PP(millis());
-_PL(": task2Callb()");
 
+/**************************************************************************/
+/*!
+    @brief    Callback method of task2 - explain
+    @param    none
+    @returns  none
+*/
+/**************************************************************************/
+void task2Callback() {
+_PM("task2Callback()");
+//  task code
 }
 
 

+ 1 - 1
library.json

@@ -16,7 +16,7 @@
       "maintainer": true
     }
   ],
-  "version": "3.1.6",
+  "version": "3.1.7",
   "frameworks": "arduino",
   "platforms": "*"
 }

+ 1 - 1
library.properties

@@ -1,5 +1,5 @@
 name=TaskScheduler
-version=3.1.6
+version=3.1.7
 author=Anatoli Arkhipenko <arkhipenko@hotmail.com>
 maintainer=Anatoli Arkhipenko <arkhipenko@hotmail.com>
 sentence=Cooperative multitasking for Arduino, ESPx, STM32 and other microcontrollers.

+ 16 - 9
src/TaskScheduler.h

@@ -173,6 +173,9 @@
 //
 // v3.1.6:
 //    2020-05-12 - bug fix: deleteTask and addTask should check task ownership first (Issue #97)
+//
+// v3.1.7:
+//    2020-07-07 - warning fix: unused parameter 'aRecursive' (Issue #99)
 
 
 #include <Arduino.h>
@@ -786,7 +789,11 @@ void Scheduler::deleteTask(Task& aTask) {
  * task remaining active is an error processing task
  * @param aRecursive - if true, tasks of the higher priority chains are disabled as well recursively
  */
+#ifdef _TASK_PRIORITY
 void Scheduler::disableAll(bool aRecursive) {
+#else
+void Scheduler::disableAll() {
+#endif
     Task    *current = iFirst;
     while (current) {
         current->disable();
@@ -802,7 +809,11 @@ void Scheduler::disableAll(bool aRecursive) {
 /** Enables all the tasks in the execution chain
  * @param aRecursive - if true, tasks of the higher priority chains are enabled as well recursively
  */
- void Scheduler::enableAll(bool aRecursive) {
+#ifdef _TASK_PRIORITY
+void Scheduler::enableAll(bool aRecursive) {
+#else
+void Scheduler::enableAll() {
+#endif    
     Task    *current = iFirst;
     while (current) {
         current->enable();
@@ -835,19 +846,15 @@ void Scheduler::setHighPriorityScheduler(Scheduler* aScheduler) {
 #ifdef _TASK_SLEEP_ON_IDLE_RUN
 void Scheduler::allowSleep(bool aState) {
     iAllowSleep = aState;
-
-#ifdef ARDUINO_ARCH_ESP8266
-    wifi_set_sleep_type( iAllowSleep ? LIGHT_SLEEP_T : NONE_SLEEP_T );
-#endif  // ARDUINO_ARCH_ESP8266
-
-#ifdef ARDUINO_ARCH_ESP32
-    // TO-DO; find a suitable replacement for ESP32 if possible.
-#endif  // ARDUINO_ARCH_ESP32
 }
 #endif  // _TASK_SLEEP_ON_IDLE_RUN
 
 
+#ifdef _TASK_PRIORITY
 void Scheduler::startNow( bool aRecursive ) {
+#else
+void Scheduler::startNow() {
+#endif
     unsigned long t = _TASK_TIME_FUNCTION();
 
     iCurrent = iFirst;

+ 7 - 1
src/TaskSchedulerDeclarations.h

@@ -280,10 +280,16 @@ class Scheduler {
     INLINE void init();
     INLINE void addTask(Task& aTask);
     INLINE void deleteTask(Task& aTask);
+#ifdef _TASK_PRIORITY
     INLINE void disableAll(bool aRecursive = true);
     INLINE void enableAll(bool aRecursive = true);
-    INLINE bool execute();                              // Returns true if none of the tasks' callback methods was invoked (true = idle run)
     INLINE void startNow(bool aRecursive = true);       // reset ALL active tasks to immediate execution NOW.
+#else
+    INLINE void disableAll();
+    INLINE void enableAll();
+    INLINE void startNow();                             // reset ALL active tasks to immediate execution NOW.
+#endif
+    INLINE bool execute();                              // Returns true if none of the tasks' callback methods was invoked (true = idle run)
     INLINE Task& currentTask() ;                        // DEPRICATED
     INLINE Task* getCurrentTask() ;                     // Returns pointer to the currently active task
     INLINE long timeUntilNextIteration(Task& aTask);    // return number of ms until next iteration of a given Task