Home AMX User Forum AMXForums Archive Threads Tips and Tricks

Button Feed Back

Good afternoon
My boss has asked for me to make the projector blank. I found the code and I created a button, so far good. But now i was asked by my boss to make the button flash when the button is pressed, to show the blank or shutter is on or enabled and to stop flashing whe is pressed again. Is there a way to do that? or to make the button turn green, when off or red when on or button pressed.

Comments

  • ericmedleyericmedley Posts: 4,177
    josefino wrote: »
    Good afternoon
    My boss has asked for me to make the projector blank. I found the code and I created a button, so far good. But now i was asked by my boss to make the button flash when the button is pressed, to show the blank or shutter is on or enabled and to stop flashing whe is pressed again. Is there a way to do that? or to make the button turn green, when off or red when on or button pressed.

    one of the oldest tricks in the book. Here's a very simple way to do it.
    define_variable
    
    volatile integer flasher
    volatile integer my_proj_mute_stat
    
    define_program
    
    wait 7
      {
      flasher=!flasher
      [dvTP,1]=flasher and my_proj_mute_stat
       // andother way to write the above is
      //[dvTP,1]=flasher && my_proj_mute_stat
      }
    
    

    I actually do this in a feedback timeline routine. But this method demonstrates how to do it.
    Hope that helps.
  • DiogoDiogo Posts: 65
    You can also select "Blink" on Feedback at the button properties.
  • FeedBack

    Thank you for the replys, I tried the code and changing the button to blink, and I was not able to get it working. Most likely that I still new to programming. I can write symple code but when it comes to this I have dificulty. Is there anything else that I did not put on the code or something else I need to add, like at the Mutually exclusive, thanks
  • viningvining Posts: 4,368
    josefino wrote: »
    Thank you for the replys, I tried the code and changing the button to blink, and I was not able to get it working. Most likely that I still new to programming. I can write symple code but when it comes to this I have dificulty. Is there anything else that I did not put on the code or something else I need to add, like at the Mutually exclusive, thanks
    Make sure the button feedback type is set to "channel" in TPD4 under the programming property tab. You can also select "Blink" as Diogo suggested so when on it will blink. If the feedback type is "none" or "momemtary" it will not respond to anything you attempt to do to this button from your program.

    Also confrirm your port and channel number while you're there. Then put send_string 0' in your code to verify your code is triggering.
  • Done

    Today finally I got the code and the button to flash, I was going nuts, any way I had to email Billy my professor to check my code, and he was able to point were problem was. Also the button was to momentary, I changed to channel and it works, thanks eric and vining for the help and specially Billy.

    BUTTON_EVENT[dvTP,87] //Shutter //TRIED TO MAKE IT FLASH
    {
    PUSH:
    {
    ON[dvTP,87]
    PROJECTOR_MUTE_STAT=!PROJECTOR_MUTE_STAT //Billy added this line
    SEND_STRING dvProjector,"$02,'OSH',$03";
    }
    }

    (***********************************************************)
    (* THE ACTUAL PROGRAM GOES BELOW *)
    (***********************************************************)
    DEFINE_PROGRAM

    (*********************BUTTON FLASH********************************)
    WAIT 7 //HERE IS WHERE I TRIED TO DEFINE TO FLASH
    {
    FLASHER=!FLASHER
    [dvTP,87]=(FLASHER && PROJECTOR_MUTE_STAT) //parentesis
    }
  • Flash

    I just want to share what I found, since I'm not an expert, as many of you and I found many of the solutions for my problems here at this forum. I got the button flashing and it was great, but when I changed source the button stayed flashing, and for professors it was going to be confusing and it was going to be more trouble for us. Here is the code that I have just in case anybody needs it.
    (***********************************************************)
    (* THE EVENTS GO BELOW *)
    (***********************************************************)
    (* **************** NAVIGATION EVENTS **************** *)

    BUTTON_EVENT[dvTP,3] // Page - PC
    { PUSH: { nCurrent_Nav = NAV_PC;
    SEND_STRING dvSwitcher,"'7!',$0D";
    SEND_STRING dvProjector,"$02,'IIS:RG1',$03";
    WAIT 20 SEND_STRING dvProjector,"$02,'OAS',$03";
    WAIT 7
    PROJECTOR_MUTE_STATUS=0} } //HERE IS WHERE THE BUTTONS STOPS FLASHING

    (* **************** PROJECTOR CONTROLS **************** *)

    BUTTON_EVENT[dvTP,87] //Shutter
    {
    PUSH:
    {
    ON[dvTP,87] //SO IT WOULD TURN ON OR SHOW THE STATUS
    PROJECTOR_MUTE_STATUS=!PROJECTOR_MUTE_STATUS
    SEND_STRING dvProjector,"$02,'OSH',$03";
    }
    }
    (***********************************************************)
    (* THE ACTUAL PROGRAM GOES BELOW *)
    (***********************************************************)

    (********************************BUTTON FLASH COMMAND**********************)
    WAIT 7
    {
    FLASHER=!FLASHER
    [dvTP,87]=(FLASHER && PROJECTOR_MUTE_STATUS)
    }
    IF(PROJECTOR_MUTE_STATUS)
    {
    [dvTP,87]=FLASHER
    }

    Again I want to thank all the people that takes time to help and post the solutions for people like me.
  • viningvining Posts: 4,368
    Ok but what happens when you go back to the projector? It's now not flashing and indicates it's not muted right and that not necassaily reflecting the true state of the device.

    Not to overwhelm you but the mute state should be set by a string returned from the device that says "hey, I'm mute" not because you pushed a button to send a command or change sources. Maybe that's too much to deal with for now but what you can do for now is create another var to track your current source based on a button push to indicate the current source selected ie, nSource = 1 (avr) , nSource = 2 (projector), etc, what ever numbers you want.

    Then in your code:
    DEFINE_CONSTANT
    
    SOURCE_AVR 	= 1 ;
    SOURCE_PROJ 	= 2 ;
    SOURCE_CD	= 3 ;
    
    DEFINE_VARIABLE
    
    VOLATILE INTEGER nSource = 0 ;
    
    DEFINE_PROGRAM
    
    WAIT 7
         {
         FLASHER=!FLASHER
         
         IF(nSource == SOURCE_PROJ)
    	  {
    	  [dvTP,87] = (FLASHER && PROJECTOR_MUTE_STATUS)
    	  }
         ELSE
    	  {
    	  [dvTP,87] = PROJECTOR_MUTE_STATUS
    	  }
         }
    
    As long as you set nSource when you push a button to select a different source you button will stop flashing when not on the projector and start flashing when on the projector if muted. All other times it will reflect the correct projector mute state.

    You probably already have a var to track your current source so this should be easy to do and it doesn't require you to do a bunch of crap you're not ready for.
  • josefinojosefino Posts: 29
    Thanks

    You are right Vinning, the buton sometims is flashing and the projector is not in mute. I will try the code and the suggestions you stated, thanks for the info and pointing the problem.
Sign In or Register to comment.