pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit UWB

案例程序

Anchor 模式,用于固定作为锚点

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

setScreenColor(0x222222)
uwb_0 = unit.get(unit.UWB, unit.PORTC)

uwb_0.init_uwb_mode(0)
uwb_0.set_mode(0)
while True:
  if uwb_0.check_device:
    print((str('distance') + str((uwb_0.device_id))))
  wait_ms(2)

Tag 模式,移动点,获取定位

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

setScreenColor(0x222222)
uwb_0 = unit.get(unit.UWB, unit.PORTC)

uwb_0.init_uwb_mode()
uwb_0.set_mode()
while True:
  if uwb_0.check_device:
    print((str('distance') + str((uwb_0.get_distance_measure[0]))))
  wait_ms(2)

功能说明

uwb_0.init_uwb_mode()
  • 初始化Unit,设置运行模式
    • tag:标签模式
    • Anchor:锚模式
uwb_0.uart_port_id(1)
  • 设置部件ID编号
print(uwb_0.check_device)
  • 检查设备是否可用
uwb_0.continuous_output_value(0)
  • 连续值输出输出
    • Enable
    • Disable
print(uwb_0.device_id)
  • 获取设备ID
print(uwb_0.get_distance_measure[0])
  • 获取到锚点的距离
print(uwb_0.get_version())
  • 获取当前固件版本
uwb_0.set_mode(0)
  • 设置锚模式ID值
uwb_0.set_range_interval(5)
  • 设置获取数据间隔次数
uwb_0.set_mode()
  • 设置标签模式
uwb_0.update_new_value_loop()
  • 更新距离值
On This Page