Home AMX User Forum AMX Technical Discussion

single button with dual function help

I am currently working on writing programming for a DVD/VCR player and the IR codes for switching between the DVD and VCR are different channels..... how can i have a single TP button alternate between the channels

Comments

  • mpullinmpullin Posts: 949
    Set up a variable to keep track of which command you last sent the DVD/VCR player. Use the variable to determine which command you should send next, then toggle the variable every time the button is pushed. Obviously there's no real way to know whether it's on DVD or VCR input since it's an IR device, so this is the best you can do.
    DEFINE_VARIABLE
    nDVD_VCR_STATE
    
    DEFINE_EVENT
    BUTTON_EVENT[arrTP,butDVD_VCR_TOGGLE]{
         PUSH:{
              if(nDVD_VCR_STATE) PULSE[dvDVDVCR,nDVD_MODE]
              else PULSE[dvDVDVCR,nVCR_MODE]
              nDVD_VCR_STATE = !nDVD_VCR_STATE
         }
    }
    
  • It's interesting that you want to be able to do that because I usually find myself doing the opposite - that is, taking a toggle button and using some twisted method to be sure that one or the other state is definitely true.
Sign In or Register to comment.