<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[TOF Hat does not work with UIFLOW or Micropython simple example]]></title><description><![CDATA[<p dir="auto">Re: [UIFlow Firmware](ToF unit and ampy)</p>
<hr />
<h1>From the published simple example for ToF hat running the Micropython code below:<br />
from m5stack import *<br />
from m5ui import *<br />
from uiflow import *<br />
import time<br />
import unit<br />
setScreenColor(0x000000)<br />
tof0 = unit.get(unit.TOF, unit.PORTA)<br />
label0 = M5TextBox(85, 83, "Text", lcd.FONT_DejaVu72, 0x08feab, rotate=0)<br />
label1 = M5TextBox(227, 174, "mm", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)<br />
label2 = M5TextBox(29, 31, "distance:", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)<br />
while True:<br />
label0.setText(str(tof0.distance))<br />
if (tof0.distance) &lt; 300:<br />
rgb.setColorAll(0xff0000)<br />
wait(((tof0.distance) / 2000))<br />
rgb.setColorAll(0x000000)<br />
wait(((tof0.distance) / 2000))<br />
speaker.sing(622, 1/16)<br />
else:<br />
rgb.setColorAll(0x009900)<br />
wait_ms(2)</h1>
<p dir="auto">The statement below fails with error message</p>
<blockquote>
<blockquote>
<blockquote>
<p dir="auto">tof0 = unit.get(unit.TOF, unit.PORTA)<br />
Traceback (most recent call last):<br />
File "&lt;stdin&gt;", line 1, in &lt;module&gt;<br />
File "<a href="http://unit.py" target="_blank" rel="noopener noreferrer nofollow ugc">unit.py</a>", line 171, in get<br />
File "&lt;string&gt;", line 1, in &lt;module&gt;<br />
File "units/_tof.py", line 5, in <strong>init</strong><br />
File "libs/vl53l0x.py", line 119, in <strong>init</strong><br />
File "libs/vl53l0x.py", line 174, in _available<br />
Unit: TOF unit maybe not connect</p>
</blockquote>
</blockquote>
</blockquote>
]]></description><link>https://community.m5stack.com/topic/4863/tof-hat-does-not-work-with-uiflow-or-micropython-simple-example</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 06:43:15 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/4863.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 05 Dec 2022 15:19:34 GMT</pubDate><ttl>60</ttl></channel></rss>