TOF Hat does not work with UIFLOW or Micropython simple example
-
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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login