Asynchronous user input libraries using MicroPython uasyncio library
Library for for getting user input inside uasyncio event-loop
NOTE(*):
For this to work on esp32, you need to use my fork of micropython which incorperates a hack on the UART console.
import uasyncio
from uaioinput import ainput
s = await ainput(prompt="User Input: ", password=False)
print(s)
To prevent two ainput()
being called at the same time, a global lock is
implemented at the module level.
To check lock status,
import uaioinput
print(uaioinput.input_lock.locked)
A simple(dumb) REPL console that runs inside uasyncio event-loop.
Features are severely limited comparing to the standard REPL,
only basic operations are supported.
NOTE(*):
ctrl+b
for manual linebreak
For this to work on esp32, you need to use my fork of micropython which incorperates a hack on the UART console.
import uasyncio
import uaiorepl
loop = uasyncio.get_event_loop()
loop.call_soon(uaiorepl.start())
loop.run_forever()
Modified telnet server that runs inside uasyncio event-loop.
Adapted from cpopp's MicroTelnetServer
NOTE(*):
Must run concurrently with a uaiorepl
or uaioinput
otherwise user input will still be blocked.
NOTE:
If you are using Putty in windows as your telnet client, then you must set the following parameters:\
- Terminal - Local echo - force off
- Terminal - Local line editing - force off
- Connection - Telnet - [UNCHECK] Return key sends Telnet New Line instead of ^M
import uasyncio, uaiotelnet, uaiorepl
loop = uasyncio.get_event_loop()
loop.call_soon(uaiotelnet.start(ip="0.0.0.0", port=23))
loop.call_soon(uaiorepl.start()) # uasyncio repl will process telnet input
loop.run_forever()
The offical implementation of WebREPL relies on socket interrupt and can be horribly slow.
This modified WebREPL runs inside uasyncio event-loop and is way faster than the official one.
Adapted from the offical WebREPL for ESP8266
NOTE:
Must run concurrently with uaiorepl
or uaioinput
otherwise user input will still be blocked.
import uasyncio, uaiowebrepl, uaiorepl
loop = uasyncio.get_event_loop()
loop.call_soon(uaiowebrepl.start(ip="0.0.0.0", port=8266, password=123))
loop.call_soon(uaiorepl.start()) # uasyncio repl will process webrepl input
loop.run_forever()