Quellcode durchsuchen

v3.1.5 - light sleep for esp32

Anatoli Arkhipenko vor 5 Jahren
Ursprung
Commit
fc18a9ffe4

+ 1 - 1
README

@@ -1,5 +1,5 @@
 Task Scheduler – cooperative multitasking for Arduino, ESPx, STM32 and other microcontrollers
-Version 3.1.4 2020-02-22
+Version 3.1.5 2020-05-08
 
 If you find TaskScheduler useful for your Arduino project, please drop me an email: arkhipenko@hotmail.com
 ----------------------------------------------------------------------------------------------------------

+ 1 - 1
README.md

@@ -1,6 +1,6 @@
 # Task Scheduler
 ### Cooperative multitasking for Arduino, ESPx, STM32 and other microcontrollers
-#### Version 3.1.4: 2020-02-22
+#### Version 3.1.5: 2020-05-08
 
 ### OVERVIEW:
 A lightweight implementation of cooperative multitasking (task scheduling) supporting:

BIN
extras/TaskScheduler.doc


BIN
extras/TaskScheduler.pdf


+ 1 - 1
extras/These documents are no longer current.txt

@@ -1,3 +1,3 @@
-As of March 2018 these offline documents are no longer maintained. 
+As of May 2020 all offline documents are deprecated. 
 For the latest documentation of TaskScheduler please visit:
 https://github.com/arkhipenko/TaskScheduler/wiki

+ 1 - 1
library.json

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

+ 1 - 1
library.properties

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

+ 4 - 0
src/TaskScheduler.h

@@ -167,6 +167,10 @@
 // v3.1.4:
 //    2020-02-22 - bug: get rid of unnecessary compiler warnings
 //    2020-02-22 - feature: access to the task chain with _TASK_EXPOSE_CHAIN compile option
+//
+// v3.1.5:
+//    2020-05-08 - feature: implemented light sleep for esp32
+
 
 #include <Arduino.h>
 

+ 7 - 6
src/TaskSchedulerSleepMethods.h

@@ -47,18 +47,19 @@ void SleepMethod( unsigned long aDuration ) {
 
 #elif defined( ARDUINO_ARCH_ESP32 )
 
+#include <esp_sleep.h>
+
 #ifndef _TASK_ESP32_DLY_THRESHOLD
 #define _TASK_ESP32_DLY_THRESHOLD 200L
 #endif
-#warning _TASK_SLEEP_ON_IDLE_RUN for ESP32 cannot use light sleep mode but a standard delay for 1 ms
 extern unsigned long tStart, tFinish;
+const unsigned long tRem = 1000-_TASK_ESP32_DLY_THRESHOLD;
 
 void SleepMethod( unsigned long aDuration ) {
-//TODO: find a correct light sleep implementation for ESP32
-    // esp_sleep_enable_timer_wakeup(1000); //1 ms
-    // int ret= esp_light_sleep_start();
-      if ( aDuration < _TASK_ESP32_DLY_THRESHOLD) delay(1);   // ESP8266 implementation of delay() uses timers and yield
-
+    if ( aDuration < tRem ) {
+        esp_sleep_enable_timer_wakeup((uint64_t) (1000 - aDuration));
+        esp_light_sleep_start();
+    }
 }
 // ARDUINO_ARCH_ESP32