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