Home AMX User Forum AMX Control Products

"General" Button State Change

I'm new to programming AMX and I'm wrapping my head around the various commands. One area I need a little assistance is in button states. I know that the preferred method to change the button state (say from off to on) is to make it a multi-state general and then assign it a state through the ^ANI command. I have that up and running.

I'm just curious though, is there a command to do the same with just a general on/off and not a multi-state button?

I was originally trying to figure out how to do it that way and came across the multi-state version which works fine. I'm just wondering, that's all.

Comments

  • viningvining Posts: 4,368
    jabramson wrote: »
    I'm new to programming AMX and I'm wrapping my head around the various commands. One area I need a little assistance is in button states. I know that the preferred method to change the button state (say from off to on) is to make it a multi-state general and then assign it a state through the ^ANI command. I have that up and running.

    I'm just curious though, is there a command to do the same with just a general on/off and not a multi-state button?

    I was originally trying to figure out how to do it that way and came across the multi-state version which works fine. I'm just wondering, that's all.
    I don't know where you came up with ^ANI as the preferred method, I would say that's the least preferred.

    For general channels set to channel for feedback, feedback or button state control typically occurs in an event and has:
    ON[dvTP,SomeBtnChannel] ;
    or
    OFF[dvTP,SomeBtnChannel] ;
    or
    [dvTP,SomeBtnChannel] = nVarState ; 
    or
    [dvTP,SomeBtnChannel] = (nVarState == SomeValue) ; 
    

    Then typically in a define_program or timeline you can do or in an event for that matter:
    [dvTP,SomeBtnChannel] = nVarState ; //a zero would make the channel OFF and any non zero would make it ON.
    

    Now for multi-states the preffered method IMHO would be to create a multi-state bargraph then you can just send_level to the the button of 0 to what ever to set the desired state for.
    SEND_LEVEL dvTP,SomeLevelChannel,SomeLevelValue ;
    

    A lot easier and more versatile then using the ^ANI command.
  • Button

    I agree with Vining.Here is something simple, but you also have to make sure the state is defined or set on TP4. For example the button to change from off to on or/and change color.

    ***********************************************************)
    (* VARIABLE DEFINITIONS GO BELOW *)
    (***********************************************************)
    INTEGER g_bProj_Main_Power (**BUTTON FEED BACK**)
    INTEGER g_bScreen_Down (**BUTTON FEED BACK**)

    (***********************************************************)
    (* THE EVENTS GOES BELOW *)
    (***********************************************************)
    BUTTON_EVENT[dvTP,50] // Projector On
    {
    PUSH:
    {
    SEND_STRING dvProj,"$02,'PON',$03";
    SEND_STRING dvProj,"$02,'OSH',$03";
    PROJECTOR_MUTE_STATUS = 1;
    IF (PROJECTOR_MUTE_STATUS)
    {
    SEND_STRING dvProj,"$02,'OSH:0',$03";
    }
    g_bProj_Main_Power = 1; // here button would turn green and display on
    }
    }

    BUTTON_EVENT[dvTP,51] // Projector Off
    {
    PUSH:
    {
    SEND_STRING dvProj,"$02,'POF',$03";
    g_bProj_Main_Power = 0; //here the button would turn red and display off
    }
    }

    (***********************************************************)
    (* THE ACTUAL PROGRAM GOES BELOW *)
    (***********************************************************)
    // Display Controls "FEED BACK"
    [dvTP,50] = (g_bProj_Main_Power)
    [dvTP,51] = (!g_bProj_Main_Power) //the ! means not in order to display off
    [dvTP,52] = (!g_bScreen_Down)
    [dvTP,53] = (g_bScreen_Down)

    Here is a simple code that I got from reading and trial and many errors, good luck
  • a_riot42a_riot42 Posts: 1,624
    The advantage to using ANI is that you can configure the time of the transition from one state to another in code.
    Paul
Sign In or Register to comment.