Home AMX User Forum NetLinx Studio

A Question about Button Events...

Hello All,
I wonder if I can have the external LEDs on a MVP8400 flash anytime a Button is pressed on the TP. So my question is, can I have 2 different button events pointing to the same button and have both execute everytime a button is pressed? Or do I have to make it work with just 1 Button Event?

for example.
BUTTON_EVENT[dvTP1,0]
{
   PUSH:
   {
      //PULSE THE EXTERNAL LEDs HERE
   }
}

BUTTON_EVENT[dvTP1,6]
{
   PUSH:
   {
       //DO SOMETHING
   }
}



Will this work?

Comments

  • DHawthorneDHawthorne Posts: 4,584
    Yes, you can have duplicate and overlapping button events. I've done it by mistake enough to know they will all fire :). Event tables are created when the code starts running on the master, and any event in the tables will run on occurance of that event, without regard to how many times it appears in the tables ... at least, that is my observation. Whether there is some obscure technical limitation that isn't obvious, I would decline to say.
  • pauldpauld Posts: 106
    Thank you Dave for the quick answer.
    Paul
  • cwpartridgecwpartridge Posts: 120
    pauld wrote:
    BUTTON_EVENT[dvTP1,0]
    {
       PUSH:
       {
          //PULSE THE EXTERNAL LEDs HERE
       }
    }
    
    
    I must caution about what may be an unexpected side effect when using channel 0 as you have here. If a button event is NOT processed by an event handler, the button event is sent to mainline (DEFINE_PROGRAM) for processing. Using channel 0 in an event cause every button event to be processed by the event handler that declared channel 0, so no button event would ever be sent to mainline for processing. ANy PUSH statements you may have had in mainline will never be executed.

    If there are no PUSH or RELEASE statements in mainline, you are OK, but I wanted you to know of this behavior when using the global event handler.
  • pauldpauld Posts: 106
    Thanks for the Heads-up but, I don't use mainline at all so I should be ok. I use Timelines for all my feedback etc

    Paul
  • Button array

    Have you tryed to make a button array?
    Something like this:

    DEFINE_CONSTANT

    INTEGER BUTTONS[]={1,2}

    DEFINE_EVENT
    BUTTON_EVENT[dv_PANELS,BUTTONS]
    {
    PUSH:
    {
    TO[BUTTON.INPUT] // AS WE HOLD THE BUTTON PUT IT ON
    SWITCH(GET_LAST(BUTTONS))
    {
    CASE 1:
    {
    // DO SOMETHING
    }
    CASE 2:
    {
    // DO SOMETHING
    }

    }
    }
    }

    Good luck
  • pauldpauld Posts: 106
    Have you tryed to make a button array?
    ...

    I did think about that, but in this case I believe the general Button Event is the most efficent way of doing what I need to.

    Thanks for all the ideas everybody!

    Paul
Sign In or Register to comment.