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

    UiFlow 2.0 discuss(how-to, bug, feature request or sometings)

    UiFlow 2.0
    69
    178
    173.9k
    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.
    • S
      sorphin @felmue
      last edited by

      @felmue Thanks for confirming as well Felix. I did find that I could make it work in a round about way as well (using rfid.RFID (no parenthesis)).. but one shouldn't have to do that :/

      1 Reply Last reply Reply Quote 1
      • CAT the TechC
        CAT the Tech
        last edited by

        I am programming using UiFlow 2.0 on my M5Stack Stick C Plus 2.

        I have 3 issues currently:

        • 1
          When I burn UiFlow 2.0 using M5Burner, the tool shows esptool being used, which reports the file size being ~20KB.
          This is very fast (less than a minute).

          When I use UiFlow 2.0's web interface to upload my program (~20KB) via USB in the web terminal, however, It is very very slow (~2-3 minutes).

          The issue also happens when I upload a file from the web terminal.

        • 2
          When I upload a file or program, it results in an empty (0 Bytes) file! (most of the time), I burned the old Alpha-29 version of UIFlow 2 on my device using M5Burner, and this problem is fixed

        • 3
          Half of the time, when I run the program, the colors are inverted (instead of RGB, it's BGR, literally)

        1 Reply Last reply Reply Quote 0
        • P
          Peter
          last edited by

          I would like to use the touchscreen on the M5Dial. But the block M5.Touch.getCount() does not work in a while loop! It only works in the main loop. So the touchscreen is hardly usable in Micropython. I have not been able to realize the waiting for a touch.

          1 Reply Last reply Reply Quote 0
          • felmueF
            felmue
            last edited by felmue

            Hello @Peter

            the trick is to add an M5.update() statement (using an Execute mpy Code block) inside the while loop.
            See UIFlow2 Project Zone example: M5Dial_Touch_Get_Count_In_While_Loop_UIFlow2.0.4

            Thanks
            Felix

            GPIO translation table M5Stack / M5Core2
            Information about various M5Stack products.
            Code examples

            P 1 Reply Last reply Reply Quote 0
            • P
              Peter @felmue
              last edited by

              @felmue Thanks Felix, it works:)
              I didn't look to the Project Zone. I'll do it now.

              1 Reply Last reply Reply Quote 0
              • R
                Raed.Alnuaimi
                last edited by

                Hi...
                How to add custom block (m5b) to UiFlow2.0???

                1 Reply Last reply Reply Quote 0
                • H
                  HéctorD
                  last edited by

                  Is there any way to port projects from UiFlow 1 to UiFlow 2 (.m5f to .m5f2)?

                  I've been searching in the forum but didn't find any message about it.

                  I've to start all my development from zero or there is any way to port projects from one system to the another?

                  I've several developments for M5StickC.

                  If it is possible, I think it must be put more visible how to do it. If it's not possible, it must be warning in some place to be visible too.

                  Thanks.

                  1 Reply Last reply Reply Quote 1
                  • CAT the TechC
                    CAT the Tech
                    last edited by

                    Since update 2.0.9, the buttons on my M5Stack Stick C Plus 2 have been tangled and unusable

                    The button A and power button (aka button C) are now unresponsive. Their respective callbacks do not get triggered at all.
                    The button B will trigger the callback for button A!

                    Here is my test program:
                    uiflow2_block_1720288367871.png

                    import os, sys, io
                    import M5
                    from M5 import *
                    from hardware import *
                    import time
                    
                    
                    
                    
                    
                    
                    def btnA_wasPressed_event(state):
                      print('Pressed A')
                    
                    
                    def btnA_wasReleased_event(state):
                      print('Released A')
                    
                    
                    def btnB_wasPressed_event(state):
                      print('Pressed B')
                    
                    
                    def btnB_wasReleased_event(state):
                      print('Released B')
                    
                    
                    def btnPWR_wasPressed_event(state):
                      print('Pressed PWR')
                    
                    
                    def btnPWR_wasReleased_event(state):
                      print('Released PWR')
                    
                    
                    def setup():
                    
                      print('hello M5')
                      M5.begin()
                      BtnA.setCallback(type=BtnA.CB_TYPE.WAS_PRESSED, cb=btnA_wasPressed_event)
                      BtnA.setCallback(type=BtnA.CB_TYPE.WAS_RELEASED, cb=btnA_wasReleased_event)
                      BtnB.setCallback(type=BtnB.CB_TYPE.WAS_PRESSED, cb=btnB_wasPressed_event)
                      BtnB.setCallback(type=BtnB.CB_TYPE.WAS_RELEASED, cb=btnB_wasReleased_event)
                      BtnPWR.setCallback(type=BtnPWR.CB_TYPE.WAS_PRESSED, cb=btnPWR_wasPressed_event)
                      BtnPWR.setCallback(type=BtnPWR.CB_TYPE.WAS_RELEASED, cb=btnPWR_wasReleased_event)
                    
                    
                    
                    def loop():
                      M5.update()
                      time.sleep_ms(50)
                    
                    
                    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")
                    

                    All was working well in UiFlow 2.0.8 yesterday, please fix this so I can continue to use it.

                    lbuqueL 1 Reply Last reply Reply Quote 0
                    • CAT the TechC
                      CAT the Tech
                      last edited by CAT the Tech

                      I also tried some other methods since, none of them had the desired effect:

                      Method 2 - Pin buttons

                      • This method works only with mode High (pull_low=False), with or without pull
                      • It is incredibly slow to respond (about 1 second)
                      import os, sys, io
                      import M5
                      from M5 import *
                      from hardware import *
                      import time
                      
                      
                      
                      Btn37 = None
                      Btn39 = None
                      Btn35 = None
                      
                      
                      def btn37_wasPressed_event(state):
                        global Btn37, Btn39, Btn35
                        print('Pressed A')
                      
                      
                      def btn39_wasPressed_event(state):
                        global Btn37, Btn39, Btn35
                        print('Pressed B')
                      
                      
                      def btn35_wasPressed_event(state):
                        global Btn37, Btn39, Btn35
                        print('Pressed PWR')
                      
                      
                      def btn35_wasReleased_event(state):
                        global Btn37, Btn39, Btn35
                        print('Released PWR')
                      
                      
                      def btn39_wasReleased_event(state):
                        global Btn37, Btn39, Btn35
                        print('Released B')
                      
                      
                      def btn37_wasReleased_event(state):
                        global Btn37, Btn39, Btn35
                        print('Released A')
                      
                      
                      def setup():
                        global Btn37, Btn39, Btn35
                      
                        print('hello M5')
                        M5.begin()
                        # Pin 37 == button A
                        # Pin 39 == button B
                        # Pin 35 == button PWR (aka button C)
                        Btn37 = Button(37, active_low=False, pullup_active=False)
                        Btn37.setCallback(type=Btn37.CB_TYPE.WAS_PRESSED, cb=btn37_wasPressed_event)
                        Btn37.setCallback(type=Btn37.CB_TYPE.WAS_RELEASED, cb=btn37_wasReleased_event)
                        Btn39 = Button(39, active_low=False, pullup_active=False)
                        Btn39.setCallback(type=Btn39.CB_TYPE.WAS_PRESSED, cb=btn39_wasPressed_event)
                        Btn39.setCallback(type=Btn39.CB_TYPE.WAS_RELEASED, cb=btn39_wasReleased_event)
                        Btn35 = Button(35, active_low=False, pullup_active=False)
                        Btn35.setCallback(type=Btn35.CB_TYPE.WAS_PRESSED, cb=btn35_wasPressed_event)
                        Btn35.setCallback(type=Btn35.CB_TYPE.WAS_RELEASED, cb=btn35_wasReleased_event)
                      
                      
                      def loop():
                        global Btn37, Btn39, Btn35
                        M5.update()
                        Btn37.tick(None)
                        Btn39.tick(None)
                        Btn35.tick(None)
                        time.sleep_ms(50)
                      
                      
                      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")
                      

                      Method 3 - machine.Pin (IRQ)

                      • It is fast, responsive
                      • It cannot report accurately if the button was pressed or released if multiple events are queued one after the other
                      import os, sys, io
                      import M5
                      from M5 import *
                      import time
                      from hardware import *
                      from machine import Pin
                      
                      
                      
                      pin37 = None
                      pin39 = None
                      pin35 = None
                      
                      
                      p = None
                      
                      # Describe this function...
                      def button_callback(p):
                        global pin37, pin39, pin35
                        i = int(str(p)[4:-1])
                        print(f"Button id: {i}, value: {p.value()}")
                      
                      
                      def setup():
                        global pin37, pin39, pin35
                      
                        print('hello M5')
                        M5.begin()
                        # Pin 37 == button A
                        # Pin 39 == button B
                        # Pin 35 == button PWR (aka button C)
                        pin37 = Pin(37, mode=Pin.IN)
                        pin39 = Pin(39, mode=Pin.IN)
                        pin35 = Pin(35, mode=Pin.IN)
                        pin37.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING, handler=button_callback)
                        pin39.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING, handler=button_callback)
                        pin35.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING, handler=button_callback)
                      
                      
                      def loop():
                        global pin37, pin39, pin35
                        M5.update()
                        time.sleep_ms(50)
                      
                      
                      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")
                      

                      Edit:
                      Oh, right, I almost forgot.
                      There is no such thing as the following in the machine.Pin method:

                      p.irq().flags()
                      

                      I don't know if it is because of the micropython port you guys use or if it is the esp32-pico-v3-02's fault, but I think there is something missing there...

                      1 Reply Last reply Reply Quote 0
                      • lbuqueL
                        lbuque @CAT the Tech
                        last edited by

                        @CAT-the-Tech I tried running your code and found that it works well.

                        CAT the TechC 1 Reply Last reply Reply Quote 0
                        • CAT the TechC
                          CAT the Tech @lbuque
                          last edited by

                          @lbuque Really?
                          Which method did you use? (1, 2, or 3)
                          What device are you using?

                          Thanks

                          lbuqueL 1 Reply Last reply Reply Quote 0
                          • CAT the TechC
                            CAT the Tech
                            last edited by

                            Since version 2.1.0, The Pin Buttons method (method 2) does not work AT ALL anymore

                            lbuqueL 1 Reply Last reply Reply Quote 0
                            • lbuqueL
                              lbuque @CAT the Tech
                              last edited by

                              @CAT-the-Tech stickc_plus2

                              1 Reply Last reply Reply Quote 0
                              • lbuqueL
                                lbuque @CAT the Tech
                                last edited by lbuque

                                @CAT-the-TechSnipaste_2024-07-19_10-05-43.png

                                cores3 works fine

                                CAT the TechC 1 Reply Last reply Reply Quote 0
                                • CAT the TechC
                                  CAT the Tech @lbuque
                                  last edited by

                                  @lbuque Weird...
                                  Can you show me the StickC Plus 2's code you used?
                                  Are you sure your core3 AND StickC Plus 2 are at the latest version? (2.1.0 as of yesterday) (You can see this when it boots, in the terminal)

                                  CAT the TechC 1 Reply Last reply Reply Quote 0
                                  • D
                                    digiponta
                                    last edited by digiponta

                                    I need it supports M5Stack DIN base with M5 stack/S3.

                                    lbuqueL 1 Reply Last reply Reply Quote 0
                                    • lbuqueL
                                      lbuque @digiponta
                                      last edited by

                                      @digiponta said in UiFlow 2.0 discuss(how-to, bug, feature request or sometings):

                                      I need it supports M5Stack DIN base with M5 stack/S3.

                                      DIN base does not require software support, it can be used directly.

                                      1 Reply Last reply Reply Quote 0
                                      • CAT the TechC
                                        CAT the Tech @CAT the Tech
                                        last edited by CAT the Tech

                                        @lbuque I tried some more ideas to make the buttons work again:

                                        M5 buttons - manual loop

                                        • Same results as the original M5 buttons method (button A and PWR (C) won't work no matter what, and button B thinks it is button A)
                                        import os, sys, io
                                        import M5
                                        from M5 import *
                                        from hardware import *
                                        import time
                                        
                                        
                                        
                                        
                                        
                                        
                                        # Describe this function...
                                        def button_check():
                                          if BtnA.wasPressed():
                                            print('Pressed A')
                                          if BtnA.wasReleased():
                                            print('Released A')
                                          if BtnB.wasPressed():
                                            print('Pressed B')
                                          if BtnB.wasReleased():
                                            print('Released B')
                                          if BtnPWR.wasPressed():
                                            print('Pressed PWR')
                                          if BtnPWR.wasReleased():
                                            print('Released PWR')
                                        
                                        
                                        def setup():
                                        
                                          print('hello M5')
                                          M5.begin()
                                        
                                        
                                        def loop():
                                          M5.update()
                                          button_check()
                                          time.sleep_ms(50)
                                        
                                        
                                        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")
                                        

                                        Pin buttons - manual loop

                                        Okay, so this one is an absolute monster via blockly (visual editor)

                                        • Same results as the original Pin buttons method (it takes some time for the buttons to register the actions and the press/release is inverted))
                                        import os, sys, io
                                        import M5
                                        from M5 import *
                                        from hardware import *
                                        import time
                                        
                                        
                                        
                                        Btn37 = None
                                        Btn39 = None
                                        Btn35 = None
                                        
                                        
                                        code_str = None
                                        Btn37_last_state = None
                                        Btn39_last_state = None
                                        Btn35_last_state = None
                                        
                                        # Describe this function...
                                        def button_check():
                                          global code_str, Btn37_last_state, Btn39_last_state, Btn35_last_state, Btn37, Btn39, Btn35
                                          if execute_mpy_code('Btn37.wasPressed()') and not Btn37_last_state:
                                            print('Pressed A')
                                            Btn37_last_state = True
                                          elif execute_mpy_code('Btn37.wasReleased()') and Btn37_last_state:
                                            print('Released A')
                                            Btn37_last_state = False
                                          if execute_mpy_code('Btn39.wasPressed()') and not Btn39_last_state:
                                            print('Pressed B')
                                            Btn39_last_state = True
                                          elif execute_mpy_code('Btn39.wasReleased()') and Btn39_last_state:
                                            print('Released B')
                                            Btn39_last_state = False
                                          if execute_mpy_code('Btn35.wasPressed()') and not Btn35_last_state:
                                            print('Pressed PWR')
                                            Btn35_last_state = True
                                          elif execute_mpy_code('Btn35.wasReleased()') and Btn35_last_state:
                                            print('Released PWR')
                                            Btn35_last_state = False
                                        
                                        # Describe this function...
                                        def execute_mpy_code(code_str):
                                          global Btn37_last_state, Btn39_last_state, Btn35_last_state, Btn37, Btn39, Btn35
                                          return eval(code_str)
                                        
                                        
                                        def setup():
                                          global Btn37, Btn39, Btn35, Btn37_last_state, Btn39_last_state, Btn35_last_state
                                        
                                          print('hello M5')
                                          M5.begin()
                                          # Pin 37 == button A
                                          # Pin 39 == button B
                                          # Pin 35 == button PWR (aka button C)
                                          Btn37 = Button(37, active_low=False, pullup_active=False)
                                          Btn39 = Button(39, active_low=False, pullup_active=False)
                                          Btn35 = Button(35, active_low=False, pullup_active=False)
                                          Btn37_last_state = False
                                          Btn39_last_state = False
                                          Btn35_last_state = False
                                        
                                        
                                        def loop():
                                          global Btn37, Btn39, Btn35, Btn37_last_state, Btn39_last_state, Btn35_last_state
                                          M5.update()
                                          Btn37.tick(None)
                                          Btn39.tick(None)
                                          Btn35.tick(None)
                                          button_check()
                                          time.sleep_ms(50)
                                        
                                        
                                        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")
                                        

                                        I believe my unit is not the issue, because the machine.Pin method worked as expected (except that I cannot get the state of the button the moment the callback was called)

                                        What are the next steps / things to try?

                                        felmueF 1 Reply Last reply Reply Quote 0
                                        • felmueF
                                          felmue @CAT the Tech
                                          last edited by felmue

                                          Hello @CAT-the-Tech

                                          using M5StickCPlus2 with UIFlow2.1.1 firmware works for me using either Button or Pin Button blocks.

                                          Button blocks example in ProjectZone: M5StickCPlus2_BtnABPWR_Test_UIFlow2.1.1

                                          Pin Button blocks example in PlayZone: M5StickCPlus2_PinButtonTest_UIFlow2.1.1

                                          Note: with Button blocks responds time is much quicker.

                                          Thanks
                                          Felix

                                          GPIO translation table M5Stack / M5Core2
                                          Information about various M5Stack products.
                                          Code examples

                                          CAT the TechC 1 Reply Last reply Reply Quote 0
                                          • CAT the TechC
                                            CAT the Tech @felmue
                                            last edited by

                                            Hi @felmue ,
                                            Unfortunately, I had the same results with your code as with mine.

                                            The only thing I changed to make your code 'work' is add print statements (I broke my screen, so no more labels for me).
                                            I also had to put the Pin Buttons' init statements to mode=High (otherwise my buttons won't work)

                                            Basically the only difference between your code and mine, other than that, is that you didn't sleep in your loop

                                            I shared my test projects too:
                                            (M5 Buttons) buttons callback test
                                            (pin buttons) buttons callback test
                                            for the pin buttons one, please fill in the callbacks' names to: [37, 37, 39, 39, 35, 35] (there is a bug that whenever you import the project they dissapear)

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