Skip to content

Commit 0375cdc

Browse files
committed
esp32/modmachine.c Added ext0, ext1, touch wake functionality
1 parent 4ff1926 commit 0375cdc

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

ports/esp32/modmachine.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "freertos/task.h"
3535
#include "rom/ets_sys.h"
3636
#include "esp_system.h"
37+
#include "driver/touch_pad.h"
3738

3839
#include "py/obj.h"
3940
#include "py/runtime.h"
@@ -43,11 +44,12 @@
4344
#include "extmod/machine_i2c.h"
4445
#include "extmod/machine_spi.h"
4546
#include "modmachine.h"
47+
#include "machine_rtc.h"
4648

4749
#if MICROPY_PY_MACHINE
4850

4951
// amount of time to sleep
50-
extern uint64_t machine_rtc_expiry;
52+
extern machine_rtc_config_t machine_rtc_config;
5153
#define MACHINE_WAKE_DEEPSLEEP (0x04)
5254

5355
STATIC mp_obj_t machine_freq(size_t n_args, const mp_obj_t *args) {
@@ -69,9 +71,26 @@ STATIC mp_obj_t machine_freq(size_t n_args, const mp_obj_t *args) {
6971
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_freq_obj, 0, 1, machine_freq);
7072

7173
STATIC mp_obj_t machine_deepsleep(void) {
72-
if (machine_rtc_expiry != 0) {
73-
esp_deep_sleep_enable_timer_wakeup(machine_rtc_expiry);
74+
75+
if (machine_rtc_config.expiry != 0) {
76+
esp_deep_sleep_enable_timer_wakeup(machine_rtc_config.expiry);
77+
}
78+
79+
if (machine_rtc_config.ext0_pin != -1) {
80+
esp_deep_sleep_enable_ext0_wakeup(machine_rtc_config.ext0_pin, machine_rtc_config.ext0_level ? 1 : 0);
81+
}
82+
83+
if (machine_rtc_config.ext1_pins != 0) {
84+
esp_deep_sleep_enable_ext1_wakeup(
85+
machine_rtc_config.ext1_pins,
86+
machine_rtc_config.ext1_level ? ESP_EXT1_WAKEUP_ANY_HIGH : ESP_EXT1_WAKEUP_ALL_LOW);
87+
}
88+
89+
if (machine_rtc_config.wake_on_touch) {
90+
// esp_deep_sleep_enable_touchpad_wakeup();
91+
nlr_raise(mp_obj_new_exception_msg(&mp_type_RuntimeError, "touchpad wakeup not available for this version of ESP-IDF"));
7492
}
93+
7594
esp_deep_sleep_start();
7695
return mp_const_none;
7796
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy