Greetings @felmue!
Thank you for your reply,
Even if I space apart both sensors and direct them in different spots - they still get weird readings. As soon as I disconnect one of them from pa.hub one label gets proper readings - and other gets very simillar reading to first label (even though it is linked with disconnected sensor).
Below screenshot of readings with one sensor disconnected from pa.hub - and both labels change as soon as I get some object near the connected sensor.
462582190_1192320768525964_4002535964587001502_n.jpg
For UIflow 1 code is:
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit
setScreenColor(0x222222)
tof4m_0 = unit.get(unit.TOF4M, unit.PAHUB0)
tof4m_1 = unit.get(unit.TOF4M, unit.PAHUB2)
label0 = M5TextBox(43, 36, "label0", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(45, 88, "label1", lcd.FONT_Default, 0xFFFFFF, rotate=0)
while True:
label0.setText(str((str('odl 1 ') + str(((str(((tof4m_0.get_single_distance_value) / 10)) + str('cm')))))))
label1.setText(str((str('odl 2 ') + str(((str(((tof4m_1.get_single_distance_value) / 10)) + str('cm')))))))
wait_ms(500)
wait_ms(2)
When I try to run it on UIflow 2.0 with pa.hub I get error:
Traceback (most recent call last):
File "<stdin>", line 29, in <module>
File "<stdin>", line 20, in setup
File "driver/vl53l1x.py", line 60, in init
File "driver/vl53l1x.py", line 176, in get_model_info
File "driver/vl53l1x.py", line 273, in _read_register
TypeError: unexpected keyword argument 'addrsize'
This is my code for uiflow 2 - and it does not work
import os, sys, io
import M5
from M5 import *
from hardware import *
from unit import TOF4MUnit
from unit import PAHUBUnit
label0 = None
label1 = None
i2c1 = None
pahub_0 = None
tof4m_2 = None
tof4m_0 = None
def setup():
global label0, label1, i2c1, pahub_0, tof4m_2, tof4m_0
M5.begin()
Widgets.fillScreen(0x222222)
label0 = Widgets.Label("label0", 44, 65, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
label1 = Widgets.Label("label1", 43, 111, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
i2c1 = I2C(1, scl=Pin(22), sda=Pin(21), freq=100000)
tof4m_0 = TOF4MUnit(PAHUBUnit(i2c=i2c1, channel=1), 0x29)
tof4m_2 = TOF4MUnit(PAHUBUnit(i2c=i2c1, channel=0), 0x29)
def loop():
global label0, label1, i2c1, pahub_0, tof4m_2, tof4m_0
M5.update()
label0.setText(str((str('Odl1 ') + str((tof4m_2.get_distance)))))
label0.setText(str((str('Odl2 ') + str((tof4m_0.get_distance)))))
if __name__ == '__main__':
try:
setup()
while True:
loop()
except (Exception, KeyboardInterrupt) as e:
try:
from utility import print_error_msg
print_error_msg(e)
except ImportError:
print("please update to latest firmware")
Thank you for help,
best,
Matt