Skip to content

Scheduled calls from run_every are queued during sleep when deep_sleep(run_every=False) #131

@microbit-carlos

Description

@microbit-carlos

So a programme like this one, which purposely turns off the run_every events during sleep, will wake up and run the print_time() function 5 times in a row:

from microbit import *
import power

@run_every(s=3)
def print_time():
    print(running_time())
    display.show([Image.HEART, Image.HEART_SMALL])

while True:
    power.deep_sleep(15_000, run_every=False)

The heart animation can be seen 5 times, and this is printed to serial:

15182
15985
16789
17593
18397

I think in the occasions when deep_sleep is set up with run_every=False, we wouldn't expect the events to still be queued and all of them run when it wakes up, as the board might be put to sleep for long periods of time (for example, a data logging app that is meant to be deployed somewhere and start/stop logging when a button is pressed).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions