diff options
| author | microDev <70126934+microDev1@users.noreply.github.com> | 2020-09-22 23:45:38 +0530 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2020-10-27 16:13:25 -0700 |
| commit | 05a3f203dbaf53fbccd97395a90d025f2d3b9dc2 (patch) | |
| tree | 1785b5baf0fb811765eedd8f7417cf0b1d9bb94c /shared-bindings/microcontroller/__init__.c | |
| parent | e310b871c8eb8cf924e6937edc7cd51a2be1a6b7 (diff) | |
Add function to get time elapsed during sleep
Diffstat (limited to 'shared-bindings/microcontroller/__init__.c')
| -rw-r--r-- | shared-bindings/microcontroller/__init__.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index b8ca8f18b..7b896d99b 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -152,6 +152,24 @@ STATIC mp_obj_t mcu_sleep(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_sleep_obj, mcu_sleep); +//| def getWakeAlarm() -> None: +//| """This returns the alarm that triggered wakeup, +//| also returns alarm specific parameters`. +//| +STATIC mp_obj_t mcu_get_wake_alarm(void) { + return common_hal_mcu_get_wake_alarm(); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_get_wake_alarm_obj, mcu_get_wake_alarm); + +//| def getSleepTime() -> None: +//| """This returns the period of time in ms, +//| in which the board was in deep sleep`. +//| +STATIC mp_obj_t mcu_get_sleep_time(void) { + return mp_obj_new_int(common_hal_mcu_get_sleep_time()); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_get_sleep_time_obj, mcu_get_sleep_time); + //| nvm: Optional[ByteArray] //| """Available non-volatile memory. //| This object is the sole instance of `nvm.ByteArray` when available or ``None`` otherwise. @@ -188,6 +206,8 @@ STATIC const mp_rom_map_elem_t mcu_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_on_next_reset), MP_ROM_PTR(&mcu_on_next_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&mcu_reset_obj) }, { MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mcu_sleep_obj) }, + { MP_ROM_QSTR(MP_QSTR_getSleepTime), MP_ROM_PTR(&mcu_get_sleep_time_obj) }, + { MP_ROM_QSTR(MP_QSTR_getWakeAlarm), MP_ROM_PTR(&mcu_get_wake_alarm_obj) }, #if CIRCUITPY_INTERNAL_NVM_SIZE > 0 { MP_ROM_QSTR(MP_QSTR_nvm), MP_ROM_PTR(&common_hal_mcu_nvm_obj) }, #else |
