UIFlow 上手教程
初始化 RS232 通信模块(UART1),并在循环中检查是否有剩余缓存数据,如果有,则读取并显示所有字节数据,同时生成一个随机整数
from m5stack import *
from m5ui import *
from uiflow import *
import module
setScreenColor(0x00006d)
rand = None
rs232 = module.get(module.RS232)
import random
rs232_1 = rs232.init(1, tx=17, rx=16, baudrate=9600, data_bits=8, stop_bits=1, parity=None)
while True:
if rs232_1.any():
print((str('show all bytes:') + str((rs232_1.read()))))
rand = random.randint(100000, 999999)
wait_ms(2)
any()
rs232.init(1, tx=17, rx=16, baudrate=9600, data_bits=8, stop_bits=1, parity=None)
read()
readline()
read(10)
write(''+"\r\n")
write(''+"\r\n")
write(bytes([0, 0, 0]))