For example, suppose I wanted to repeatedly write to a UART device, wait for a fixed delay and read from that device, and repeat this sequence indefinitely at a given frequency. I guess I could just write an infinite loop and avoid Timer() altogether:
Code: Select all
async def readfoo():
while True:
uart.write('foo'.encode())
await uasyncio.sleep(0.1)
print('foo = ' + uart.read().decode())
await uasyncio.sleep(0.9)
uasyncio.run(readfoo())
Does anyone have advice/caveats/words of wisdom to share on this topic? I've been reading up on uasyncio but I'm just getting started, so forgive me if there is an obvious tutorial I managed to miss.