multichar_input module¶
Non-blocking multi-character numeric input handler for serial interfaces.
Provides a generator-based input routine for reading floating-point numbers from a MicroPython serial port (USB_VCP or UART). Designed for use with the cooperative multitasking scheduler: the generator yields on every loop iteration so other tasks continue to run while waiting for user input.
- Supported input:
Digits 0–9, optional leading
-, optional single.Backspace / rubout (
0x7F) to delete the last characterEnter / Return (
\ror\n) to submit
- multichar_input.multichar_input(ser)[source]¶
Generator that reads a floating-point number from a serial port.
Accumulates characters one at a time, echoes valid input back to the terminal, and returns the parsed value when the user presses Enter. Yields
Noneon every iteration to cooperate with the task scheduler.- Args:
- ser: MicroPython serial object (
USB_VCPorUART) that supports any(),read(n), andwrite(s).
- ser: MicroPython serial object (
- Yields:
None: Relinquishes the CPU on every loop so other tasks can run.
- Returns:
float: The value entered by the user when Enter is pressed. None: If the user presses Enter with an empty buffer (no change).