Jeff Epler
76f03a2bee
Make keypad select/poll'able for better async
...
This allows a small wrapper class to be written
```py
class AsyncEventQueue:
def __init__(self, events):
self._events = events
async def __await__(self):
yield asyncio.core._io_queue.queue_read(self._events)
return self._events.get()
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
pass
```
and used to just "await" the next event:
```py
async def key_task():
print("waiting for keypresses")
with keypad.KeyMatrix([board.D4], [board.D5]) as keys, AsyncEventQueue(keys.events) as ev:
while True:
print(await ev)
```
Because checking the empty status of the EventQueue does not enter
CircuitPython bytecode, it's assumed (but not measured) that this is
more efficient than an equivalent loop with an `await async.sleep(0)`
yield and introduces less latency than any non-zero sleep value.
2022-08-09 21:48:27 -05:00
..
2022-03-10 11:19:35 -05:00
2022-08-04 16:33:10 -07:00
2021-12-22 11:14:21 -06:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-08-04 19:34:12 -05:00
2022-05-19 15:38:37 -04:00
2022-05-19 15:38:37 -04:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-05-03 12:31:20 -06:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-06-10 18:01:02 -05:00
2022-05-19 15:38:37 -04:00
2022-05-13 11:51:30 -04:00
2022-05-27 12:59:54 -07:00
2021-11-17 16:42:47 +01:00
2022-05-19 15:38:37 -04:00
2022-05-23 13:03:03 -05:00
2022-05-27 12:59:54 -07:00
2022-06-23 07:28:04 -05:00
2022-05-18 14:01:35 -07:00
2021-09-01 00:19:05 -04:00
2022-01-13 19:33:10 -06:00
2022-05-27 12:59:54 -07:00
2022-07-14 13:31:41 +02:00
2022-05-27 12:59:54 -07:00
2021-08-26 21:35:02 -04:00
2021-10-27 10:54:31 -05:00
2022-05-03 08:48:53 -05:00
2022-07-11 14:53:20 -07:00
2021-12-22 11:14:21 -06:00
2021-11-22 14:54:44 -08:00
2022-05-03 08:48:53 -05:00
2022-05-03 08:48:53 -05:00
2022-08-09 21:48:27 -05:00
2022-05-27 12:59:54 -07:00
2022-07-28 08:43:36 -07:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-07-11 11:04:06 -05:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2021-10-15 13:49:33 -05:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-05-13 14:00:09 -04:00
2021-11-12 17:31:15 -06:00
2022-05-27 12:59:54 -07:00
2022-05-19 15:38:37 -04:00
2022-05-03 08:48:53 -05:00
2022-05-27 12:59:54 -07:00
2021-12-22 11:14:21 -06:00
2022-05-27 12:59:54 -07:00
2022-07-11 11:04:06 -05:00
2022-06-27 13:34:13 -07:00
2022-05-06 09:55:18 -04:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-08-04 16:34:25 -07:00
2022-05-27 12:59:54 -07:00
2022-06-09 14:55:54 -07:00
2022-05-27 12:59:54 -07:00
2022-07-11 11:04:06 -05:00
2022-05-03 12:31:20 -06:00
2021-09-01 00:19:05 -04:00
2022-05-03 08:48:53 -05:00
2022-05-27 12:59:54 -07:00
2022-05-27 12:59:54 -07:00
2022-03-07 18:07:25 -08:00
2022-05-27 12:59:54 -07:00
2021-09-01 00:19:05 -04:00
2022-05-27 12:59:54 -07:00
2022-05-03 08:48:53 -05:00
2022-07-09 22:17:35 -07:00
2022-05-27 12:59:54 -07:00
2020-08-07 00:01:31 +09:00
2020-06-14 11:12:35 -05:00
2022-07-26 18:15:59 +02:00
2022-05-27 12:59:54 -07:00
2019-06-12 11:36:43 -07:00