English
English
简体中文
日本語

UiFlow Tutorial

UiFlow1 Development Guide

Project Management

Use LTE network

UiFlow1 Blockly

Event

Unit

Unit ToF4M

Example

Get the distance data measured by the device

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)

API

print(tof4m_0.get_single_distance_value)
  • Gets the individual distance measured by Unit ToF4M (returns int). Unit millimeter
tof4m_0.set_distance_mode('SHORT')
  • Set the measurement mode of Unit ToF4M
    • SHORT:indicates a short distance
    • MEDIUM:indicates the medium distance
    • LONG:indicates a long distance
tof4m_0.set_measurement_timing_budget(200)
  • Set up Unit ToF4M Time Budget (ms)
Page Tools
PDF
On This Page