Open
Description
In #6712 a proof of concept for improved waiting on core objects in asyncio was merged. This, together with a small piece of Python code, lets asyncio code await
an event from any keypad EventQueue, and it's much faster/more efficient than previous options, which involved a Python loop with an await asyncio.sleep
and a test for an event being registered.
I think it would be good to ...
- Identify any other types in the core that would benefit from similar treatment (addition of an ioctl poll routine)
- Create a new helper library with the necessary code and place it in the bundle (not in asyncio itself)
Classes that might be worth considering, with little or no code addition needed besides the ioctl poll:
- PulseIn
- canio.Listener
- countio
- esp32_camera.Camera
- imagecapture.ParallelImageCapture
- FrequencyIn
- rp2pio.StateMachine (for background_write completion)
- socketpool.Socket, if it doesn't already work with asyncio
- AudioOut (& i2s & pwm variants & Mixer) wait for sample complete
With new core code possibly we could do these things in the background or based on true microcontroller interrupts:
- DigitalInOut or new InterruptIn (slightly different to keypad.Keys as it would react to just one polarity, probably)
- TouchIn