Skip to content

Commit 59df1a1

Browse files
microdev1tannewt
authored andcommitted
Add alarm_touch module
1 parent da44972 commit 59df1a1

File tree

15 files changed

+83
-31
lines changed

15 files changed

+83
-31
lines changed

ports/esp32s2/common-hal/alarm/__init__.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ mp_obj_t common_hal_alarm_get_wake_alarm(void) {
3636
case ESP_SLEEP_WAKEUP_TIMER: ;
3737
//Wake up from timer.
3838
alarm_time_obj_t *timer = m_new_obj(alarm_time_obj_t);
39-
timer->base.type = &alarm_time_type;
39+
timer->base.type = &alarm_time_type;
4040
return timer;
4141
case ESP_SLEEP_WAKEUP_EXT0: ;
4242
//Wake up from GPIO
4343
alarm_io_obj_t *ext0 = m_new_obj(alarm_io_obj_t);
44-
ext0->base.type = &alarm_io_type;
45-
return ext0;
46-
case ESP_SLEEP_WAKEUP_TOUCHPAD:
44+
ext0->base.type = &alarm_io_type;
45+
return ext0;
46+
case ESP_SLEEP_WAKEUP_TOUCHPAD:
4747
//TODO: implement TouchIO
4848
//Wake up from touch on pad, esp_sleep_get_touchpad_wakeup_status()
49-
break;
49+
break;
5050
case ESP_SLEEP_WAKEUP_UNDEFINED:
5151
default:
5252
//Not a deep sleep reset

ports/esp32s2/common-hal/alarm_io/__init__.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55

66
mp_obj_t common_hal_alarm_io_pin_state (alarm_io_obj_t *self_in) {
77
if (!rtc_gpio_is_valid_gpio(self_in->gpio)) {
8-
mp_raise_ValueError(translate("io must be rtc io"));
9-
}
8+
mp_raise_ValueError(translate("io must be rtc io"));
9+
}
1010

1111
switch(esp_sleep_enable_ext0_wakeup(self_in->gpio, self_in->level)) {
1212
case ESP_ERR_INVALID_ARG:
1313
mp_raise_ValueError(translate("trigger level must be 0 or 1"));
1414
case ESP_ERR_INVALID_STATE:
1515
mp_raise_RuntimeError(translate("wakeup conflict"));
16-
default:
17-
break;
16+
default:
17+
break;
1818
}
1919

2020
if (self_in->pull) { (self_in->level) ? rtc_gpio_pulldown_en(self_in->gpio) : rtc_gpio_pullup_en(self_in->gpio); }
2121

22-
return self_in;
23-
}
22+
return self_in;
23+
}
2424

2525
void common_hal_alarm_io_disable (void) {
2626
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_EXT0 | ESP_SLEEP_WAKEUP_EXT1);

ports/esp32s2/common-hal/alarm_time/__init__.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
void common_hal_alarm_time_duration (uint32_t ms) {
66
if (esp_sleep_enable_timer_wakeup((ms) * 1000) == ESP_ERR_INVALID_ARG) {
77
mp_raise_ValueError(translate("time out of range"));
8-
}
9-
}
8+
}
9+
}
1010

1111
void common_hal_alarm_time_disable (void) {
1212
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "esp_sleep.h"
2+
3+
#include "shared-bindings/alarm_touch/__init__.h"
4+
5+
void common_hal_alarm_touch_disable (void) {
6+
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TOUCHPAD);
7+
}

ports/esp32s2/common-hal/microcontroller/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void common_hal_mcu_reset(void) {
8080
}
8181

8282
void common_hal_mcu_sleep(void) {
83-
esp_deep_sleep_start();
83+
esp_deep_sleep_start();
8484
}
8585

8686
// The singleton microcontroller.Processor object, bound to microcontroller.cpu

ports/esp32s2/mpconfigport.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ CIRCUITPY_FULL_BUILD = 1
1717
CIRCUITPY_ALARM = 1
1818
CIRCUITPY_ALARM_IO = 1
1919
CIRCUITPY_ALARM_TIME = 1
20+
CIRCUITPY_ALARM_TOUCH = 1
2021
CIRCUITPY_AUDIOBUSIO = 0
2122
CIRCUITPY_AUDIOIO = 0
2223
CIRCUITPY_CANIO = 1

ports/esp32s2/supervisor/port.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ safe_mode_t port_init(void) {
8686
if (heap == NULL) {
8787
return NO_HEAP;
8888
}
89-
89+
9090
return NO_SAFE_MODE;
9191
}
9292

py/circuitpy_defns.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ endif
108108
ifeq ($(CIRCUITPY_ALARM_TIME),1)
109109
SRC_PATTERNS += alarm_time/%
110110
endif
111+
ifeq ($(CIRCUITPY_ALARM_TIME),1)
112+
SRC_PATTERNS += alarm_touch/%
113+
endif
111114
ifeq ($(CIRCUITPY_ANALOGIO),1)
112115
SRC_PATTERNS += analogio/%
113116
endif
@@ -310,6 +313,7 @@ SRC_COMMON_HAL_ALL = \
310313
alarm/__init__.c \
311314
alarm_io/__init__.c \
312315
alarm_time/__init__.c \
316+
alarm_touch/__init__.c \
313317
analogio/AnalogIn.c \
314318
analogio/AnalogOut.c \
315319
analogio/__init__.c \

py/circuitpy_mpconfig.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,13 @@ extern const struct _mp_obj_module_t alarm_time_module;
261261
#define ALARM_TIME_MODULE
262262
#endif
263263

264+
#if CIRCUITPY_ALARM_TOUCH
265+
extern const struct _mp_obj_module_t alarm_touch_module;
266+
#define ALARM_TOUCH_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm_touch), (mp_obj_t)&alarm_touch_module },
267+
#else
268+
#define ALARM_TOUCH_MODULE
269+
#endif
270+
264271
#if CIRCUITPY_ANALOGIO
265272
#define ANALOGIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module },
266273
extern const struct _mp_obj_module_t analogio_module;
@@ -787,6 +794,7 @@ extern const struct _mp_obj_module_t wifi_module;
787794
ALARM_MODULE \
788795
ALARM_IO_MODULE \
789796
ALARM_TIME_MODULE \
797+
ALARM_TOUCH_MODULE \
790798
ANALOGIO_MODULE \
791799
AUDIOBUSIO_MODULE \
792800
AUDIOCORE_MODULE \

py/circuitpy_mpconfig.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ CFLAGS += -DCIRCUITPY_ALARM_IO=$(CIRCUITPY_ALARM_IO)
4848
CIRCUITPY_ALARM_TIME ?= 0
4949
CFLAGS += -DCIRCUITPY_ALARM_TIME=$(CIRCUITPY_ALARM_TIME)
5050

51+
CIRCUITPY_ALARM_TOUCH ?= 0
52+
CFLAGS += -DCIRCUITPY_ALARM_TOUCH=$(CIRCUITPY_ALARM_TOUCH)
53+
5154
CIRCUITPY_ANALOGIO ?= 1
5255
CFLAGS += -DCIRCUITPY_ANALOGIO=$(CIRCUITPY_ANALOGIO)
5356

0 commit comments

Comments
 (0)