microbit-foundation / micropython-microbit-v2

Temporary home for MicroPython for micro:bit v2 as we stablise it before pushing upstream
MIT License
41 stars 22 forks source link

On battery this programme will sometimes wake up unexpectedly after a reset #133

Open microbit-carlos opened 1 year ago

microbit-carlos commented 1 year ago

This programme is meant to go to sleep right away and stay asleep until any of the "hidden" wake up sources (serial or USB insertion) wake it up.

from microbit import *
import power

@run_every(s=1)
def print_time():
    sleep(100)
    display.show([Image.HEART, Image.HEART_SMALL])

power.deep_sleep(run_every=False)

while True:
    display.show(Image.SURPRISED)
    sleep(500)

It seems to work fine when connected to my computer via USB, but on battery power, if you press the reset button enough times it will eventually not stay asleep and show the SURPRISED face and the run_every beating heart.

Interestingly, I haven't been able to replicate this if I remove the run_every function, or any of the two statements inside, but it might be that I haven't tried hard enough.

I'll see if I can replicate in CODAL, but logging here first in case it's something on the MicroPython side.

microbit-carlos commented 1 year ago

Okay, I was able to replicate this in CODAL when the MICROBIT_USB_SERIAL_WAKE config is used (as I have configured in PR https://github.com/microbit-foundation/micropython-microbit-v2/pull/132):