Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function deepSleepExt0 #2358

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions targets/esp32/jswrap_esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions targets/esp32/jswrap_esp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down