Home AMX User Forum NetLinx Studio

Mutliple touchpanels on one master

I have recently finished a system that had 2 touch panels on one master, in which each master looked the same and acted the same but you were able to control them independently. I basically was in a hurry so i just doubled up on all the button events and on the feedback.

I was wondering if there was a preferred method or even an easier method to handle this event. I tried to use virtual TP's but that seemed to cause problems, and i also tried a TP array but maybe I just implemented it incorrectly not sure. Has anybody come across this before and if so how did you do it?

Thanks in advance for any advice,
tony

Comments

  • mpullinmpullin Posts: 949
    twilliams wrote:
    I have recently finished a system that had 2 touch panels on one master, in which each master looked the same and acted the same but you were able to control them independently. I basically was in a hurry so i just doubled up on all the button events and on the feedback.

    I was wondering if there was a preferred method or even an easier method to handle this event. I tried to use virtual TP's but that seemed to cause problems, and i also tried a TP array but maybe I just implemented it incorrectly not sure. Has anybody come across this before and if so how did you do it?

    Thanks in advance for any advice,
    tony

    First, you'd define each panel: e.g.
    dv_TP1 = 10001:1:0
    dv_TP2 = 10002:1:0

    Then, you would make an array as follows:
    DEV TouchPanels[] = {dv_TP1,dv_TP2}

    For all of your button events, you would include the array instead of a device:
    BUTTON_EVENT[TouchPanels,12]{
       PUSH:{  // this event will happen if button 12 is pushed on either panel
           ON[BUTTON.INPUT.DEVICE,14]  // turns on channel 14 on the panel that was just used to create this event
           nLastPanelUsed = GET_LAST(TouchPanels) // this variable now contains a 1 or 2 depending on which touchpanel was used to create the event
       }
    }
    

    Hope that helps.
  • if i have this:
    devchan buttons1[] = {{tp1,1},{tp1,2}}
    devchan buttons2[] = {{tp2,1},{tp2,2}}

    if seemed when i wrote the button event the following away it didnt seem to work correctly:

    button_event[buttons1]
    button_event[buttons2]
    {
    push:{

    var1 = get_last(buttons1)
    var2 = get_last(buttons2)

    if(var1 > 0) {var3 = var1}
    else if(var2 >0) {var2 = var2}

    switch(var3)
    {
    }

    var1 = var2 = var3 = 0
    }
    }

    and it always seem to only go into the virst if statment everytime. this is how i wrote it until i just gave up because of time and seperated each button event. am i missing something on way it always hit the first condition statement?
  • alexanboalexanbo Posts: 282
    I tend to stay as far away from devChan's as possibly and use the devArray as the previous poster mentioned.

    That way you can do something like this

    dvTP is an array of Touchpanels and buttons is an array of integers indicating channel numbers.

    Button_Event[dvTP,buttons]
    {
    Push:
    {
    Switch(GetLast(buttons))
    {
    Case 1:{Send_command dvTP[GetLast(dvTP)],"'PAGE-1'"}
    Case 2:{Send_command dvTP[GetLast(dvTP)],"'PAGE-2'"}
    }
    }
    }
  • more time for beer

    Button_Event[dvTP,buttons]
    {
    Push:
    {
    stack_var integer iButton, iTp

    iTp = GET_LAST(dvTP)
    iButton = GET_LAST(buttons)
    Switch(iButton)
    {
    Case 1:{Send_command dvTP[iTp],"'PAGE-1'"}
    Case 2:{Send_command dvTP[iTp],"'PAGE-2'"}
    }
    }
    }


    Blah!
  • alexanboalexanbo Posts: 282
    Lol the funny thing was before i put in the Send Command i just had blah in the brackets....

    shouldn't it be nTP and nButton if you're going to use prefixes :P
  • I save the "standard" prefixes for globals (using reverse scottish notation of course). For example in a speech emulation program I might hold a standard salutation in the global variable char cSaysI[] = GFY
  • alexanboalexanbo Posts: 282
    Geez I haven't thought about reverse Scotish notation since the last time I had to do some changes at one of your old jobs :P

    You should get Billy to teach that in Programmer I.....
  • alexanbo wrote:
    Geez I haven't thought about reverse Scotish notation since the last time I had to do some changes at one of your old jobs :P

    http://www.acurazine.com/forums/images/smilies/finger.gif
  • mpullinmpullin Posts: 949
    I have yet to find a place in my own programming where a DevChan is useful. I've always used DEV[] Arrays.

    Also, I don't think you can do "val1 = val2 = val3" in this language. I know you can in C, because the = operator returns a value, so that (val2 = val3) would set val2 to equal val3 and evaluate to val3, and you get val1 = (val3), etc. I'm not sure the = operator returns anything in NetLinx, correct me if I'm wrong.
Sign In or Register to comment.