You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
my understanding is that the current version of circuit python (v1.0) is based on micropython 1.8.7. micropython (i think) does support uasyncio and has a external libraries project called micropython-lib that holds a number of librariies including the uasyncio library (there are two there, one is uasyncio which is empty and uasyncio.core which is what i want).
i guess my question is: how can i build/download a compatible version of uasyncio.core for use with circuitpython v1.0?
i can package the contents of uasyncio.core and copy it to circuitpython's lib folder, but when i try to define an async function, it generates a syntax error. for example:
async def pwm_cycle(led, duty, cycles):
The error is:
File "code.py", line 6
SyntaxError: invalid syntax
@lila The async stuff in MicroPython and its additional libraries is a subset of CPython and still looks a bit work in progress. What's your use case for the module?
i'd like to use libraries such as : https://github.com/peterhinch/micropython-async in order to do event driven programming of the board. For example, when buttons are pressed or accelleratometers triggered do run a coroutine, rather than have to explicitly poll for each of the inputs.
I think async programming is much harder to teach than sync programming so this is very low on my list.
If you or anyone else are interested in adding support, please reopen for tracking. Otherwise, I'm closing this. While I think we'll get there eventually, there are just too many other things to do including additional MCU support, standardizing APIs and networking to consider this in the medium term.
The micropython uasyncio code is very actively being worked on, as in a commit that is only a day old (as of now), by pfalcon. Until it's reasonably stable, I can't see that it's gonna get much attention for the limited number of ports (samd, esp8266) that adafruit folks are trying to get into a manageable shape. (and keep in mind, CP doesn't track MP exactly, there are some differences such as using non-micro libraries (random vs urandom, for one example...))
So just to clarify asyncio is not currently supported on Circuit Playground Express? I have been trying to work this out as I would like to utilize cooperative multitasking.
Activity
lila commentedon Aug 20, 2017
just more details:
it appears that the
asynckeyword is new in python starting at version 3.5. circuiltpython v1.0 is using python version 3.4.0.but 3.4 does have coroutines, using
@asyncio.coroutineinstead ofasync. however,tannewt commentedon Aug 21, 2017
What board are you trying this on? I'd expect it to work on ESP8266.
lila commentedon Aug 21, 2017
i'm using the Adafruit Circuit Playground Express.
tannewt commentedon Aug 21, 2017
Ok, I've not taken any time to look into adding it. What libraries are you trying to use on top of it?
willingc commentedon Aug 21, 2017
@lila The async stuff in MicroPython and its additional libraries is a subset of CPython and still looks a bit work in progress. What's your use case for the module?
lila commentedon Aug 21, 2017
i'd like to use libraries such as : https://github.com/peterhinch/micropython-async in order to do event driven programming of the board. For example, when buttons are pressed or accelleratometers triggered do run a coroutine, rather than have to explicitly poll for each of the inputs.
in https://github.com/peterhinch/micropython-async/blob/master/aswitch.py there is a pushbutton class that handles the registration and execution of the python functions.
i find that's a much easier way to program...
if there are other ways to do this, please let me know... thanks,
tannewt commentedon Aug 21, 2017
I think async programming is much harder to teach than sync programming so this is very low on my list.
If you or anyone else are interested in adding support, please reopen for tracking. Otherwise, I'm closing this. While I think we'll get there eventually, there are just too many other things to do including additional MCU support, standardizing APIs and networking to consider this in the medium term.
sethcohn commentedon Aug 21, 2017
The micropython uasyncio code is very actively being worked on, as in a commit that is only a day old (as of now), by pfalcon. Until it's reasonably stable, I can't see that it's gonna get much attention for the limited number of ports (samd, esp8266) that adafruit folks are trying to get into a manageable shape. (and keep in mind, CP doesn't track MP exactly, there are some differences such as using non-micro libraries (random vs urandom, for one example...))
ronysh commentedon Mar 4, 2018
I totally agree that event driven input can bring working with these boards to the next level.
tannewt commentedon Mar 5, 2018
@ronysh please follow #619 for more info.
rosstie commentedon Jun 3, 2022
So just to clarify asyncio is not currently supported on Circuit Playground Express? I have been trying to work this out as I would like to utilize cooperative multitasking.
dhalbert commentedon Jun 3, 2022
@rosstie That's right, there just isn't room for it in the firmware space we have (256kB, which includes several frozen libraries).
ladyada commentedon Jun 3, 2022
you could try the circuit playground bluefruit instead! it has a ton of flash/ram :)