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

    REMOTE+ Slider for motors

    Scheduled Pinned Locked Moved UIFlow
    11 Posts 4 Posters 18.6k Views 1 Watching
    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.
    • ajb2k3A Offline
      ajb2k3
      last edited by

      you need to use the map block to map the range

      UIFlow, so easy an adult can learn it!
      If I don't know it, be patient!
      I've ether not learned it or am too drunk to remember it!
      Author of the WIP UIFlow Handbook!
      M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

      1 Reply Last reply Reply Quote 0
      • W Offline
        Werner_G
        last edited by

        you are probably right. But I cannot see any similarity with the maps-function of other IDE's. Great would be a mathematical function like this from MakeCode:
        "map 'speed' from low '0' high '100' to low '-127' high '127'" (or vice versa)
        Using arrays is very compicated, too much for me.

        1 Reply Last reply Reply Quote 0
        • R Offline
          robalstona
          last edited by

          def translate(value, inMin, inMax, outMin, outMax):
              return (value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin
          
          1 Reply Last reply Reply Quote 0
          • W Offline
            Werner_G
            last edited by

            Thank you. I tried this:

            ...
            def slider_Motor_callback(slider_value):
            global inMin, inMax, outMin, outMax, tof_0
            motion = Motion()
            inMin = 0
            inMax = 100
            outMin = -127
            outMax = 127
            def translate(slider_value, inMin, inMax, outMin, outMax):
            return (slider_value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin
            motion.set_motor_speed(1, slider_value)
            ...

            But this doesn't work. What might be wrong?

            1 Reply Last reply Reply Quote 0
            • J Offline
              joueurgear
              last edited by joueurgear

              the definition of your function has been created but you have to call it now with :
              translate(slider_value, inMin, inMax, outMin, outMax)

              1 Reply Last reply Reply Quote 0
              • W Offline
                Werner_G
                last edited by

                I also tried this - but with no success. Seems that mapping or translating might not work in combination with REMOTE. Thanks for your help!

                1 Reply Last reply Reply Quote 0
                • R Offline
                  robalstona
                  last edited by

                  Try this:

                  def translate(slider_value, inMin, inMax, outMin, outMax):
                    return (slider_value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin
                  
                  def slider_Motor_callback(slider_value):
                    motion = Motion()
                    motion.set_motor_speed(1, translate(slider_value, 0, 100, -127, 127) )
                  
                  W 1 Reply Last reply Reply Quote 0
                  • W Offline
                    Werner_G @robalstona
                    last edited by

                    @robalstona

                    with this definition the motors shows absolutely no movement.

                    1 Reply Last reply Reply Quote 0
                    • R Offline
                      robalstona
                      last edited by

                      @Werner_G, probably there is a problem with remote control. In this thread is a post about it
                      https://community.m5stack.com/topic/3477/uiflow-1-8-1

                      1 Reply Last reply Reply Quote 0
                      • W Offline
                        Werner_G
                        last edited by

                        Finally, I've got it working using the map-block from Easy I/O in UIFlow (by chance I found it!), which is just

                        def slider_Motor_callback(slider_value):
                        motion.set_motor_speed(2, map_value(slider_value, 0, 100, -127, 127))

                        without any translation. Works fine with Remote+

                        1 Reply Last reply Reply Quote 0

                        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
                        • First post
                          Last post