@@ -9,7 +9,7 @@ There are two micro:bit board low power modes that can be requested from
9
9
MicroPython:
10
10
11
11
- **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
13
13
operation.
14
14
- **Off **: The power mode with the lowest power consumption, the only way to
15
15
wake up the board is via the reset button, or by plugging the USB cable while
@@ -37,7 +37,7 @@ Functions
37
37
will start running from the beginning.
38
38
39
39
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 )
41
41
42
42
Set the micro:bit into a low power mode where it can wake up and continue
43
43
operation.
@@ -49,16 +49,21 @@ Functions
49
49
50
50
The wake up sources are configured via arguments.
51
51
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
53
53
button is pressed (which resets the board) or, in battery power,
54
54
when the USB cable is inserted.
55
55
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
+
56
61
:param ms: A time in milliseconds to wait before it wakes up.
57
62
:param wake_on: A single instance or a tuple of pins and/or buttons to
58
63
wake up the board, e.g. ``deep_sleep(wake_on=button_a) `` or
59
64
``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 .
62
67
63
68
Examples
64
69
========
@@ -124,3 +129,13 @@ the USB connection.
124
129
+------------------+-----------------+--------------------+
125
130
| **Off ** | 📴 Power Down | 📴 Power Down |
126
131
+------------------+-----------------+--------------------+
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