File tree 1 file changed +21
-0
lines changed 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,27 @@ the case of a single short press, `release_func` will be delayed until the
244
244
expiry of the double-click timer (because until that time a second click might
245
245
occur).
246
246
247
+ The following script may be used to demonstrate the effect of this arg. As
248
+ written it assumes a Pi Pico with a pushbutton between GPIO 18 and Gnd, with
249
+ the primitives installed.
250
+ ``` python
251
+ from machine import Pin
252
+ import uasyncio as asyncio
253
+ from primitives.pushbutton import Pushbutton
254
+
255
+ btn = Pin(18 , Pin.IN , Pin.PULL_UP ) # Adapt for your hardware
256
+ pb = Pushbutton(btn, suppress = True )
257
+
258
+ async def main ():
259
+ short_press = pb.release_func(print , (" SHORT" ,))
260
+ double_press = pb.double_func(print , (" DOUBLE" ,))
261
+ long_press = pb.long_func(print , (" LONG" ,))
262
+ while True :
263
+ await asyncio.sleep(1 )
264
+
265
+ asyncio.run(main())
266
+ ```
267
+
247
268
### 4.1.2 The sense constructor argument
248
269
249
270
In most applications it can be assumed that, at power-up, pushbuttons are not
You can’t perform that action at this time.
0 commit comments