Home AMX User Forum AMX Design Tools

Touch Panel Buttons

I hope this isn't too basic of a question, but I haven't been able to attend programming I yet, and I was wondering about a couple simple things.

First, how do you make a button do two things? E.g. Mute. Let's take a Pioneer Elite receiver I am working on. It has a mute on and mute off through RS-232. I can also query what the status is. Where or how do you store that return value/query? I was thinking that I could take that info and put it in an if/else loop. Would that be the easiest/most efficient?

Second, I decided to play with the aluminum smoke panel. For the DSS, it can bring up a keypad to type in a channel. How do you a) limit input to only 3 digits; b)extract those 1-3 digits in order to pulse the satellite receiver to change to the appropriate channel?

I guess the bottom line is that I have figured out how to send information to equipment based on button pushes, but I don't know how to ask the panel for anything more than a PUSH,HOLD, or RELEASE.

Thanks,

Eric

Comments

  • Eric;
    First, how do you make a button do two things? E.g. Mute. Let's take a Pioneer Elite receiver I am working on. It has a mute on and mute off through RS-232. I can also query what the status is. Where or how do you store that return value/query? I was thinking that I could take that info and put it in an if/else loop. Would that be the easiest/most efficient?
    DEFINE_DEVICE
    dvPanel = 10001:1:0
    dvReceiver = 5001:1:0
    
    DEFINE_VARIABLE
    INTEGER nReceiverMute
    
    DEFINE_EVENT
    BUTTON_EVENT[dvPanel,1] // Mute Mute/Unmute
    {
    PUSH:
    {
    IF(nReceiverMute) // if Receiver is muted
    {
    SEND_STRING dvReceiver,'Set Unmute // Unmute
    nReceiverMute = 0 // it is Unmuted
    }
    ELSE 
    {
    SEND_STRING dvReceiver,'Set Mute
    nReceiverMute = 1
    }
    }
    }
    
    DEFINE_PROGRAM
    [dvPanel,1] = (nReveiverMute = 1) // or simpler [dvPanel,1] = nReceiverMute
    

    Second, I decided to play with the aluminum smoke panel. For the DSS, it can bring up a keypad to type in a channel. How do you a) limit input to only 3 digits; b)extract those 1-3 digits in order to pulse the satellite receiver to change to the appropriate channel?
    In G4 panel design, you can limit the length of text (or digits) within the keyborad's / keypad/s design:
    1) open the keypad (it's a popup I think)
    2) mark the text field where later the text/digits are shown
    3) in the button properties, in GENERAL tab, you can set the MAX TEXT LENGTH. If it's 0 (zero) it's not limited, in your case set this value to 3.[/QUOTE]
  • Ok, so I was close to knowing what the answer was then, but I don't think I understand it...

    The integer definition exists in order to give the button two states, but in the IF..ELSE statement it says IF(nReceiverMute), which I have seen written in other code I was looking at. If the IF(condition) is how it is written, how is IF(nReceiverMute) a condition since nReceiverMute is not a BOOLEAN expression.

    Why isn't it IF(nReceiverMute=1), for example? Is it because in DEFINE_PROGRAM you assign [dvPanel,1]=nReceiverMute=1. If you never assign dvReceiverMute to equal 1, how does it get that value? Is it passing the channel code of 1 from th tp?

    If it is passing the value, does this answer the b) part of my second question which is how do you pass information from the panel to Netlinx...i.e. a text entry field where you would enter a 3-digit channel for example?
  • cwpartridgecwpartridge Posts: 120
    The integer definition exists in order to give the button two states, but in the IF..ELSE statement it says IF(nReceiverMute), which I have seen written in other code I was looking at. If the IF(condition) is how it is written, how is IF(nReceiverMute) a condition since nReceiverMute is not a BOOLEAN expression.

    The Integer definition means nReceiverMute can hold any value from 0 to 65535. It just so happens it is only assigned the values of 0 or 1 in this snippet.

    The condition IF(nReceiverMute) evaluates to true if nReceiverMute has a value other than 0. It would evaluate to false only is nReceiverMute had a value of 0.

    Why isn't it IF(nReceiverMute=1), for example?
    It could be, but since the variable is used to track a binary value it wasn't necessary to explicitely test the value. If you were tracking more than two values in a variable, then IF(nReceiverMute=1) would test to see if value==1 was the current value.
    Is it because in DEFINE_PROGRAM you assign [dvPanel,1]=nReceiverMute=1. If you never assign dvReceiverMute to equal 1, how does it get that value? Is it passing the channel code of 1 from th tp?

    nReceiverMute was set to 1 in the ELSE clause.
    IF(nReceiverMute) // if Receiver is muted
    {
        SEND_STRING dvReceiver,'Set Unmute' // Unmute
        nReceiverMute = 0 // it is Unmuted
    }
    ELSE 
    {
        SEND_STRING dvReceiver,'Set Mute'
        nReceiverMute = 1 // <<< SET TO 1 HERE
    }
    
    If it is passing the value, does this answer the b) part of my second question which is how do you pass information from the panel to Netlinx...i.e. a text entry field where you would enter a 3-digit channel for example?

    The contents of the text-entry field would be returned as a string from the panel. See the panel docs for the exact syntax to parse as it differs between G3 and G4 panels (G4 panels allows you to set the string prefix). You would parse the string and convert the ASCII data representing the 3 digit channel number.
  • Aha! Ok...now I get it. So easy...The initial value is, of course, zero when defined. When the button is pressed the first time, it is still zero, so it mutes it and sets the value to 1. The next time it unmutes and sets back to 0. And as stated an IF (nReceiverMute) would only work if the result could be 0 or 1 and, therefore, a BOOLEAN expression. Otherwise you would have an IF..ELSEIF. as well as test for specific values of nInteger.

    Thanks!
Sign In or Register to comment.