Open pfalcon opened 10 years ago
I started microasync when uasyncio
not existed, so I think I should try uasyncio
=)
Thanks for the link.
Well, first commit was in April: https://github.com/micropython/micropython-lib/commit/80ecd3b822973352fa75d7166bf689c4284f8d38 , soon after I finished implementing "yield from": https://github.com/micropython/micropython/commit/cf21a4e7f4fbd330fa65fb5431308ae712626023 . Forum thread dates to start of May: http://forum.micropython.org/viewtopic.php?f=3&t=85 .
Bottom line: would be nice to get people interested in coroutine multitasking in MicroPython on the same line to move it forward ;-). uasyncio now has web microframework running on top of it: https://github.com/pfalcon/picoweb . But that runs on POSIX port, I really could use some help with supporting PyBoard I/O in event loop.
I've tried uasyncio.core
and it works well on simple code like:
from uasyncio.core import get_event_loop, sleep
import pyb
def toggle_led_on_interval(led, interval):
while True:
pyb.LED(led).toggle()
yield from sleep(interval)
loop = get_event_loop()
loop.call_soon(toggle_led_on_interval(1, 1))
loop.call_soon(toggle_led_on_interval(2, 2))
loop.call_soon(toggle_led_on_interval(3, 1))
loop.call_soon(toggle_led_on_interval(4, 2))
loop.run_forever()
So I definitely should use asyncio.core
.
Thanks! There's a discussion about next steps to support PyBoard devices in uasyncio, which really could use input from more parties: http://forum.micropython.org/viewtopic.php?f=3&t=85&start=30#p2351
subj. https://github.com/micropython/micropython-lib/tree/master/uasyncio.core