pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit ToF4M

案例程序

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

setScreenColor(0x222222)
tof4m_0 = unit.get(unit.TOF4M, unit.PORTA)

tof4m_0.set_distance_mode('SHORT')
tof4m_0.set_measurement_timing_budget(200)
while True:
  print(tof4m_0.get_single_distance_value)
  wait_ms(2)

功能说明

print(tof4m_0.get_single_distance_value)
  • 获取 Unit ToF4M 测量的单独距离(返回int)。单位毫米
tof4m_0.set_distance_mode('SHORT')
  • 设置 Unit ToF4M 测量的模式
    • SHORT:短距离
    • MEDIUM:中距离
    • LONG:长距离
tof4m_0.set_measurement_timing_budget(200)
  • 设置 Unit ToF4M 时间预算 (ms)
On This Page