File tree 1 file changed +26
-1
lines changed 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -359,7 +359,32 @@ Bound objects:
359
359
2 . ` close ` An ` Event ` instance. Set on contact closure.
360
360
3 . ` open ` An ` Event ` instance. Set on contact open.
361
361
362
- Application code is responsible for clearing the ` Event ` instances.
362
+ Application code is responsible for clearing the ` Event ` instances.
363
+ Usage example:
364
+ ``` python
365
+ import uasyncio as asyncio
366
+ from machine import Pin
367
+ from primitives import ESwitch
368
+ es = ESwitch(Pin(" Y1" , Pin.IN , Pin.PULL_UP ))
369
+
370
+ async def closure ():
371
+ while True :
372
+ es.close.clear()
373
+ await es.close.wait()
374
+ print (" Closed" )
375
+
376
+ async def open ():
377
+ while True :
378
+ es.open.clear()
379
+ await es.open.wait()
380
+ print (" Open" )
381
+
382
+ async def main ():
383
+ asyncio.create_task(open ())
384
+ await closure()
385
+
386
+ asyncio.run(main())
387
+ ```
363
388
364
389
###### [ Contents] ( ./EVENTS.md#0-contents )
365
390
You can’t perform that action at this time.
0 commit comments