Answering my own question. This was trivially simple in my code. My code was doing deep sleep in the setup()
function. When waking up from deep-sleep the setup function is called again. But if the device is powered by USB then deep sleep fails and we will reach the loop()
function. So any special code that I want for USB power should simply be put in loop()
.
Posts made by dov
-
RE: How to test if the M5Paper is attached to USB power?
-
How to do partial refresh of the M5paper screen after deep sleep wakeup
After waking up after deep sleep, I'd like to update part of the screen. But I found that after wakeup that if I don't do
M5.EPD.Clear(true)
no other canvas commands work. Am I missing something? Does anyone have an example of how to to do apush_canvas()
on a part of the screen after wakeup, without the need to redraw the entire screen? -
How to test if the M5Paper is attached to USB power?
I'd like to have different behavior whether the M5paper is running of USB power or battery. I guess I can just try to go to sleep and if it "fails" and I reached the next statement, the I'm on USB power (since you never deep sleep when connected). But is there a more direct way?
-
M5Paper wakeup cause
Hello,
I'm playing around with the M5Paper RTC and I'm stuck on differentiating between a restart caused by pressing the reset button, and a restart caused by a
shutdown()
with a RTC IRQ wakeup.I'm writing a simple clock application that updates once a minute with the following properties:
- On boot I paint a decorative frame (I actually pull it by http), connect to ntp and setup the RTC clock. Finally I draw the time, and do a
shutdown(60)
to wake up in a minute. - After a minute I want to wake up, draw the time, and go back to sleep.
So I did all the initialization in
setup()
and initialized the RTC, setup the font cache, and then went to sleep for 60s. But when I wake up after 60s I need to know whether the RTC has already been initialized, and whether I have already painted the clock frame. Right now I do all the setup once a minute.The ESP itself has a wake up "reason". But how would I access it on the M5Paper? And does it work in the context of the BM8563 RTC?
Thanks!
- On boot I paint a decorative frame (I actually pull it by http), connect to ntp and setup the RTC clock. Finally I draw the time, and do a