M5StickC ToF Hat UIFlow example missing?



  • I would like to use the ToF Hat with the M5StickC for distance measurement.
    https://docs.m5stack.com/#/en/hat/hat-tof

    The UIFlow example looks a bit short and there is no link to a piece of code.
    UIFlow ToF hat snippet

    UIFlow web has a lot of Hats in the DEMO menu, but this one is missing.

    How can I interface the ToF Hat to show the measured distance on the M5StickC display?

    Thanks
    Mike



  • Nope, that is all that is needed to show values from tof.
    The Get Distance block returns the value from sensor and other blocks handle the data. it is the same for the tof unit.
    https://github.com/Ajb2k3/UIFlowHandbook/blob/master/quickblockref.pdf
    PG197 is for the unit but its almost identicle.



  • Thanks for the hint. I forgot to add the ToF Hat in UIFlow with the Hat '+' below the M5StickC.

    alt text

    Now with the simplest program (Setup+Loop), I get an error message when ToF Hat is added:

    Traceback (most recent call last):
      File "flow/m5cloud.py", line 76, in _exec_fun
      File "<string>", line 8, in <module>
      File "hat.py", line 49, in get
      File "<string>", line 1, in <module>
      File "hats/_tof.py", line 9, in __init__
    AttributeError: 'module' object has no attribute 'init'
    

    When I remove the ToF Hat it runs again.

    Do I need to install anything? Using UIFlow v1.6.5 (web and firmware)



  • @mb You haven't added any functions to the loop and so it cant initialise the TOF hat.
    Once you add a function block and the get distance block like in the example then the micropython init code will be added.



  • The pure "Setup-Loop" block is running fine - as long as I do not add the ToF Hat.

    Now I have a loop block with functions inside, which works fine.

    alt text

    When adding the ToF Hat (just in the configuration) it breaks, I see a Traceback.

    alt text

    Even with ToF Hat and ToF function it does not work.

    alt text

    Traceback (most recent call last):
      File "flow/m5cloud.py", line 76, in _exec_fun
      File "<string>", line 9, in <module>
      File "hat.py", line 49, in get
      File "<string>", line 1, in <module>
      File "hats/_tof.py", line 9, in __init__
    AttributeError: 'module' object has no attribute 'init'
    

    I am using UIFlow v1.6.5 (web and firmware).

    Has anyone the M5StickC with ToF Hat up and running? And can share the code?



  • @mb well that is strange



  • Maybe @m5stack can have a look. Is this a bug with v1.6.5?


  • M5Stack

    @mb this is a bug. we will fix it in the next version



  • Thanks @m5stack. Will this be hours, days, weeks or months?

    Just so I know when I can move my project forward.


  • M5Stack

    @mb already fixed. you could use the new firmware version M5StickC UIFlow 1.6.5.1



  • Awesome @m5stack, thank you!



  • M5StickC and ToF Hat work great with firmware UIFlow 1.6.5.1 :)

    alt text