Skip to content

Commit 783717a

Browse files
committed
EVENTS.md: Add TOC.
1 parent 2b05b39 commit 783717a

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

v3/docs/EVENTS.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ application logic.
77
This document assumes familiarity with `uasyncio`. See [official docs](http://docs.micropython.org/en/latest/library/uasyncio.html) and
88
[unofficial tutorial](https://github.com/peterhinch/micropython-async/blob/master/v3/docs/TUTORIAL.md).
99

10+
# 0. Contents
11+
1012
1. [An alternative to callbacks in uasyncio code](./EVENTS.md#1-an-alternative-to-callbacks-in-uasyncio-code)
1113
2. [Rationale](./EVENTS.md#2-rationale)
1214
3. [Device driver design](./EVENTS.md#3-device-driver-design)
@@ -23,7 +25,7 @@ This document assumes familiarity with `uasyncio`. See [official docs](http://do
2325
6.2 [EButton](./EVENTS.md#62-ebutton)
2426
     6.2.1 [The suppress constructor argument](./EVENTS.md#621-the-suppress-constructor-argument)
2527
     6.2.2 [The sense constructor argument](./EVENTS.md#622-the-sense-constructor-argument)
26-
[Appendix 1 Polling](./EVENTS.md-appendix-1-polling)
28+
[Appendix 1 Polling](./EVENTS.md#-appendix-1-polling)
2729

2830
# 1. An alternative to callbacks in uasyncio code
2931

@@ -69,6 +71,8 @@ Note the `Stream` mechanism provides another approach which works well with
6971
devices such as sockets and UARTs. It is less well suited to handling arbitrary
7072
events, partly because it relies on polling under the hood.
7173

74+
###### [Contents](./EVENTS.md#0-contents)
75+
7276
# 2. Rationale
7377

7478
Consider a device driver `Sensor` which has a bound `Event` object `.ready`.
@@ -119,6 +123,8 @@ callbacks:
119123
execution reaches `.wait()` before the `Event` is cleared, it will not pause.
120124
If the `Event` is cleared, it will pause until it is set again.
121125

126+
###### [Contents](./EVENTS.md#0-contents)
127+
122128
# 3. Device driver design
123129

124130
This document introduces the idea of an event-like object (ELO). This is an
@@ -146,6 +152,8 @@ Drivers exposing `Event` instances include:
146152
* [Switch][5m] Similar but interfaces also expose callbacks.
147153
* [Pushbutton][6m]
148154

155+
###### [Contents](./EVENTS.md#0-contents)
156+
149157
# 4. Primitives
150158

151159
Applying `Events` to typical logic problems requires two new primitives:
@@ -188,6 +196,8 @@ await WaitAll((event1, event2, WaitAny(event3, event4))).wait()
188196
This will pause until `event1` and `event2` and either `event3`or `event4` have
189197
been set.
190198

199+
###### [Contents](./EVENTS.md#0-contents)
200+
191201
# 5. Event based programming
192202

193203
## 5.1 Use of Delay_ms
@@ -281,6 +291,8 @@ async def main():
281291
# Both timers running: run "short press" code
282292
```
283293

294+
###### [Contents](./EVENTS.md#0-contents)
295+
284296
## 5.3 Application example
285297

286298
A measuring instrument is started by pressing a button. The measurement
@@ -314,6 +326,8 @@ async def foo():
314326
# Normal outcome, process readings
315327
```
316328

329+
###### [Contents](./EVENTS.md#0-contents)
330+
317331
# 6. Drivers
318332

319333
This document describes drivers for mechanical switches and pushbuttons. These
@@ -355,6 +369,8 @@ Bound objects:
355369

356370
Application code is responsible for clearing the `Event` instances.
357371

372+
###### [Contents](./EVENTS.md#0-contents)
373+
358374
## 6.2 EButton
359375

360376
This extends the functionality of `ESwitch` to provide additional events for
@@ -443,6 +459,8 @@ the voltage on the pin is gnd.
443459
Whenever the pin value changes, the new value is compared with `sense` to
444460
determine whether the button is closed or open.
445461

462+
###### [Contents](./EVENTS.md#0-contents)
463+
446464
# Appendix 1 Polling
447465

448466
The primitives or drivers referenced here do not use polling with the following

0 commit comments

Comments
 (0)