Disable external button

patriot_stvpatriot_stv Junior MemberPosts: 25
Hello!

Is there a command that can disable all external buttons? I mean, I need to EXT button is only activated when a specific event on and off until the event has not occurred

Comments

  • AMXJeffAMXJeff Senior Member Posts: 450
    Set a variable inside your code that reflects when you want the buttons to work. In the button event for the external button test if that variable is on or off.
  • patriot_stvpatriot_stv Junior Member Posts: 25
    I understand it. I can not find a team that can disable the external buttons on mio r4 upon the occurrence of certain events.

    For example
    button_event [mio_1, key_volup] {push: {send_string dvReciv, 'volup}
    button_event [mio_1, key_voldw] {push: {send_string dvReciv, 'voldw}
    Etc.

    If (event1= 1) {*disable key_volup and voldw*} --- what command for disable?

    in the project I made the substitution device. it works, but I think this is the wrong decision.

    Example

    Define_variables
    DEV void_dev

    Define_event

    Channel_event {mio_1,button} {
    on: dvReciv = void_dev
    Off: dvReciv = 5001:1:1}

    button_event [mio_1, key_volup] {push: {send_string dvReciv, 'volup}
    button_event [mio_1, key_voldw] {push: {send_string dvReciv, 'voldw}

    Etc))))
  • viningvining X Member Posts: 4,341
    Try something like this:
    BUTTON_EVENT[mio_1,0]//0 catches all button events for the mio_1 dev/port
    
         {
         PUSH:
    	  {
    	  STACK_VAR INTEGER nBtn;
    	  
    	  nBtn = BUTTON.INPUT.CHANNEL;
    	  
    	  if(!nDisable)//prevents the following buttons from firing if set
    	       {
    	       SWITCH(nBtn)//these buttons will work if nDisable is not set as long as a case matches nBtn
    		    {
    		    CASE key_volup:{send_string dvReciv, 'volup';}
    		    CASE key_voldw:{send_string dvReciv, 'voldw';}
    		    CASE key_volxx:{send_string dvReciv, 'volxx';}
    		    CASE key_volyy:{send_string dvReciv, 'volyy';}
    		    }
    	       }
    	  SWITCH(nBtn)//these buttons will work regardless of the disable flag as long as a case matches nBtn
    	       {
    	       CASE key_disable:{nDisable = !nDisable;}
    	       CASE key_pwr_on: {send_string dvReciv, 'pwr_on';} 
    	       CASE key_pwr_off:{send_string dvReciv, 'wr_off';}
    	       }
    	  }
         }
    
    instead of changing your dev to a null which will likely just piss off the master when it tries to send a string to it unless your null is a virtual that is.

    Just set a var and use as a flag to determine if button pushes should be processed or not which is what AMXJeff was talking about.
Sign In or Register to comment.