Skip to content

Commit 9fbcb73

Browse files
committed
Tidy up lowpower README.
1 parent 75c3a92 commit 9fbcb73

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

lowpower/README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Release 0.1 25th July 2018
88
3. [Low power uasyncio operation](./README.md#3-low-power-uasyncio-operation)
99
3.1 [The official uasyncio package](./README.md#31-the-official-uasyncio-package)
1010
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)
1212
3.2.1.1 [Timing Accuracy and rollover](./README.md#3211-timing-accuracy-and-rollover)
1313
3.2.1.2 [USB](./README.md#3212-usb)
1414
3.2.2 [Measured results](./README.md#322-measured-results)
@@ -89,16 +89,24 @@ calculated on that basis. This consumes power.
8989
The second issue is that it uses `utime`'s millisecond timing utilities for
9090
timing. This ensures portability across MicroPython platforms. Unfortunately on
9191
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.
9494

9595
## 3.2 The low power adaptation
9696

9797
If running on a Pyboard the version of `uasyncio` in this repo attempts to
9898
import the file `rtc_time.py`. If this succeeds and there is no USB connection
9999
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.
102110

103111
To avoid the power drain caused by `select.poll` the user code must issue the
104112
following:
@@ -123,7 +131,7 @@ scheduler is again paused (if `latency` > 0).
123131

124132
###### [Contents](./README.md#a-low-power-usayncio-adaptation)
125133

126-
### 3.2.1 Consequences of pyb.stop
134+
### 3.2.1 Consequences of stop mode
127135

128136
#### 3.2.1.1 Timing Accuracy and rollover
129137

@@ -207,7 +215,7 @@ Horizontal 50ms/div
207215
![Image](./current.png)
208216

209217
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.
211219
Vertical 20mA/div
212220
Horizontal 500μs/div
213221
![Image](./current1.png)
@@ -225,8 +233,8 @@ Variable:
225233
Functions:
226234
If the timebase is `utime` these are references to the corresponding `utime`
227235
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)
230238
for these.
231239
* `ticks_ms`
232240
* `ticks_add`
@@ -289,8 +297,9 @@ control.
289297

290298
Floating Pyboard I/O pins can consume power. Further there are 4.7KΩ pullups on
291299
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.
294303

295304
## 5.2 Application Code
296305

@@ -327,8 +336,8 @@ async def foo():
327336
await asyncio.sleep(0)
328337
```
329338

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
332341

333342
```python
334343
async def bar():

0 commit comments

Comments
 (0)