@@ -9,7 +9,7 @@ There are two micro:bit board low power modes that can be requested from
99MicroPython:
1010
1111- **Deep Sleep **: Low power mode where the board can be woken up via
12- multiple sources (pins, button presses, or a timer) and resume
12+ multiple sources (pins, button presses, uart data, or a timer) and resume
1313 operation.
1414- **Off **: The power mode with the lowest power consumption, the only way to
1515 wake up the board is via the reset button, or by plugging the USB cable while
@@ -37,7 +37,7 @@ Functions
3737 will start running from the beginning.
3838
3939
40- .. py :function :: deep_sleep(ms = None , wake_on = None , run_every = False )
40+ .. py :function :: deep_sleep(ms = None , wake_on = None , run_every = True )
4141
4242 Set the micro:bit into a low power mode where it can wake up and continue
4343 operation.
@@ -49,16 +49,21 @@ Functions
4949
5050 The wake up sources are configured via arguments.
5151
52- If no wake up sources have been configured it will sleep until the reset
52+ The board will always wake up when receiving UART data, when the reset
5353 button is pressed (which resets the board) or, in battery power,
5454 when the USB cable is inserted.
5555
56+ When the ``run_every `` parameter is set to ``True `` (the default), any
57+ function scheduled with :py:meth: `microbit.run_every<microbit.run_every> `
58+ will momentarily wake up the board to run and when it finishes it will go
59+ back to sleep.
60+
5661 :param ms: A time in milliseconds to wait before it wakes up.
5762 :param wake_on: A single instance or a tuple of pins and/or buttons to
5863 wake up the board, e.g. ``deep_sleep(wake_on=button_a) `` or
5964 ``deep_sleep(wake_on=(pin0, pin2, button_b)) ``.
60- :param run_every: Set to `` True `` to wake up with each
61- ``microbit.run_every `` scheduled run.
65+ :param run_every: A boolean to configure if the functions scheduled with
66+ ``microbit.run_every `` will continue to run while it sleeps .
6267
6368Examples
6469========
@@ -124,3 +129,13 @@ the USB connection.
124129+------------------+-----------------+--------------------+
125130| **Off ** | 📴 Power Down | 📴 Power Down |
126131+------------------+-----------------+--------------------+
132+
133+ Deep Sleep & run_every
134+ ----------------------
135+
136+ To make sure the :py:meth: `microbit.run_every<microbit.run_every> `
137+ functions continue to run during "Deep Sleep", the micro:bit will wake up
138+ at the correct time to run the next scheduled ``run_every ``,
139+ and then go back to "Deep Sleep" mode as soon as that ``run_every `` completes.
140+ It will continue to do this until the deep sleep finishes due
141+ to the ``ms `` timeout being reached, or a ``wake_on `` event occurs.
0 commit comments