pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit PaHUB

案例程序

通过 Unit PaHUB 分线,连接多款 Unit ToF ,实现Unit ToF 的激光测距功能

from m5stack import *
from m5ui import *
from uiflow import *
import unit

setScreenColor(0x222222)
pahub_0 = unit.get(unit.PAHUB, unit.PORTA, 0x70)
tof_0 = unit.get(unit.TOF, unit.PAHUB0)

label0 = M5TextBox(130, 119, "label0", lcd.FONT_Default, 0xFFFFFF, rotate=0)
pahub_0.select(0, 1)
while True:
  print(tof_0.distance)
  label0.setText(str(tof_0.distance))
  wait_ms(2)

功能说明

pahub_0 = unit.get(unit.PAHUB, unit.PORTA, 0x70)
  • 设置通道状态为开启(通道选择)
pahub_0 = unit.get(unit.PAHUB, unit.PORTA, 0x70)

-置通道状态为开启(通过变量控制通道)

pahub_0 = unit.get(unit.PAHUB, unit.PORTA, 0x70)
  • 设置通道对应 value 值(十六进制),进行通讯
pahub_0 = unit.get(unit.PAHUB, unit.PORTA, 0x70)
  • 设置通道状态(通道选择)
pahub_0 = unit.get(unit.PAHUB, unit.PORTA, 0x70)
  • 通过变量设置通道状态(通道变量控制)
On This Page