Home AMX User Forum NetLinx Studio

Multiple Button Event Hold Times

I'd like to set up button events with different hold times, I.E. Buttons 1-5 do a function after a hold of "5" and buttons 6-10 run after a hold of "10".

Tried putting in 2 different Hold definitions but it only lets me do one. What's the best way of doing this?

Comments

  • jabramson wrote: »
    I'd like to set up button events with different hold times, I.E. Buttons 1-5 do a function after a hold of "5" and buttons 6-10 run after a hold of "10".

    Tried putting in 2 different Hold definitions but it only lets me do one. What's the best way of doing this?
    2 different button events. That's about the only way that I know.
  • mpullinmpullin Posts: 949
    Something like this:
    BUTTON_EVENT[dvTP,btnArray]{
      HOLD[50,REPEAT]:{
        switch(BUTTON.HOLDTIME){
          case 50:
            if(GET_LAST(btnArray) <= 5){
              // do something with these
            }
          break;
          case 100:
            if(GET_LAST(btnArray) > 5){
              // do something else with these
            }
          break;
        }
      }
    }
    
  • ericmedleyericmedley Posts: 4,177
    Another approach is to just have the button event trigger a timeline that does everything and have the release kill the timeline. Thatvwaybyou can even dynamically alter the holds as you see fit upon execution.
  • BigsquatchBigsquatch Posts: 216
    mpullin wrote: »
    Something like this:
    BUTTON_EVENT[dvTP,btnArray]{
      HOLD[50,REPEAT]:{
        switch(BUTTON.HOLDTIME){
          case 50:
            if(GET_LAST(btnArray) <= 5){
              // do something with these
            }
          break;
          case 100:
            if(GET_LAST(btnArray) > 5){
              // do something else with these
            }
          break;
        }
      }
    }
    

    Very nice! I learned something new today.
  • Bigsquatch wrote: »
    Very nice! I learned something new today.

    I learned something new too!
  • a_riot42a_riot42 Posts: 1,624
    mpullin wrote: »
    Something like this:
    BUTTON_EVENT[dvTP,btnArray]{
      HOLD[50,REPEAT]:{
        switch(BUTTON.HOLDTIME){
          case 50:
            if(GET_LAST(btnArray) <= 5){
              // do something with these
            }
          break;
          case 100:
            if(GET_LAST(btnArray) > 5){
              // do something else with these
            }
          break;
        }
      }
    }
    

    Does this work in practice? I've noticed that the button.holdtime increase every time so its only 50 the first time through, and can also be slightly off from the repeat time like 51, 101, 151 instead of 50, 100, 150. When I've done this I've had to use >< to compare due to this anomaly, but normally I create two button events. I've also triggered a phantom button event from another button event to flash an LED at a fast rate while the actual hold that does something is at a slower rate. For instance if you want to send a volume up command every 5 tenths, but flash the volume LED every 1 tenth.
    Paul
  • mpullinmpullin Posts: 949
    a_riot42 wrote: »
    Does this work in practice? I've noticed that the button.holdtime increase every time so its only 50 the first time through, and can also be slightly off from the repeat time like 51, 101, 151 instead of 50, 100, 150. When I've done this I've had to use >< to compare due to this anomaly, but normally I create two button events. I've also triggered a phantom button event from another button event to flash an LED at a fast rate while the actual hold that does something is at a slower rate. For instance if you want to send a volume up command every 5 tenths, but flash the volume LED every 1 tenth.
    Paul
    I don't normally use BUTTON.HOLDTIME and REPEAT in this way, either. But I haven't seen anything to suggest BUTTON.HOLDTIME is unreliable in the way you are suggesting it is. If you have been able to produce such an anomaly, then the answer to your question is no.
  • viningvining Posts: 4,368
    I did some some tests with this some time ago and at that time it worked as a_riot42 stated. If you need precision use a timeline else use <> as suggested. For most things i also put a do_release to force and exit of the hold.
  • a_riot42a_riot42 Posts: 1,624
    mpullin wrote: »
    If you have been able to produce such an anomaly, then the answer to your question is no.

    I was able to reproduce this a while ago, unless its been fixed. I was using division on the holdtime, and it was never working out correctly. When I printed the hold time to the console I was getting values like 399, 401, 500 etc. I guess depending on what else is going on in the system you are not guaranteed that your hold will be precisely the right amount. Holdtime is in hundreds of a second and the hold is in tenths so that might account for it.
    Paul
Sign In or Register to comment.