I have been experimenting MicroPython on my ESP8266 for the past few days.
I needed to do some multitasking for my project however it seems there is no easy way to do it.
uasyncio turns out to be a great alternative to threads, however it blocks user input when an event loop is running.
I wrote a set of libraries that enables user input even when there are tasks running in the background.
https://github.com/shawwwn/micropython-ainput
uaioinput - Just like input() except it can be run in an event loop
uaiorepl - Crude simulation of REPL console in an event loop
uaiotelnet - Telnet server that runs in an event loop. Adapted from https://github.com/cpopp/MicroTelnetServer
uaiowebrepl - Modified WebREPL server that runs in an event loop
NOTE:
uaiotelnet /uaiowebrepl must run together with uaioinput/uaiorepl otherwise user input would still be blocked.
Should be able to work on ESP32 , but I'm still waiting for my board to arrive.
ainput - asynchronous user input libraries based on uasyncio
Re: ainput - asynchronous user input libraries based on uasyncio
That's really exciting and interesting.
Is there a technical reason uaiorepl can't be wired to the 'real' REPL, anyone?
Is there a technical reason uaiorepl can't be wired to the 'real' REPL, anyone?
Re: ainput - asynchronous user input libraries based on uasyncio
It seems there are multiple places in the source code that would block/deny user input when something is running in repl.
However, the underlying issue here I think is the design decision residing with MicroPython.
The repl execution is running as the main task, it means MicroPython won't take any input until the execution has returned.
There is no simple way to get around this, I'm afraid.