Home AMX User Forum AMX General Discussion

Having toggle for an array

I've got a group of buttons that control a set up popup pages. I have set the buttons as an array to easily turn them off when the tp turns off the popups. I am trying to have them as toggle buttons for the popups and stay on when the popup is showing. what i have works fine on the first press (showing the page) and the second (hiding the page) but the third press of the same button will not work - the button won't become active but the popup does show (popups are a function of the touch panel file).



BUTTON_EVENT [ENVIRO_BUTTONS] //BOTTOM BAR TOGGLES
{
PUSH :
{
[vdvTP_1,BUTTON.INPUT.CHANNEL]=![vdvTP_1,BUTTON.INPUT.CHANNEL]
}
}

I'm sure it's something simple -- what am i missing?

Comments

  • ericmedleyericmedley Posts: 4,177
    You touch on a subject that is covered and debated much on this forum. I'll give you may advice. However, you'll probably get a much heated reply that favors the other point-of-view.

    I would not use the panel's built-in popup navigation. The reason is what you've just discussed that the panel can change and you not know what the heck happened.

    What I'd do is this:

    Create a variable array that has the names of all the popups you want to track.

    Example:
    DEFINE_VARIABLE
    popup_name[100][50] // 100 Possible popup names by 50chars long
    TP_BUTTON_PUSHED
    
    DEFINE_MUTUALLY_EXCLUSIVE
    ([TP_1].. [TP_100]) // Makes sure only one light on a time.
    
    DEFINE_START
    popup_name[1]='house audio zone 1'
    popup_name[2]='house audio zone 2
    popup_name[3]='house audio zone 3
    popup_name[4]='house audio zone 4'
    //etc..
    popup_name[21]='dvd controls'
    //etc.. so on and so forth
    
    DEFINE_EVENT
    BUTTON_EVENT[TP_1,BUTTONS_1_THRU_100]
    {
    push:
      {
      TP_BUTTON_PUSHED=BUTTON.INPUT.DEVICE
      CURRENT_ACTIVE_POPUP=TP_BUTTON_PUSHED
      SEND_COMMAND TP_!, " 'ppon-',popup_name[TP_BUTTON_PUSHED]"
      ON[TP_1,TP_BUTTON_PUSHED]
      }
    }
    
    

    This is an overly simplified way to do it but I think it illustrates the idea.
    I commonly have several popups open and how they interrelate is dependent upon what the client is doing at the time and whether or not what they're doing is more system wide or local in nature. (I deal with installs with 20 or more touch panels)

    If I had to manage that kind of navigation in the touch panels themselves, I'd go stark-raving mad. The way I have it set up is nice since I make only one TP file. IT goes in every panel in the house no matter where or what it is.

    It contains every single popup, graphic, button for every possible thing going on in the install. The code actually handles what that panel at whatever address is actually supposed to do. For example: if the room has a home theater associated with it, it will call up the proper buttons, popups and graphics that relate to that room. If the panel is located elsewhere, the client will never see those items on that panel.

    Or even more nicely, I get a call from Mr. client and he says he dropped his MVP8400 in the pool and wants to watch the game in 20 minutes. I can tell him to grab another one, re-address it and Ta-Da, the panel becomes the one that runs his theater without reprogramming anything.

    That's my 2 cents...
    later
    ejm
  • DHawthorneDHawthorne Posts: 4,584
    I'm one of those that likes to put page flips in the panel when possible, but I won't get into that debate right now :). Besides, there are definitely times when it makes the most sense to do it in code. Getting "religious" about doing it one way or the other just limits you. Do what is best for the task at hand.

    I think the problem with your code, however, is the difference between input channels, output channels, and feedback channels. Output and feedback are not necessarily the same thing, but the program determines what you want by interpreting the code; you can't address them explicitly (that I know of, except for the TOTAL_OFF keyword, which isn't quite the same). My guess is that syntax is following the output channel on the right side, and the feedback on the left, and so causing the inconsistent results. Changing one doesn't necessarily change the other, or at least not right away. I don't know how the differences are handled, but I suspect it varies with the type of channel and whether it tracks a hardware device, or a virtual, or a button.

    At least, that's my understanding of it, which, admittedly, is somewhat murky.
  • viningvining Posts: 4,368
    You could do something like. I don't track channel states unless I'm working on an existing module but if I were this is one possiblity. Depending on where your channel button numbers for this begin you may need to subtract an offset from the channel number to work with the pop up array which holds your pop up names.
    BUTTON_EVENT [ENVIRO_BUTTONS] //BOTTOM BAR TOGGLES
         
         {
         PUSH :
    	  {
    	  [vdvTP_1,BUTTON.INPUT.CHANNEL]=![vdvTP_1,BUTTON.INPUT.CHANNEL]
    	  if([vdvTP_1,BUTTON.INPUT.CHANNEL])
    	       {
    	       SEND_COMMAND BUTTON.INPUT.DEVICE,"'PPON-',cPopUpArry[BUTTON.INPUT.CHANNEL]"
    	       }
    	  else
    	       {
    	       SEND_COMMAND BUTTON.INPUT.DEVICE,"'PPOF-',cPopUpArry[BUTTON.INPUT.CHANNEL]"
    	       }
    	  }
         }
    

    To chime in on pop up control once again since it's been over a month since it's been discussed I believe doing either way is completely acceptable and which way you go depends on what your needs are. I've never done a system completely one way or the other. If it were a perfect world I would prefer doing it all in code but since my world far from perfect and there are so many other things more important I can do to improve my code doing more than is necassary to control pop ups will stay a low priority. When you have to, you have to. When you don't do what you feel like doing or what time permits.
Sign In or Register to comment.