LaserTX Unit
LASER.TX 是 M5Units 系列中的通信设备之一 —— 一款具有可调焦距的激光发射器。它主要由激光二极管构成。激光通信设备通过大气进行无线连接,其工作方式类似于光纤链路,但光束是在自由空间中传输。虽然发射端与接收端必须满足视距(line-of-sight)条件,但其优势在于无需申请广播许可,也无需铺设埋地电缆。
支持以下产品:
LaserTX 示例:
1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from unit import LaserTXUnit 9import time 10 11 12title1 = None 13label0 = None 14laser_tx_0 = None 15 16 17def setup(): 18 global title1, label0, laser_tx_0 19 20 M5.begin() 21 Widgets.fillScreen(0x222222) 22 title1 = Widgets.Title( 23 "LaserTXUnit CoreS3 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18 24 ) 25 label0 = Widgets.Label("label0", 2, 116, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 26 27 laser_tx_0 = LaserTXUnit((1, 2), mode=2, id=1) 28 laser_tx_0.init_uart(9600, 8, None, 1) 29 30 31def loop(): 32 global title1, label0, laser_tx_0 33 M5.update() 34 if M5.Touch.getCount(): 35 laser_tx_0.write("Hello") 36 label0.setText(str("Write Message")) 37 time.sleep(1) 38 else: 39 label0.setText(str("Wait to write Message")) 40 41 42if __name__ == "__main__": 43 try: 44 setup() 45 while True: 46 loop() 47 except (Exception, KeyboardInterrupt) as e: 48 try: 49 from utility import print_error_msg 50 51 print_error_msg(e) 52 except ImportError: 53 print("please update to latest firmware")
LaserRX 示例:
1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from unit import LaserRXUnit 9 10 11title0 = None 12laser_rx_0 = None 13 14 15def setup(): 16 global title0, laser_rx_0 17 18 M5.begin() 19 Widgets.fillScreen(0x222222) 20 title0 = Widgets.Title( 21 "LaserRXUnit Core2 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18 22 ) 23 24 laser_rx_0 = LaserRXUnit((33, 32), mode=2, id=1) 25 laser_rx_0.init_uart(9600, 8, None, 1) 26 27 28def loop(): 29 global title0, laser_rx_0 30 M5.update() 31 if laser_rx_0.any(): 32 print(laser_rx_0.read()) 33 34 35if __name__ == "__main__": 36 try: 37 setup() 38 while True: 39 loop() 40 except (Exception, KeyboardInterrupt) as e: 41 try: 42 from utility import print_error_msg 43 44 print_error_msg(e) 45 except ImportError: 46 print("please update to latest firmware")
LaserTX UiFlow2 应用示例:
LaserRX UiFlow2 应用示例:
class LaserTXUnit
Constructors
Methods
- LaserTXUnit.init_uart(baudrate, bits, parity, stop)
使用指定参数初始化 UART 通信。
- 参数:
UIFLOW2:

- LaserTXUnit.write(payload)
通过 UART 传输数据。
- 参数:
payload – 要通过 UART 传输的数据。
UIFLOW2:

- LaserTXUnit.on()
使用 PIN_MODE 时打开激光。
UIFLOW2:

- LaserTXUnit.off()
使用 PIN_MODE 时关闭激光。
UIFLOW2:




