By design, at wake up from deepsleep, the RTC timer will be reset, but
the data stored in RTC memory will not [1]. Therefore, we have to adjust
delta in RTC memory before going into deepsleep to get almost correct
time after waking up.
[1] http://bbs.espressif.com/viewtopic.php?t=1184#p4082
Use the machine.deepsleep() function to enter the sleep mode. Use the
RTC to configure the alarm to wake the device.
Basic use is the following:
import machine
# configure RTC's ALARM0 to wake device from deep sleep
rtc = machine.RTC()
rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)
# do other things
# ...
# set ALARM0's alarm to wake after 10 seconds
rtc.alarm(rtc.ALARM0, 10000)
# enter deep-sleep state (system is reset upon waking)
machine.deepsleep()
To detect if the system woke from a deep sleep use:
if machine.reset_cause() == machine.DEEPSLEEP_RESET:
print('woke from deep sleep')
This patch consolidates all global variables in py/ core into one place,
in a global structure. Root pointers are all located together to make
GC tracing easier and more efficient.
Blanket wide to all .c and .h files. Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.
Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
By default mingw outputs 3 digits instead of the standard 2 so all float
tests using printf fail. Using setenv at the start of the program fixes this.
To accomodate calling platform specific initialization a
MICROPY_MAIN_INIT_FUNC macro is used which is called in mp_init()