UIFlow Guide
from m5stack import *
from m5ui import *
from uiflow import *
import module
setScreenColor(0x222222)
packet_size = None
check = None
lora433 = module.get(module.LORA433)
def lora433_callback(size):
global packet_size, check
packet_size = size
if packet_size:
check = lora433.read_packet()
print(check)
pass
def buttonA_wasPressed():
global packet_size, check
lora433.set_begin_packet()
lora433.write_packet([0x48, 0x65, 0x6C, 0x6C, 0x6F])
lora433.set_end_packet()
pass
btnA.wasPressed(buttonA_wasPressed)
lora433.init_lora_module(cs=5, rst=13, irq=34)
lora433.set_lora_config(freq=433000000, band=125000, TxPow=17, sync=0x34, spreadfactor=7, crate=5, preamble=8, CRC=False)
lora433.set_receive_callback_handler(lora433_callback)
import module
lora433 = module.get(module.LORA433)
lora433.init_lora_module(cs=5, rst=13, irq=34)
lora433.set_lora_config(freq=433000000, band=125000, TxPow=17, sync=0x34, spreadfactor=7, crate=5, preamble=8, CRC=False)
初始化LoRa配置:
详细配置参数含义与作用范围请参考 sx127x datasheet
lora433.write_str_packet('')
lora433.set_begin_packet()
lora433.write_packet([0x48, 0x65, 0x6C, 0x6C, 0x6F])
lora433.set_end_packet()
lora433.set_receive_callback_handler(lora433_callback)
def lora433_callback(size):
global packet_size
packet_size = size
pass
lora433.read_str_packet()
lora433.read_packet()
lora433.get_rssi()
lora433.get_snr()
lora433.set_sleep_mode()
lora433.set_standby_mode()