RF433T Unit
这个库是 Unit RF433T 的驱动
支持以下产品:
UiFlow2 应用示例:
发送数据。
示例程序演示使用 RF433TUnit 和 RF433RUnit 进行通信,接收数据端请查看 RF433RUnit
在 UiFlow2 上打开 cores3_rf433t_send_example.m5f2 项目。
UiFlow2 代码块:
示例输出:
无
MicroPython 应用示例:
发送数据。
示例程序演示使用 RF433TUnit 和 RF433RUnit 进行通信,接收数据端请查看 RF433RUnit
MicroPython 代码块:
1# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from unit import RF433TUnit 9 10 11title0 = None 12label0 = None 13label_cnt = None 14rf433t_0 = None 15cnt = None 16tx_buf = None 17 18 19def btnPWR_wasClicked_event(state): 20 global title0, label0, label_cnt, rf433t_0, cnt, tx_buf 21 cnt = cnt + 1 22 tx_buf[-1] = cnt 23 rf433t_0.send(tx_buf) 24 label_cnt.setText(str((str("Count: ") + str(cnt)))) 25 26 27def setup(): 28 global title0, label0, label_cnt, rf433t_0, cnt, tx_buf 29 M5.begin() 30 title0 = Widgets.Title("RF433T Send Data", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu24) 31 label0 = Widgets.Label( 32 "Press Power Button Send", 41, 54, 1.0, 0xFFFFFF, 0x000000, Widgets.FONTS.DejaVu18 33 ) 34 label_cnt = Widgets.Label("Count", 115, 118, 1.0, 0x00FF00, 0x000000, Widgets.FONTS.DejaVu18) 35 BtnPWR.setCallback(type=BtnPWR.CB_TYPE.WAS_CLICKED, cb=btnPWR_wasClicked_event) 36 rf433t_0 = RF433TUnit((8, 9)) 37 tx_buf = bytearray(3) 38 tx_buf[-1] = 0 39 tx_buf[0] = 0 40 cnt = 0 41 tx_buf[-1] = cnt 42 43 44def loop(): 45 global title0, label0, label_cnt, rf433t_0, cnt, tx_buf 46 M5.update() 47 48 49if __name__ == "__main__": 50 try: 51 setup() 52 while True: 53 loop() 54 except (Exception, KeyboardInterrupt) as e: 55 try: 56 from utility import print_error_msg 57 58 print_error_msg(e) 59 except ImportError: 60 print("please update to latest firmware")
示例输出:
无