UIFlow Guide
from m5stack import *
from m5ui import *
from uiflow import *
from base.CAN import CAN
import time
frame = None
atom_can = CAN()
def buttonA_wasPressed():
global frame
atom_can.send([0, 1, 2, 3, 4, 5, 6, 7], 0)
pass
btnA.wasPressed(buttonA_wasPressed)
atom_can.can_init(0, extframe=True, mode=atom_can.NORMAL, baudrate=atom_can.BAUDRATE_250K, tx_io=22, rx_io=19, auto_restart=False)
while True:
print((str('status:') + str(atom_can.state())))
if atom_can.any():
frame = atom_can.recv()
print((str('data:') + str(frame)))
wait_ms(30)
wait_ms(2)
from base.CAN import CAN
atom_can = CAN()
atom_can.can_init(0, extframe=True, mode=atom_can.NORMAL, baudrate=atom_can.BAUDRATE_250K, tx_io=22, rx_io=19, auto_restart=False)
atom_can.any()
frame = atom_can.recv()
atom_can.send([0, 1, 2, 3, 4, 5, 6, 7], id)
list
或是tuple
, 数据帧的数据长度要求是8个byte
。atom_can.setfilter(0, CAN.FILTER_RAW_SINGLE, [])
atom_can.state()
atom_can.clear_rx_queue()
atom_can.clear_tx_queue()
atom_can.clearfilter()
atom_can.restart()
atom_can.deinit()