UIFlow Guide
点击 ButtonA 按钮,点亮 QR-Code2 LED 灯,触发扫描,扫描成功输出数据到控制台。
from m5stack import *
from m5ui import *
from uiflow import *
from base.QRCode2 import QRCode2
import time
data = None
qrcode2 = QRCode2(1)
def qrcode2_event_cb(qrdata):
global data
data = qrdata
print(data.decode())
pass
qrcode2.set_event_cb(qrcode2_event_cb)
def buttonA_wasPressed():
global data
qrcode2.set_trigger_key()
pass
btnA.wasPressed(buttonA_wasPressed)
print(qrcode2.get_firmware_version())
print(qrcode2.get_hardware_model())
qrcode2.set_light_brightness(75)
qrcode2.set_trigger_mode(0)
while True:
qrcode2.event_poll_loop()
wait_ms(100)
wait_ms(2)
qrcode2 = QRCode2(1)
print(qrcode2.get_baudrate())
print(qrcode2.get_data(False))
print(qrcode2.get_data_length())
print(qrcode2.get_firmware_version())
print(qrcode2.get_hardware_model())
qrcode2.set_baudrate(115200)
qrcode2.set_light_brightness(57)
qrcode2.set_trigger_cmd(0x01)
qrcode2.set_trigger_key()
qrcode2.set_trigger_mode(5)
data = None
def qrcode2_event_cb(qrdata):
global data
data = qrdata
pass
while True:
qrcode2.event_poll_loop()
wait_ms(100)
wait_ms(2)