Add Pico presets engine, patterns, and tests.
Wire the Pico to UART-driven preset selection, add pattern modules and presets data, remove old p2p/settings code, and update tests and LED driver. Made-with: Cursor
This commit is contained in:
32
pico/test/test_serial_receive.py
Normal file
32
pico/test/test_serial_receive.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Serial receive test – single file. Run on Pico (RX side).
|
||||
Wire: ESP32 TX (GPIO17) → Pico RX (GPIO1); GND ↔ GND. Run send test on ESP32.
|
||||
mpremote run pico/test/test_serial_receive.py
|
||||
"""
|
||||
import time
|
||||
import sys
|
||||
from machine import UART, Pin
|
||||
|
||||
if "esp32" in sys.platform:
|
||||
UART_ID, TX_PIN, RX_PIN, BAUD = 1, 17, 18, 115200
|
||||
else:
|
||||
UART_ID, TX_PIN, RX_PIN, BAUD = 0, 0, 1, 115200
|
||||
|
||||
print("UART receive: %s UART%d TX=%s RX=%s %d baud (10 s)" % (sys.platform, UART_ID, TX_PIN, RX_PIN, BAUD))
|
||||
uart = UART(UART_ID, baudrate=BAUD, tx=Pin(TX_PIN, Pin.OUT), rx=Pin(RX_PIN, Pin.IN))
|
||||
buf = bytearray()
|
||||
deadline = time.ticks_add(time.ticks_ms(), 10000)
|
||||
while time.ticks_diff(deadline, time.ticks_ms()) > 0:
|
||||
n = uart.any()
|
||||
if n:
|
||||
buf.extend(uart.read(n))
|
||||
while b"\n" in buf:
|
||||
idx = buf.index(b"\n")
|
||||
line = bytes(buf[:idx]).strip()
|
||||
buf = buf[idx + 1:]
|
||||
if line:
|
||||
print("rx:", line.decode("utf-8", "replace"))
|
||||
time.sleep_ms(10)
|
||||
uart.deinit()
|
||||
print("Receive test done.")
|
||||
Reference in New Issue
Block a user