@@ -8,7 +8,7 @@ Release 0.1 25th July 2018
8
8
3 . [ Low power uasyncio operation] ( ./README.md#3-low-power-uasyncio-operation )
9
9
3.1 [ The official uasyncio package] ( ./README.md#31-the-official-uasyncio-package )
10
10
3.2 [ The low power adaptation] ( ./README.md#32-the-low-power-adaptation )
11
- 3.2.1 [ Consequences of pyb. stop] ( ./README.md#321-consequences-of-pyb. stop )
11
+ 3.2.1 [ Consequences of stop mode ] ( ./README.md#321-consequences-of-stop-mode )
12
12
3.2.1.1 [ Timing Accuracy and rollover] ( ./README.md#3211-timing-accuracy-and-rollover )
13
13
3.2.1.2 [ USB] ( ./README.md#3212-usb )
14
14
3.2.2 [ Measured results] ( ./README.md#322-measured-results )
@@ -89,16 +89,24 @@ calculated on that basis. This consumes power.
89
89
The second issue is that it uses ` utime ` 's millisecond timing utilities for
90
90
timing. This ensures portability across MicroPython platforms. Unfortunately on
91
91
the Pyboard the clock responsible for ` utime ` stops for the duration of
92
- ` pyb.stop() ` . An application-level scheme using ` pyb.stop ` to conserve power
93
- would cause all ` uasyncio ` timing to become highly inaccurate.
92
+ ` pyb.stop() ` . If an application were to use ` pyb.stop ` to conserve power it
93
+ would cause ` uasyncio ` timing to become highly inaccurate.
94
94
95
95
## 3.2 The low power adaptation
96
96
97
97
If running on a Pyboard the version of ` uasyncio ` in this repo attempts to
98
98
import the file ` rtc_time.py ` . If this succeeds and there is no USB connection
99
99
to the board it derives its millisecond timing from the RTC; this continues to
100
- run through ` stop ` . Libraries using ` uasyncio ` will run unmodified, barring any
101
- timing issues if user code increases scheduler latency.
100
+ run through ` stop ` . So code such as the following will behave as expected:
101
+ ``` python
102
+ async def foo ():
103
+ await asyncio.sleep(10 )
104
+ bar()
105
+ await asyncio.sleep_ms(100 )
106
+ ```
107
+ Libraries and applications using ` uasyncio ` will run unmodified. Code adapted
108
+ to invoke power saving (as described below) may exhibit reduced performance:
109
+ there is a tradeoff beween power consumption and speed.
102
110
103
111
To avoid the power drain caused by ` select.poll ` the user code must issue the
104
112
following:
@@ -123,7 +131,7 @@ scheduler is again paused (if `latency` > 0).
123
131
124
132
###### [ Contents] ( ./README.md#a-low-power-usayncio-adaptation )
125
133
126
- ### 3.2.1 Consequences of pyb. stop
134
+ ### 3.2.1 Consequences of stop mode
127
135
128
136
#### 3.2.1.1 Timing Accuracy and rollover
129
137
@@ -207,7 +215,7 @@ Horizontal 50ms/div
207
215
![ Image] ( ./current.png )
208
216
209
217
The following shows that peak on a faster timebase. This type of waveform is
210
- typical that experienced when Python code is running.
218
+ typical that experienced when Python code is running.
211
219
Vertical 20mA/div
212
220
Horizontal 500μs/div
213
221
![ Image] ( ./current1.png )
@@ -225,8 +233,8 @@ Variable:
225
233
Functions:
226
234
If the timebase is ` utime ` these are references to the corresponding ` utime `
227
235
functions. Otherwise they are direct replacements but using the RTC as their
228
- timebase. See the ` utime ` official
229
- [ documentation] ( http://docs.micropython.org/en/latest/pyboard/library/utime.html )
236
+ timebase. See the ` utime `
237
+ [ official documentation] ( http://docs.micropython.org/en/latest/pyboard/library/utime.html )
230
238
for these.
231
239
* ` ticks_ms `
232
240
* ` ticks_add `
@@ -289,8 +297,9 @@ control.
289
297
290
298
Floating Pyboard I/O pins can consume power. Further there are 4.7KΩ pullups on
291
299
the I2C pins. The ` rtc_time ` module sets all pins as inputs with internal
292
- pullups. The application should then reconfigure any pins which are to be used.
293
- If I2C is to be used there are further implications: see the above reference.
300
+ pullups. The application should import ` rtc_time ` before configuring any pins
301
+ or instantiating any drivers which use pins. If I2C is to be used there are
302
+ implications regarding the onboard pullups: see the above reference.
294
303
295
304
## 5.2 Application Code
296
305
@@ -327,8 +336,8 @@ async def foo():
327
336
await asyncio.sleep(0 )
328
337
```
329
338
330
- will execute (at best) at a rate of 5Hz; possibly considerably less frequently
331
- depending on the behaviour of competing tasks. Likewise
339
+ will execute (at best) at a rate of 5Hz; possibly less, depending on the
340
+ behaviour of competing tasks. Likewise with 200ms latency
332
341
333
342
``` python
334
343
async def bar ():
0 commit comments