Skip to content

Commit 2a64578

Browse files
committed
SCHEDULE.md: Add mpremote installation.
1 parent 4e9b4b1 commit 2a64578

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

v3/docs/SCHEDULE.md

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
1. [Scheduling tasks](./SCHEDULE.md#1-scheduling-tasks)
44
2. [Overview](./SCHEDULE.md#2-overview)
55
3. [Installation](./SCHEDULE.md#3-installation)
6-
4. [The schedule function](./SCHEDULE.md#4-the-schedule-function) The primary interface for uasyncio
6+
4. [The schedule function](./SCHEDULE.md#4-the-schedule-function) The primary interface for asyncio
77
4.1 [Time specifiers](./SCHEDULE.md#41-time-specifiers)
88
4.2 [Calendar behaviour](./SCHEDULE.md#42-calendar-behaviour) Calendars can be tricky...
99
     4.2.1 [Behaviour of mday and wday values](./SCHEDULE.md#421-behaviour-of-mday-and-wday-values)
@@ -37,8 +37,8 @@ It is partly inspired by the Unix cron table, also by the
3737
latter it is less capable but is small, fast and designed for microcontroller
3838
use. Repetitive and one-shot events may be created.
3939

40-
It is ideally suited for use with `uasyncio` and basic use requires minimal
41-
`uasyncio` knowledge. Users intending only to schedule callbacks can simply
40+
It is ideally suited for use with `asyncio` and basic use requires minimal
41+
`asyncio` knowledge. Users intending only to schedule callbacks can simply
4242
adapt the example code. It can be used in synchronous code and an example is
4343
provided.
4444

@@ -48,13 +48,13 @@ and the Unix build.
4848
# 2. Overview
4949

5050
The `schedule` function (`sched/sched.py`) is the interface for use with
51-
`uasyncio`. The function takes a callback and causes that callback to run at
51+
`asyncio`. The function takes a callback and causes that callback to run at
5252
specified times. A coroutine may be substituted for the callback - at the
5353
specified times it will be promoted to a `Task` and run.
5454

5555
The `schedule` function instantiates a `cron` object (in `sched/cron.py`). This
5656
is the core of the scheduler: it is a closure created with a time specifier and
57-
returning the time to the next scheduled event. Users of `uasyncio` do not need
57+
returning the time to the next scheduled event. Users of `asyncio` do not need
5858
to deal with `cron` instances.
5959

6060
This library can also be used in synchronous code, in which case `cron`
@@ -64,23 +64,28 @@ instances must explicitly be created.
6464

6565
# 3. Installation
6666

67-
Copy the `sched` directory and contents to the target's filesystem. It requires
68-
`uasyncio` V3 which is included in daily firmware builds and in release builds
69-
after V1.12.
70-
71-
To install to an SD card using [rshell](https://github.com/dhylands/rshell)
72-
move to the parent directory of `sched` and issue:
67+
Copy the `sched` directory and contents to the target's filesystem. This may be
68+
done with the official [mpremote](https://docs.micropython.org/en/latest/reference/mpremote.html):
69+
```bash
70+
$ mpremote mip install "github:peterhinch/micropython-async/v3/as_drivers/sched"
71+
```
72+
On networked platforms it may be installed with [mip](https://docs.micropython.org/en/latest/reference/packages.html).
73+
```py
74+
>>> mip.install("github:peterhinch/micropython-async/v3/as_drivers/sched")
75+
```
76+
Currently these tools install to `/lib` on the built-in Flash memory. To install
77+
to a Pyboard's SD card [rshell](https://github.com/dhylands/rshell) may be used.
78+
Move to the SD card root, run `rshell` and issue:
7379
```
7480
> rsync sched /sd/sched
7581
```
76-
Adapt the destination as appropriate for your hardware.
7782

7883
The following files are installed in the `sched` directory.
7984
1. `cron.py` Computes time to next event.
80-
2. `sched.py` The `uasyncio` `schedule` function: schedule a callback or coro.
85+
2. `sched.py` The `asyncio` `schedule` function: schedule a callback or coro.
8186
3. `primitives/__init__.py` Necessary for `sched.py`.
8287
4. `asynctest.py` Demo of asynchronous scheduling.
83-
5. `synctest.py` Synchronous scheduling demo. For `uasyncio` phobics only.
88+
5. `synctest.py` Synchronous scheduling demo. For `asyncio` phobics only.
8489
6. `crontest.py` A test for `cron.py` code.
8590
7. `simulate.py` A simple script which may be adapted to prove that a `cron`
8691
instance will behave as expected. See [The simulate script](./SCHEDULE.md#8-the-simulate-script).
@@ -125,7 +130,7 @@ import sched.asynctest
125130
```
126131
This is the demo code.
127132
```python
128-
import uasyncio as asyncio
133+
import asyncio as asyncio
129134
from sched.sched import schedule
130135
from time import localtime
131136

@@ -157,7 +162,7 @@ finally:
157162
```
158163
The event-based interface can be simpler than using callables:
159164
```python
160-
import uasyncio as asyncio
165+
import asyncio as asyncio
161166
from sched.sched import schedule
162167
from time import localtime
163168

@@ -201,7 +206,7 @@ Setting `secs=None` will cause a `ValueError`.
201206

202207
Passing an iterable to `secs` is not recommended: this library is intended for
203208
scheduling relatively long duration events. For rapid sequencing, schedule a
204-
coroutine which awaits `uasyncio` `sleep` or `sleep_ms` routines. If an
209+
coroutine which awaits `asyncio` `sleep` or `sleep_ms` routines. If an
205210
iterable is passed, triggers must be at least ten seconds apart or a
206211
`ValueError` will result.
207212

@@ -253,7 +258,7 @@ asyncio.create_task(schedule(foo, month=(2, 7, 10), hrs=1, mins=59))
253258
## 4.3 Limitations
254259

255260
The underlying `cron` code has a resolution of 1 second. The library is
256-
intended for scheduling infrequent events (`uasyncio` has its own approach to
261+
intended for scheduling infrequent events (`asyncio` has its own approach to
257262
fast scheduling).
258263

259264
Specifying `secs=None` will cause a `ValueError`. The minimum interval between
@@ -269,7 +274,7 @@ to the Unix build where daylight saving needs to be considered.
269274

270275
## 4.4 The Unix build
271276

272-
Asynchronous use requires `uasyncio` V3, so ensure this is installed on the
277+
Asynchronous use requires `asyncio` V3, so ensure this is installed on the
273278
Linux target.
274279

275280
The synchronous and asynchronous demos run under the Unix build. The module is
@@ -283,7 +288,7 @@ is to avoid scheduling the times in your region where this occurs (01.00.00 to
283288

284289
# 5. The cron object
285290

286-
This is the core of the scheduler. Users of `uasyncio` do not need to concern
291+
This is the core of the scheduler. Users of `asyncio` do not need to concern
287292
themseleves with it. It is documented for those wishing to modify the code and
288293
for those wanting to perform scheduling in synchronous code.
289294

@@ -342,7 +347,7 @@ applications. On my reference board timing drifted by 1.4mins/hr, an error of
342347

343348
Boards with internet connectivity can periodically synchronise to an NTP server
344349
but this carries a risk of sudden jumps in the system time which may disrupt
345-
`uasyncio` and the scheduler.
350+
`asyncio` and the scheduler.
346351

347352
##### [Top](./SCHEDULE.md#0-contents)
348353

@@ -403,9 +408,9 @@ main()
403408
```
404409

405410
In my opinion the asynchronous version is cleaner and easier to understand. It
406-
is also more versatile because the advanced features of `uasyncio` are
411+
is also more versatile because the advanced features of `asyncio` are
407412
available to the application including cancellation of scheduled tasks. The
408-
above code is incompatible with `uasyncio` because of the blocking calls to
413+
above code is incompatible with `asyncio` because of the blocking calls to
409414
`time.sleep()`.
410415

411416
## 7.1 Initialisation

0 commit comments

Comments
 (0)