Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
b637d39
Initial commit
gamblor21 Oct 25, 2020
12d770b
Added __probe_for_device
gamblor21 Oct 25, 2020
8a37983
Added doc and translations
gamblor21 Oct 26, 2020
9ec2245
Clean up
gamblor21 Oct 27, 2020
2374b0d
Fixed whitespace issues
gamblor21 Oct 27, 2020
90b9ec6
Initial Sleep Support
microdev1 Sep 18, 2020
3a30887
Update soft reboot message
microdev1 Sep 18, 2020
e310b87
Get io wake working
microdev1 Sep 19, 2020
05a3f20
Add function to get time elapsed during sleep
microdev1 Sep 22, 2020
21ba61a
Add function to disable alarm
microdev1 Sep 22, 2020
e5ff55b
Renamed alarm modules
microdev1 Sep 23, 2020
4d8ffdc
restructure alarm modules
microdev1 Sep 24, 2020
da44972
Fix build error
microdev1 Sep 24, 2020
59df1a1
Add alarm_touch module
microdev1 Sep 24, 2020
e359389
Add description of alarm modules
microdev1 Sep 24, 2020
930cf14
Add check for invalid io, function to disable all alarms
microdev1 Sep 26, 2020
0e444f0
Implement sleep on code.py exit
microdev1 Sep 30, 2020
354536c
Update translation
microdev1 Oct 7, 2020
1196d4b
move to new module
tannewt Oct 14, 2020
85dadf3
More API changes
tannewt Oct 15, 2020
9a4efed
Start tweaking the workflow to sleep
tannewt Oct 28, 2020
e7da852
Fixing review comments
gamblor21 Oct 29, 2020
78477a3
Initial SPI commit
gamblor21 Oct 31, 2020
5ea09fe
Fixed stubs
gamblor21 Oct 31, 2020
76c1153
Fixed stubs
gamblor21 Nov 1, 2020
7dd5380
Fixed stubs again
gamblor21 Nov 1, 2020
8bbbb28
Fixes from testing SPI
gamblor21 Nov 2, 2020
197539b
Moved I2CDevice and SPI to match python library
gamblor21 Nov 3, 2020
4c93db3
Renamed to adafruit_bus_device
gamblor21 Nov 4, 2020
03b110b
Add abort check in I2C lock
gamblor21 Nov 11, 2020
f61c4e6
Removing from smaller builds
gamblor21 Nov 11, 2020
23ed3ef
Removing frozen libs
gamblor21 Nov 11, 2020
bb77f1d
wip: initial code changes, starting from @tannewt's sleepio branch
dhalbert Nov 16, 2020
ffff02c
Merge remote-tracking branch 'adafruit/main' into sleep
dhalbert Nov 16, 2020
682054a
WIP: redo API; not compiled yet
dhalbert Nov 19, 2020
5bb3c32
merge from main
dhalbert Nov 19, 2020
649c930
wip
dhalbert Nov 19, 2020
cd436ba
Merge remote-tracking branch 'adafruit/main' into sleep
dhalbert Nov 19, 2020
39e1f52
wip; not compiling yet
dhalbert Nov 19, 2020
e4c6699
compiles
dhalbert Nov 21, 2020
75559f3
wip: ResetReason to microcontroller.cpu
dhalbert Nov 22, 2020
a0f1ec3
wip
dhalbert Nov 23, 2020
25591a3
Merge branch 'esp32s2-common-hal-mcu-delay-us' into sleep
dhalbert Nov 23, 2020
3abee9b
compiles; maybe ready to test, or almost
dhalbert Nov 23, 2020
7a45afc
working, but need to avoid deep sleeping too fast before USB ready
dhalbert Nov 24, 2020
f868cc5
some API renaming and bug fixes; fix docs
dhalbert Nov 25, 2020
9dbea36
changed alarm.time API
dhalbert Nov 25, 2020
ef0830b
merge from upstream + wip
dhalbert Nov 25, 2020
104a089
deep sleep working; deep sleep delay when connected
dhalbert Nov 27, 2020
e308a9e
working! PinAlarm not implemented yet.
dhalbert Nov 27, 2020
596e0e4
merge from upstream
dhalbert Nov 27, 2020
f96475c
update Requests; rolled back by accident
dhalbert Nov 27, 2020
65e2fe4
fix stub problems; touch up doc
dhalbert Nov 28, 2020
2830cc9
make translate
dhalbert Nov 28, 2020
28d9e91
Disable complex arithmetic on SAMD21 builds to make space
dhalbert Nov 28, 2020
4ac4faa
Use nina-fw root certs
tannewt Dec 1, 2020
9276244
Two minor socket changes
tannewt Dec 1, 2020
9a9e972
Ignore certificates readme in doc build
tannewt Dec 1, 2020
a95285a
Translated using Weblate (Polish)
szajakubiak Dec 1, 2020
f6cba4c
Translated using Weblate (Polish)
tawez Dec 1, 2020
44e0d98
Translated using Weblate (Polish)
szajakubiak Dec 1, 2020
2b9ca4d
Translated using Weblate (Polish)
tawez Dec 1, 2020
2373857
Merge branch 'main' into bus_device
gamblor21 Dec 1, 2020
d3bbb99
Fixing stubs
gamblor21 Dec 1, 2020
8b7c23c
address review comments
dhalbert Dec 2, 2020
fe1c2fa
Removed bus device from simmel build
gamblor21 Dec 2, 2020
72fa7d8
fix doc errors
dhalbert Dec 2, 2020
73e22f9
Block all tasks (not interrupts) during flash erase
tannewt Dec 2, 2020
cb863e4
Added to partial builds where frozen removed
gamblor21 Dec 2, 2020
1c00deb
Translated using Weblate (Polish)
tawez Dec 1, 2020
9e6b2b1
Translated using Weblate (Czech)
vkuthan Dec 1, 2020
d7ba641
Merge pull request #3767 from dhalbert/sleep
tannewt Dec 2, 2020
8f6baa2
Merge branch 'origin/main' into Weblate.
weblate Dec 2, 2020
7655102
Update translation files
weblate Dec 2, 2020
31acfed
Merge pull request #3780 from tannewt/block_while_erasing
dhalbert Dec 2, 2020
51fd678
Merge branch 'origin/main' into Weblate.
weblate Dec 2, 2020
9b3186b
Merge pull request #3776 from tannewt/backup_socket_timeout
dhalbert Dec 2, 2020
c7749a5
Merge branch 'origin/main' into Weblate.
weblate Dec 2, 2020
348392f
Merge pull request #3775 from tannewt/nina_certs
dhalbert Dec 2, 2020
a483cd1
Merge branch 'origin/main' into Weblate.
weblate Dec 2, 2020
1130b80
Merge pull request #3612 from gamblor21/bus_device
tannewt Dec 2, 2020
079bf7a
Merge branch 'origin/main' into Weblate.
weblate Dec 2, 2020
03d0ec8
Update translation files
weblate Dec 2, 2020
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
Prev Previous commit
Next Next commit
WIP: redo API; not compiled yet
  • Loading branch information
dhalbert committed Nov 19, 2020
commit 682054a2169c108ad69e84acdb53fdd26405077e
8 changes: 5 additions & 3 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-11-04 21:18+0530\n"
"POT-Creation-Date: 2020-11-19 00:22-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -303,7 +303,8 @@ msgstr ""
msgid "All I2C peripherals are in use"
msgstr ""

#: ports/esp32s2/peripherals/pcnt_handler.c
#: ports/esp32s2/common-hal/countio/Counter.c
#: ports/esp32s2/common-hal/rotaryio/IncrementalEncoder.c
msgid "All PCNT units in use"
msgstr ""

Expand Down Expand Up @@ -3221,6 +3222,7 @@ msgstr ""
msgid "pow() with 3 arguments requires integers"
msgstr ""

#: ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h
#: ports/esp32s2/boards/adafruit_metro_esp32s2/mpconfigboard.h
#: ports/esp32s2/boards/electroniccats_bastwifi/mpconfigboard.h
#: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h
Expand Down Expand Up @@ -3328,7 +3330,7 @@ msgstr ""
msgid "size is defined for ndarrays only"
msgstr ""

#: shared-bindings/alarm_time/__init__.c shared-bindings/time/__init__.c
#: shared-bindings/time/__init__.c
msgid "sleep length must be non-negative"
msgstr ""

Expand Down
3 changes: 0 additions & 3 deletions ports/esp32s2/mpconfigport.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ LONGINT_IMPL = MPZ
# These modules are implemented in ports/<port>/common-hal:
CIRCUITPY_FULL_BUILD = 1
CIRCUITPY_ALARM = 1
CIRCUITPY_ALARM_IO = 1
CIRCUITPY_ALARM_TIME = 1
CIRCUITPY_ALARM_TOUCH = 1
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_AUDIOIO = 0
CIRCUITPY_CANIO = 1
Expand Down
22 changes: 5 additions & 17 deletions py/circuitpy_defns.mk
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,6 @@ endif
ifeq ($(CIRCUITPY_ALARM),1)
SRC_PATTERNS += alarm/%
endif
ifeq ($(CIRCUITPY_ALARM_IO),1)
SRC_PATTERNS += alarm_io/%
endif
ifeq ($(CIRCUITPY_ALARM_TIME),1)
SRC_PATTERNS += alarm_time/%
endif
ifeq ($(CIRCUITPY_ALARM_TOUCH),1)
SRC_PATTERNS += alarm_touch/%
endif
ifeq ($(CIRCUITPY_ANALOGIO),1)
SRC_PATTERNS += analogio/%
endif
Expand Down Expand Up @@ -247,9 +238,6 @@ endif
ifeq ($(CIRCUITPY_SHARPDISPLAY),1)
SRC_PATTERNS += sharpdisplay/%
endif
ifeq ($(CIRCUITPY_SLEEP),1)
SRC_PATTERNS += sleep/%
endif
ifeq ($(CIRCUITPY_SOCKETPOOL),1)
SRC_PATTERNS += socketpool/%
endif
Expand Down Expand Up @@ -314,9 +302,9 @@ SRC_COMMON_HAL_ALL = \
_pew/PewPew.c \
_pew/__init__.c \
alarm/__init__.c \
alarm_io/__init__.c \
alarm_time/__init__.c \
alarm_touch/__init__.c \
alarm/pin/__init__.c \
alarm/time/__init__.c \
alarm/touch/__init__.c \
analogio/AnalogIn.c \
analogio/AnalogOut.c \
analogio/__init__.c \
Expand Down Expand Up @@ -372,8 +360,8 @@ SRC_COMMON_HAL_ALL = \
rtc/__init__.c \
sdioio/SDCard.c \
sdioio/__init__.c \
sleep/__init__.c \
sleep/ResetReason.c \
sleepio/__init__.c \
sleepio/ResetReason.c \
socketpool/__init__.c \
socketpool/SocketPool.c \
socketpool/Socket.c \
Expand Down
32 changes: 0 additions & 32 deletions py/circuitpy_mpconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,27 +250,6 @@ extern const struct _mp_obj_module_t alarm_module;
#define ALARM_MODULE
#endif

#if CIRCUITPY_ALARM_IO
extern const struct _mp_obj_module_t alarm_io_module;
#define ALARM_IO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm_io), (mp_obj_t)&alarm_io_module },
#else
#define ALARM_IO_MODULE
#endif

#if CIRCUITPY_ALARM_TIME
extern const struct _mp_obj_module_t alarm_time_module;
#define ALARM_TIME_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm_time), (mp_obj_t)&alarm_time_module },
#else
#define ALARM_TIME_MODULE
#endif

#if CIRCUITPY_ALARM_TOUCH
extern const struct _mp_obj_module_t alarm_touch_module;
#define ALARM_TOUCH_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_alarm_touch), (mp_obj_t)&alarm_touch_module },
#else
#define ALARM_TOUCH_MODULE
#endif

#if CIRCUITPY_ANALOGIO
#define ANALOGIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module },
extern const struct _mp_obj_module_t analogio_module;
Expand Down Expand Up @@ -642,13 +621,6 @@ extern const struct _mp_obj_module_t sharpdisplay_module;
#define SHARPDISPLAY_MODULE
#endif

#if CIRCUITPY_SLEEP
extern const struct _mp_obj_module_t sleep_module;
#define SLEEP_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_sleep),(mp_obj_t)&sleep_module },
#else
#define SLEEP_MODULE
#endif

#if CIRCUITPY_SOCKETPOOL
extern const struct _mp_obj_module_t socketpool_module;
#define SOCKETPOOL_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_socketpool), (mp_obj_t)&socketpool_module },
Expand Down Expand Up @@ -807,9 +779,6 @@ extern const struct _mp_obj_module_t wifi_module;
#define MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS \
AESIO_MODULE \
ALARM_MODULE \
ALARM_IO_MODULE \
ALARM_TIME_MODULE \
ALARM_TOUCH_MODULE \
ANALOGIO_MODULE \
AUDIOBUSIO_MODULE \
AUDIOCORE_MODULE \
Expand Down Expand Up @@ -862,7 +831,6 @@ extern const struct _mp_obj_module_t wifi_module;
SDCARDIO_MODULE \
SDIOIO_MODULE \
SHARPDISPLAY_MODULE \
SLEEP_MODULE \
SOCKETPOOL_MODULE \
SSL_MODULE \
STAGE_MODULE \
Expand Down
20 changes: 6 additions & 14 deletions py/circuitpy_mpconfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,15 @@ CFLAGS += -DMICROPY_PY_ASYNC_AWAIT=$(MICROPY_PY_ASYNC_AWAIT)
CIRCUITPY_AESIO ?= 0
CFLAGS += -DCIRCUITPY_AESIO=$(CIRCUITPY_AESIO)

# TODO: CIRCUITPY_ALARM will gradually be added to
# as many ports as possible
# so make this 1 or CIRCUITPY_FULL_BUILD eventually
CIRCUITPY_SLEEPIO ?= 0
CFLAGS += -DCIRCUITPY_SLEEPIO=$(CIRCUITPY_SLEEPIO)

CIRCUITPY_ALARM ?= 0
CFLAGS += -DCIRCUITPY_ALARM=$(CIRCUITPY_ALARM)

CIRCUITPY_ALARM_IO ?= 0
CFLAGS += -DCIRCUITPY_ALARM_IO=$(CIRCUITPY_ALARM_IO)

CIRCUITPY_ALARM_TIME ?= 0
CFLAGS += -DCIRCUITPY_ALARM_TIME=$(CIRCUITPY_ALARM_TIME)

CIRCUITPY_ALARM_TOUCH ?= 0
CFLAGS += -DCIRCUITPY_ALARM_TOUCH=$(CIRCUITPY_ALARM_TOUCH)

CIRCUITPY_ANALOGIO ?= 1
CFLAGS += -DCIRCUITPY_ANALOGIO=$(CIRCUITPY_ANALOGIO)

Expand Down Expand Up @@ -221,11 +218,6 @@ CFLAGS += -DCIRCUITPY_SDIOIO=$(CIRCUITPY_SDIOIO)
CIRCUITPY_SHARPDISPLAY ?= $(CIRCUITPY_FRAMEBUFFERIO)
CFLAGS += -DCIRCUITPY_SHARPDISPLAY=$(CIRCUITPY_SHARPDISPLAY)

# TODO: CIRCUITPY_SLEEP will gradually be added to all ports
# even if it doesn't actually sleep, so make this 1 eventually.
CIRCUITPY_SLEEP ?= 0
CFLAGS += -DCIRCUITPY_SLEEP=$(CIRCUITPY_SLEEP)

CIRCUITPY_SOCKETPOOL ?= $(CIRCUITPY_WIFI)
CFLAGS += -DCIRCUITPY_SOCKETPOOL=$(CIRCUITPY_SOCKETPOOL)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@

#include "py/enum.h"

#include "shared-bindings/sleep/ResetReason.h"
#include "shared-bindings/alarm/ResetReason.h"

MAKE_ENUM_VALUE(sleep_reset_reason_type, reset_reason, POWER_VALID, RESET_REASON_POWER_VALID);
MAKE_ENUM_VALUE(sleep_reset_reason_type, reset_reason, SOFTWARE, RESET_REASON_SOFTWARE);
MAKE_ENUM_VALUE(sleep_reset_reason_type, reset_reason, DEEP_SLEEP_ALARM, RESET_REASON_DEEP_SLEEP_ALARM);
MAKE_ENUM_VALUE(sleep_reset_reason_type, reset_reason, EXTERNAL, RESET_REASON_EXTERNAL);
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, POWER_VALID, RESET_REASON_POWER_VALID);
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, SOFTWARE, RESET_REASON_SOFTWARE);
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, DEEP_SLEEP_ALARM, RESET_REASON_DEEP_SLEEP_ALARM);
MAKE_ENUM_VALUE(alarm_reset_reason_type, reset_reason, EXTERNAL, RESET_REASON_EXTERNAL);

//| class ResetReason:
//| """The reason the chip was last reset"""
Expand All @@ -48,14 +48,14 @@ MAKE_ENUM_VALUE(sleep_reset_reason_type, reset_reason, EXTERNAL, RESET_REASON_EX
//| EXTERNAL: object
//| """The chip was reset by an external input such as a button."""
//|
MAKE_ENUM_MAP(sleep_reset_reason) {
MAKE_ENUM_MAP(alarm_reset_reason) {
MAKE_ENUM_MAP_ENTRY(reset_reason, POWER_VALID),
MAKE_ENUM_MAP_ENTRY(reset_reason, SOFTWARE),
MAKE_ENUM_MAP_ENTRY(reset_reason, DEEP_SLEEP_ALARM),
MAKE_ENUM_MAP_ENTRY(reset_reason, EXTERNAL),
};
STATIC MP_DEFINE_CONST_DICT(sleep_reset_reason_locals_dict, sleep_reset_reason_locals_table);
STATIC MP_DEFINE_CONST_DICT(alarm_reset_reason_locals_dict, alarm_reset_reason_locals_table);

MAKE_PRINTER(sleep, sleep_reset_reason);
MAKE_PRINTER(alarm, alarm_reset_reason);

MAKE_ENUM_TYPE(sleep, ResetReason, sleep_reset_reason);
MAKE_ENUM_TYPE(alarm, ResetReason, alarm_reset_reason);
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
* THE SOFTWARE.
*/

#pragma once
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H
#define MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H

typedef enum {
RESET_REASON_POWER_APPLIED,
RESET_REASON_SOFTWARE,
RESET_REASON_DEEP_SLEEP_ALARM,
RESET_REASON_BUTTON,
} sleep_reset_reason_t;
} alarm_reset_reason_t;

extern const mp_obj_type_t sleep_reset_reason_type;
extern const mp_obj_type_t alarm_reset_reason_type;

#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM__RESET_REASON__H
130 changes: 130 additions & 0 deletions shared-bindings/alarm/__init__.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
//| """Power-saving light and deep sleep. Alarms can be set to wake up from sleep.
//|
//| The `alarm` module provides sleep related functionality. There are two supported levels of
//| sleep, light and deep.
//|
//| Light sleep leaves the CPU and RAM powered so that CircuitPython can resume where it left off
//| after being woken up. CircuitPython automatically goes into a light sleep when `time.sleep()` is
//| called. To light sleep until a non-time alarm use `alarm.sleep_until_alarm()`. Any active
//| peripherals, such as I2C, are left on.
//|
//| Deep sleep shuts down power to nearly all of the chip including the CPU and RAM. This can save
//| a more significant amount of power, but CircuitPython must start ``code.py`` from the beginning when woken
//| up. CircuitPython will enter deep sleep automatically when the current program exits without error
//| or calls `sys.exit(0)`.
//| If an error causes CircuitPython to exit, error LED error flashes will be done periodically.
//| An error includes an uncaught exception, or sys.exit called with a non-zero argumetn.
//| To set alarms for deep sleep use `alarm.reload_on_alarm()` they will apply to next deep sleep only."""
//|

//| wake_alarm: Alarm
//| """The most recent alarm to wake us up from a sleep (light or deep.)"""
//|

//| reset_reason: ResetReason
//| """The reason the chip started up from reset state. This can may be power up or due to an alarm."""
//|

//| def sleep(alarm: Alarm, ...) -> Alarm:
//| """Performs a light sleep until woken by one of the alarms. The alarm that triggers the wake
//| is returned, and is also available as `alarm.wake_alarm`
//| ...
//|

#include "py/obj.h"
#include "py/runtime.h"

#include "shared-bindings/alarm/pin/__init__.h"
#include "shared-bindings/alarm/time/__init__.h"

STATIC mp_obj_t alarm_sleep_until_alarm(size_t n_args, const mp_obj_t *args) {
// TODO
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_sleep_until_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_sleep_until_alarm);

//| def restart_on_alarm(alarm: Alarm, ...) -> None:
//| """Set one or more alarms to wake up from a deep sleep.
//| When awakened, ``code.py`` will restart from the beginning.
//| The last alarm to wake us up is available as `wake_alarm`.
//| """
//| ...
//|
STATIC mp_obj_t alarm_restart_on_alarm(size_t n_args, const mp_obj_t *args) {
// TODO
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_restart_on_alarm_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_restart_on_alarm);

//| """The `alarm.pin` module contains alarm attributes and classes related to pins
//| """
//|
mp_map_elem_t alarm_pin_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_pin) },

{ MP_ROM_QSTR(MP_QSTR_PinAlarm), MP_ROM_PTR(&alarm_pin_pin_alarm_type) },
};

STATIC MP_DEFINE_CONST_DICT(alarm_pin_globals, alarm_pin_globals_table);

const mp_obj_module_t alarm_pin_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&alarm_pinn_globals,
};

//| """The `alarm.time` module contains alarm attributes and classes related to time-keeping.
//| """
//|
mp_map_elem_t alarm_time_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_time) },

{ MP_ROM_QSTR(MP_QSTR_DurationAlarm), MP_ROM_PTR(&alarm_time_duration_alarm_type) },
};

STATIC MP_DEFINE_CONST_DICT(alarm_time_globals, alarm_time_globals_table);

const mp_obj_module_t alarm_time_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&alarm_time_globals,
};

mp_map_elem_t alarm_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alarm) },

// wake_alarm and reset_reason are mutable attributes.
{ MP_ROM_QSTR(MP_QSTR_wake_alarm), mp_const_none },
{ MP_ROM_QSTR(MP_QSTR_reset_reason), mp_const_none },

{ MP_ROM_QSTR(MP_QSTR_sleep_until_alarm), MP_ROM_PTR(&alarm_sleep_until_alarm_obj) },
{ MP_ROM_QSTR(MP_QSTR_restart_on_alarm), MP_ROM_PTR(&alarm_restart_on_alarm_obj) },

{ MP_ROM_QSTR(MP_QSTR_pin), MP_ROM_PTR(&alarm_pin_module) },
{ MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&alarm_time_module) }

};
STATIC MP_DEFINE_MUTABLE_DICT(alarm_module_globals, alarm_module_globals_table);

// These are called from common_hal code to set the current wake alarm.
void common_hal_alarm_set_wake_alarm(mp_obj_t alarm) {
// Equivalent of:
// alarm.wake_alarm = alarm
mp_map_elem_t *elem =
mp_map_lookup(&alarm_module_globals_table, MP_ROM_QSTR(MP_QSTR_wake_alarm), MP_MAP_LOOKUP);
if (elem) {
elem->value = alarm;
}
}

// These are called from common hal code to set the current wake alarm.
void common_hal_alarm_set_reset_reason(mp_obj_t reset_reason) {
// Equivalent of:
// alarm.reset_reason = reset_reason
mp_map_elem_t *elem =
mp_map_lookup(&alarm_module_globals_table, MP_ROM_QSTR(MP_QSTR_reset_reason), MP_MAP_LOOKUP);
if (elem) {
elem->value = reset_reason;
}
}

const mp_obj_module_t alarm_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&alarm_module_globals,
};
Loading