@@ -139,6 +139,14 @@ before yielding with a zero delay. The duration of the `stop` condition
139
139
full speed. The ` yield ` allows each pending task to run once before the
140
140
scheduler is again paused (if ` latency ` > 0).
141
141
142
+ The line
143
+ ``` python
144
+ rtc_time_cfg.enabled = True
145
+ ```
146
+ must be issued before importing ` uasyncio ` and before importing any modules
147
+ which use it, otherwise low-power mode will not be engaged. It is wise to do
148
+ this at the start of application code.
149
+
142
150
###### [ Contents] ( ./README.md#a-low-power-usayncio-adaptation )
143
151
144
152
### 3.2.1 Consequences of stop mode
@@ -147,15 +155,15 @@ scheduler is again paused (if `latency` > 0).
147
155
148
156
A minor limitation is that the Pyboard 1.x RTC cannot resolve times of less
149
157
than 4ms so there is a theoretical reduction in the accuracy of delays. This
150
- does not apply to the Pyboard D. In practice this is somewhat academic. As
151
- explained in the [ tutorial] ( ../TUTORIAL.md ) , issuing
158
+ does not apply to the Pyboard D. This is somewhat academic. As explained in the
159
+ [ tutorial] ( ../TUTORIAL.md ) , issuing
152
160
153
161
``` python
154
162
await asyncio.sleep_ms(t)
155
163
```
156
164
157
165
specifies a minimum delay: the maximum may be substantially higher depending on
158
- the behaviour of other tasks.
166
+ the behaviour of other tasks. Also the ` latency ` value will be added to ` t ` .
159
167
160
168
RTC time rollover is at 7 days. The maximum supported ` asyncio.sleep() ` value
161
169
is 302399999 seconds (3.5 days - 1s).
@@ -166,7 +174,14 @@ Programs using `pyb.stop` disable the USB connection to the PC. This is
166
174
inconvenient for debugging so ` rtc_time.py ` detects an active USB connection
167
175
and disables power saving. This enables an application to be developed normally
168
176
via a USB connected PC. The board can then be disconnected from the PC and run
169
- from a separate power source for power measurements.
177
+ from a separate power source for power measurements, the application being
178
+ started by ` main.py ` .
179
+
180
+ An active USB connection is one where a PC application is accessing the port:
181
+ an unused port can power the Pyboard and the library will assume low-power
182
+ mode. If the Pyboard is booted in safe mode to bypass ` main.py ` and the
183
+ application is started at the REPL, USB detection will disable low power mode
184
+ to keep the connection open.
170
185
171
186
Applications can detect which timebase is in use by issuing:
172
187
0 commit comments