Non blocking console/keyboard input

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
uCTRL
Posts: 47
Joined: Fri Oct 12, 2018 11:50 pm

Non blocking console/keyboard input

Post by uCTRL » Fri Nov 09, 2018 7:46 am

For ESP32 Uart console/keyboard input.

Basically, need advice for non-blocking keyboard input from Uart console port, as scanned 1 character at the time.
input() and sys.stdin are blocking.

Thanks

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Non blocking console/keyboard input

Post by pythoncoder » Fri Nov 09, 2018 9:08 am

In general UARTS can operate in a non-blocking mode by using uasyncio StreamReader and StreamWriter objects. See the tutorial in this repo.
Peter Hinch
Index to my micropython libraries.

uCTRL
Posts: 47
Joined: Fri Oct 12, 2018 11:50 pm

Re: Non blocking console/keyboard input

Post by uCTRL » Fri Nov 09, 2018 9:39 am

Thanks Peter

I would also like to know if there is a simpler system call to access existing OS keyboard scan.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Non blocking console/keyboard input

Post by pythoncoder » Sat Nov 10, 2018 10:47 am

In general (and in particular on the ESP32) MicroPython runs on bare metal. There is no OS. If you want to connect a serial keyboard to an ESP32 you will need to interpret the data yourself. Unless someone has already posted code to do this.
Peter Hinch
Index to my micropython libraries.

Post Reply