Skip to content

Commit 4485ec3

Browse files
authored
Merge pull request #2358 from cwilling/ext0wakeup
Add function deepSleepExt0
2 parents a41a550 + 2458fff commit 4485ec3

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

targets/esp32/jswrap_esp32.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,24 @@ void jswrap_ESP32_deepSleep(int us) {
8888
esp_deep_sleep_start(); // This function does not return.
8989
} // End of jswrap_ESP32_deepSleep
9090

91+
/*JSON{
92+
"type" : "staticmethod",
93+
"class" : "ESP32",
94+
"ifdef" : "ESP32",
95+
"name" : "deepSleepExt0",
96+
"generate" : "jswrap_ESP32_deepSleep_ext0",
97+
"params" : [
98+
["pin", "pin", "Pin to trigger wakeup"],
99+
["level", "int", "Logic level to trigger"]
100+
]
101+
}
102+
Put device in deepsleep state until interrupted by pin "pin".
103+
*/
104+
void jswrap_ESP32_deepSleep_ext0(Pin pin, int level) {
105+
esp_sleep_enable_ext0_wakeup(pin, level);
106+
esp_deep_sleep_start(); // This function does not return.
107+
} // End of jswrap_ESP32_deepSleep_ext0
108+
91109

92110
/*JSON{
93111
"type" : "staticmethod",

targets/esp32/jswrap_esp32.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ JsVar *jswrap_ESP32_getState();
2323
JsVar *jswrap_ESP32_setBoot(JsVar *jsPartitionName);
2424
void jswrap_ESP32_reboot();
2525
void jswrap_ESP32_deepSleep(int us);
26+
void jswrap_ESP32_deepSleep_ext0(Pin pin,int level);
2627
void jswrap_ESP32_setAtten(Pin pin,int atten);
2728

2829
#ifdef BLUETOOTH

0 commit comments

Comments
 (0)