pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit ToF4M

Example

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)
On This Page