From 2458fffa3900ca1a4b35eacdd6eabe500b229321 Mon Sep 17 00:00:00 2001 From: Christoph Willing Date: Tue, 9 May 2023 13:05:19 +1000 Subject: [PATCH] Add function deepSleepExt0 Signed-off-by: Christoph Willing --- targets/esp32/jswrap_esp32.c | 18 ++++++++++++++++++ targets/esp32/jswrap_esp32.h | 1 + 2 files changed, 19 insertions(+) diff --git a/targets/esp32/jswrap_esp32.c b/targets/esp32/jswrap_esp32.c index 0e17251bdd..c564df28d8 100644 --- a/targets/esp32/jswrap_esp32.c +++ b/targets/esp32/jswrap_esp32.c @@ -88,6 +88,24 @@ void jswrap_ESP32_deepSleep(int us) { esp_deep_sleep_start(); // This function does not return. } // End of jswrap_ESP32_deepSleep +/*JSON{ + "type" : "staticmethod", + "class" : "ESP32", + "ifdef" : "ESP32", + "name" : "deepSleepExt0", + "generate" : "jswrap_ESP32_deepSleep_ext0", + "params" : [ + ["pin", "pin", "Pin to trigger wakeup"], + ["level", "int", "Logic level to trigger"] + ] +} +Put device in deepsleep state until interrupted by pin "pin". +*/ +void jswrap_ESP32_deepSleep_ext0(Pin pin, int level) { + esp_sleep_enable_ext0_wakeup(pin, level); + esp_deep_sleep_start(); // This function does not return. +} // End of jswrap_ESP32_deepSleep_ext0 + /*JSON{ "type" : "staticmethod", diff --git a/targets/esp32/jswrap_esp32.h b/targets/esp32/jswrap_esp32.h index 8cadca2258..96356139af 100644 --- a/targets/esp32/jswrap_esp32.h +++ b/targets/esp32/jswrap_esp32.h @@ -23,6 +23,7 @@ JsVar *jswrap_ESP32_getState(); JsVar *jswrap_ESP32_setBoot(JsVar *jsPartitionName); void jswrap_ESP32_reboot(); void jswrap_ESP32_deepSleep(int us); +void jswrap_ESP32_deepSleep_ext0(Pin pin,int level); void jswrap_ESP32_setAtten(Pin pin,int atten); #ifdef BLUETOOTH