Skip to content

Commit d14adb7

Browse files
committed
V3/docs/DRIVERS.md improve description of Pushbutton suppress ctor arg.
1 parent 1e6c2a2 commit d14adb7

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

v3/docs/DRIVERS.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,26 +205,38 @@ number of coroutines.
205205
### 4.1.1 The suppress constructor argument
206206

207207
When the button is pressed `press_func` runs immediately. This minimal latency
208-
is ideal for applications such as games, but does imply that in the event of a
209-
long press, both `press_func` and `long_func` run: `press_func` immediately and
210-
`long_func` if the button is still pressed when the timer has elapsed. Similar
211-
reasoning applies to the double click function.
208+
is ideal for applications such as games. Consider a long press: `press_func`
209+
runs initially, then `long_func`, and finally `release_func`. In the case of a
210+
double-click `press_func` and `release_func` will run twice; `double_func` runs
211+
once.
212212

213213
There can be a need for a `callable` which runs if a button is pressed but
214-
only if a doubleclick or long press function does not run. The soonest that the
215-
absence of a long press can be detected is on button release. The absence of a
216-
double click can only be detected when the double click timer times out without
217-
a second press occurring.
214+
only if a doubleclick or long press function does not run. The `suppress` arg
215+
changes the behaviour of `release_func` to fill that role. This has timing
216+
implications.
218217

219-
This `callable` is the `release_func`. If the `suppress` constructor arg is
220-
set, `release_func` will be launched as follows:
218+
The soonest that the absence of a long press can be detected is on button
219+
release. Absence of a double click can only be detected when the double click
220+
timer times out without a second press occurring.
221+
222+
Note `suppress` affects the behaviour of `release_func` only. Other callbacks
223+
including `press_func` behave normally.
224+
225+
If the `suppress` constructor arg is set, `release_func` will be launched as
226+
follows:
221227
1. If `double_func` does not exist on rapid button release.
222228
2. If `double_func` exists, after the expiration of the doubleclick timer.
223229
3. If `long_func` exists and the press duration causes `long_func` to be
224230
launched, `release_func` will not be launched.
225231
4. If `double_func` exists and a double click occurs, `release_func` will not
226232
be launched.
227233

234+
In the typical case where `long_func` and `double_func` are both defined, this
235+
ensures that only one of `long_func`, `double_func` and `release_func` run. In
236+
the case of a single short press, `release_func` will be delayed until the
237+
expiry of the double-click timer (because until that time a second click might
238+
occur).
239+
228240
### 4.1.2 The sense constructor argument
229241

230242
In most applications it can be assumed that, at power-up, pushbuttons are not

0 commit comments

Comments
 (0)