UIFlow Guide
Continuously exchange data between uart1
and uart2
to achieve bidirectional communication.
from m5stack import *
from m5ui import *
from uiflow import *
setScreenColor(0x292929)
label0 = M5TextBox(15, 106, "Slave Baud", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(12, 130, "115200", lcd.FONT_DejaVu40, 0x02c7fc, rotate=0)
label2 = M5TextBox(15, 20, "TX", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label3 = M5TextBox(139, 20, "RX", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label4 = M5TextBox(12, 40, "G17", lcd.FONT_DejaVu40, 0x00ff38, rotate=0)
label5 = M5TextBox(136, 40, "G16", lcd.FONT_DejaVu40, 0x00ff38, rotate=0)
label9 = M5TextBox(173, 106, "/", lcd.FONT_DejaVu72, 0xFFFFFF, rotate=0)
label10 = M5TextBox(199, 125, "PC default baud", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label11 = M5TextBox(224, 149, "115200", lcd.FONT_Default, 0xFFFFFF, rotate=0)
uart1 = machine.UART(1, tx=1, rx=3)
uart1.init(115200, bits=8, parity=None, stop=1)
uart2 = machine.UART(2, tx=17, rx=16)
uart2.init(115200, bits=8, parity=None, stop=1)
while True:
if uart1.any():
uart2.write(bytes(uart1.read()))
if uart2.any():
uart1.write(bytes(uart2.read()))
wait_ms(2)
uart1 = machine.UART(1, tx=14, rx=13)
uart1.init(9600, bits=8, parity=None, stop=1)
uart1.write('' + "\r\n")
uart1
, followed by a carriage return and newline to signify the end of the line.uart1.write('')
uart1
.uart1.write(bytes([0, 0, 0]))
UART1
.str(uart1.read())
UART1
and converts it to a string.label0.set_text(str(uart1.read(10)))
UART1
, converts it to a string, and sets it as the text of label0
.str(uart1.readline())
UART1
and converts it to a string.str(uart1.any())
UART1
receive buffer and converts the result to a string.