circuitpython/shared-bindings
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
..
__future__ add annotations to __future__; don't generate __future__ stubs 2022-03-10 11:19:35 -05:00
_bleio Add BLE status to title bar 2022-08-04 16:33:10 -07:00
_eve circuitpython_stubs: Use `circuitpython_typing` for cp-specific typing 2021-12-22 11:14:21 -06:00
_pew Conditionalize LTO 2022-05-27 12:59:54 -07:00
_stage Conditionalize LTO 2022-05-27 12:59:54 -07:00
adafruit_bus_device Changed error handling to use new routine 2022-08-04 19:34:12 -05:00
adafruit_pixelbuf message consolidation and more use of validators 2022-05-19 15:38:37 -04:00
aesio message consolidation and more use of validators 2022-05-19 15:38:37 -04:00
alarm Conditionalize LTO 2022-05-27 12:59:54 -07:00
analogio Conditionalize LTO 2022-05-27 12:59:54 -07:00
atexit Add os, "socket", atexit, ssl, struct, traceback, math links 2022-05-03 12:31:20 -06:00
audiobusio Conditionalize LTO 2022-05-27 12:59:54 -07:00
audiocore Conditionalize LTO 2022-05-27 12:59:54 -07:00
audioio Conditionalize LTO 2022-05-27 12:59:54 -07:00
audiomixer Conditionalize LTO 2022-05-27 12:59:54 -07:00
audiomp3 Conditionalize LTO 2022-05-27 12:59:54 -07:00
audiopwmio Conditionalize LTO 2022-05-27 12:59:54 -07:00
bitbangio Conditionalize LTO 2022-05-27 12:59:54 -07:00
bitmaptools improving rotozoom() argument docstrings 2022-06-10 18:01:02 -05:00
bitops message consolidation and more use of validators 2022-05-19 15:38:37 -04:00
board Make other documentation links prettier 2022-05-13 11:51:30 -04:00
busio Conditionalize LTO 2022-05-27 12:59:54 -07:00
camera camera: Update camera_make_new arguments 2021-11-17 16:42:47 +01:00
canio message consolidation and more use of validators 2022-05-19 15:38:37 -04:00
countio Fix a minor namespace issue in the countio example 2022-05-23 13:03:03 -05:00
digitalio Conditionalize LTO 2022-05-27 12:59:54 -07:00
displayio use validate_int_range(). remove string translation entry 2022-06-23 07:28:04 -05:00
dotenv Add dotenv read support 2022-05-18 14:01:35 -07:00
dualbank Convert more modules to use MP_REGISTER_MODULE 2021-09-01 00:19:05 -04:00
floppyio fix types 2022-01-13 19:33:10 -06:00
fontio Conditionalize LTO 2022-05-27 12:59:54 -07:00
framebufferio fix the docs 2022-07-14 13:31:41 +02:00
frequencyio Conditionalize LTO 2022-05-27 12:59:54 -07:00
getpass Convert more modules to use MP_REGISTER_MODULE 2021-08-26 21:35:02 -04:00
gifio gifio: Add dithered output 2021-10-27 10:54:31 -05:00
gnss Make MP_PROPERTY_GETTER / _GETSET fully declare the property 2022-05-03 08:48:53 -05:00
hashlib A bit more cleanup 2022-07-11 14:53:20 -07:00
i2cperipheral circuitpython_stubs: Use `circuitpython_typing` for cp-specific typing 2021-12-22 11:14:21 -06:00
imagecapture Initial broadcom port for Raspberry Pi 2021-11-22 14:54:44 -08:00
ipaddress Make MP_PROPERTY_GETTER / _GETSET fully declare the property 2022-05-03 08:48:53 -05:00
is31fl3741 Make MP_PROPERTY_GETTER / _GETSET fully declare the property 2022-05-03 08:48:53 -05:00
keypad Make keypad select/poll'able for better async 2022-08-09 21:48:27 -05:00
math Conditionalize LTO 2022-05-27 12:59:54 -07:00
mdns Tweaks based on review comments 2022-07-28 08:43:36 -07:00
memorymonitor Conditionalize LTO 2022-05-27 12:59:54 -07:00
microcontroller Conditionalize LTO 2022-05-27 12:59:54 -07:00
msgpack adding links in docs 2022-07-11 11:04:06 -05:00
multiterminal Conditionalize LTO 2022-05-27 12:59:54 -07:00
neopixel_write Conditionalize LTO 2022-05-27 12:59:54 -07:00
nvm Conditionalize LTO 2022-05-27 12:59:54 -07:00
onewireio Rename make_new's parameter to `all_args` 2021-10-15 13:49:33 -05:00
os Conditionalize LTO 2022-05-27 12:59:54 -07:00
paralleldisplay Conditionalize LTO 2022-05-27 12:59:54 -07:00
ps2io Conditionalize LTO 2022-05-27 12:59:54 -07:00
pulseio Conditionalize LTO 2022-05-27 12:59:54 -07:00
pwmio Conditionalize LTO 2022-05-27 12:59:54 -07:00
qrio Change "library" to "module" 2022-05-13 14:00:09 -04:00
rainbowio rainbowio: No need for the ternary here 2021-11-12 17:31:15 -06:00
random Conditionalize LTO 2022-05-27 12:59:54 -07:00
rgbmatrix message consolidation and more use of validators 2022-05-19 15:38:37 -04:00
rotaryio Make MP_PROPERTY_GETTER / _GETSET fully declare the property 2022-05-03 08:48:53 -05:00
rtc Conditionalize LTO 2022-05-27 12:59:54 -07:00
sdcardio circuitpython_stubs: Use `circuitpython_typing` for cp-specific typing 2021-12-22 11:14:21 -06:00
sdioio Conditionalize LTO 2022-05-27 12:59:54 -07:00
sharpdisplay adding links in docs 2022-07-11 11:04:06 -05:00
socketpool WIP doesn't flush response before closing 2022-06-27 13:34:13 -07:00
ssl Merge pull request #6337 from jepler/property-storage 2022-05-06 09:55:18 -04:00
storage Conditionalize LTO 2022-05-27 12:59:54 -07:00
struct Conditionalize LTO 2022-05-27 12:59:54 -07:00
supervisor Add supervisor.runtime.autoreload 2022-08-04 16:34:25 -07:00
synthio Conditionalize LTO 2022-05-27 12:59:54 -07:00
terminalio Wi-Fi autoconnect and title bar status 2022-06-09 14:55:54 -07:00
time Conditionalize LTO 2022-05-27 12:59:54 -07:00
touchio adding links in docs 2022-07-11 11:04:06 -05:00
traceback Add os, "socket", atexit, ssl, struct, traceback, math links 2022-05-03 12:31:20 -06:00
uheap Convert more modules to use MP_REGISTER_MODULE 2021-09-01 00:19:05 -04:00
usb Make MP_PROPERTY_GETTER / _GETSET fully declare the property 2022-05-03 08:48:53 -05:00
usb_cdc Conditionalize LTO 2022-05-27 12:59:54 -07:00
usb_hid Conditionalize LTO 2022-05-27 12:59:54 -07:00
usb_host Start of USB host API 2022-03-07 18:07:25 -08:00
usb_midi Conditionalize LTO 2022-05-27 12:59:54 -07:00
ustack Convert more modules to use MP_REGISTER_MODULE 2021-09-01 00:19:05 -04:00
vectorio Conditionalize LTO 2022-05-27 12:59:54 -07:00
watchdog Make MP_PROPERTY_GETTER / _GETSET fully declare the property 2022-05-03 08:48:53 -05:00
wifi Update shared-bindings/wifi/Radio.h 2022-07-09 22:17:35 -07:00
zlib Conditionalize LTO 2022-05-27 12:59:54 -07:00
help.rst Apply a Sphinx transform to make the core module docs look better 2020-08-07 00:01:31 +09:00
index.rst docs: Improve 5.0.x <-> main branch doc linkrot 2020-06-14 11:12:35 -05:00
support_matrix.rst list extensions instead of macros names ("bin,uf2" not BIN_UF2) 2022-07-26 18:15:59 +02:00
util.c Conditionalize LTO 2022-05-27 12:59:54 -07:00
util.h Refactor deinit check to reduce code size. 2019-06-12 11:36:43 -07:00