Skip to content

Asyncio helper support for busio.UART, pin changes, other peripherals #7156

@furbrain

Description

@furbrain

I've been programming on raspberry Pi for some time and love using the asyncio mechanisms for creating event driven programs. More recently I've started developing a product using the Seeed nRF52840 Sense board, using CircuitPython. I see we've got asyncio support, but there doesn't seem to be any async oriented libraries.

e.g

I would like to be able to do:

async def buttonAction(pin: DigitalInOut):
    while True:
        await pinChanged(pin, RISING_EDGE)
        #do some action here

async def uartRespodner(uart: busio.UART):
    while True:
        line = await asyncReadline(uart)
        uart.write(line)

I know we can use the countio stuff as per the asyncio tutorial, but that seems a bit long winded for what should be a fairly simple operation. I think having an async wrapper around anything that has a "file-like" interface (read, read_into, readline, write), should also be fairly straightforwards.

I'm willing to create this library if you feel it is a good idea, but I would welcome suggestions for a) what to call it and b) how to structure it.

Phil

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions