🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    TOF Hat does not work with UIFLOW or Micropython simple example

    Bug Report
    uiflow tof
    1
    1
    2.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      AJHANCOCK
      last edited by

      Re: [UIFlow Firmware](ToF unit and ampy)


      From the published simple example for ToF hat running the Micropython code below:
      from m5stack import *
      from m5ui import *
      from uiflow import *
      import time
      import unit
      setScreenColor(0x000000)
      tof0 = unit.get(unit.TOF, unit.PORTA)
      label0 = M5TextBox(85, 83, "Text", lcd.FONT_DejaVu72, 0x08feab, rotate=0)
      label1 = M5TextBox(227, 174, "mm", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
      label2 = M5TextBox(29, 31, "distance:", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
      while True:
      label0.setText(str(tof0.distance))
      if (tof0.distance) < 300:
      rgb.setColorAll(0xff0000)
      wait(((tof0.distance) / 2000))
      rgb.setColorAll(0x000000)
      wait(((tof0.distance) / 2000))
      speaker.sing(622, 1/16)
      else:
      rgb.setColorAll(0x009900)
      wait_ms(2)

      The statement below fails with error message

      tof0 = unit.get(unit.TOF, unit.PORTA)
      Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "unit.py", line 171, in get
      File "<string>", line 1, in <module>
      File "units/_tof.py", line 5, in init
      File "libs/vl53l0x.py", line 119, in init
      File "libs/vl53l0x.py", line 174, in _available
      Unit: TOF unit maybe not connect

      1 Reply Last reply Reply Quote 0
      • First post
        Last post