Home AMX User Forum NetLinx Studio

Mio Classsic Question

BUTTON_EVENT[dvKeypads,nKeypad_Buttons]
{
    /*
	Steps
	
	1. Check the power state
	    Is the Power off or on?
		a. Power is off
		    i. Turn on system; switch to correct source
		b. Power is on
		    Was the source that was just selected the same source or a different one?
			i. Same Source
			    a. Do source function; change preset, track, etc
			ii. Different source
			    a. Switch to correct input 
    */
    PUSH:
    {
	nPanel_Index = GET_LAST(dvKeypads) + 5
	nPanel_Address = nPanel_Index + 144
	nButton = GET_LAST(nKeypad_Buttons)
	
	//nPush = nPush + 1
	
	debug("'MIO Keypad : ',ITOA(nPanel_Address),' - What is the current power state?'")
	SELECT
	{
	    ACTIVE(strWhPwr[nPanel_Index] = 'F' AND nButton < 5):
	    {
		debug("'MIO Keypad : ',ITOA(nPanel_Address),' - The power is off!'")
		debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Turning the power on!'")
		debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Which zone?'")
		
		
		
		ON[nPanel_Address,nButton]		/// Feedback for button #'s 1 - 4
		strWhPwr[nPanel_Index] = 'N'		/// Set room power state to on
	    }
	    ACTIVE(strWhPwr[nPanel_Index] = 'N' AND nButton < 5):
	    {
		debug("'MIO Keypad : ',ITOA(nPanel_Address),' - The power is already on!'")
		
		debug("'MIO Keypad : ',ITOA(nPanel_Address),' - What source was selected?'")
		
		IF(nPush > 1)
		{
		    nPush = 0
		    debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Same source pushed!'")
		    debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Which zone?'")
		}
		ELSE
		{
		    debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Differenet source pushed!'")
		    debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Which zone?'")
		}
		
		
		
		
		PULSE[nPanel_Address,nButton]		/// Feedback for button #'s 1 - 4
		
		WAIT 5
		{
		    ON[nPanel_Address,nButton]		/// Feedback for button #'s 1 - 4
		}
	    }
	    ACTIVE(nButton = 5):
	    {
		debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Power off selected!'")
		debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Which Zone?'")
		
		ON[nPanel_Address,nButton]		/// Feedback for button # 5
		strWhPwr[nPanel_Index] = 'F'		/// Set room power state to off
	    }
	}
    }
}

I am trying to program for the MIO Source buttons. I need it to do the following:

1. Check the power state [done]
Is the Power off or on? [done]
a. Power is off [done]
i. Turn on system; switch to correct source[done]
b. Power is on [done]
Was the source that was just selected the same source or a different one? [done]
i. Same Source
a. Do source function; change preset, track, etc
ii. Different source [done]
a. Switch to correct input

With the above code I am having I need it to do the source function until the source is change to another source. What I am running into to is, that it works fine for the 1st & 2nd push, but after the second push it resets nPush = 0 and starts over.

I guess my question is how do you setup the code to do the source function ( next track, preset, etc ) until the source is changed?

Thanks for the help

Chris Ondrovic

Comments

  • ondrovicondrovic Posts: 217
    I figured it out guess it just took me to take a step back.

    If anyone else wants to know how i did it here is the code
    BUTTON_EVENT[dvKeypads,nKeypad_Buttons]
    {
        /*
    	Steps
    	
    	1. Check the power state
    	    Is the Power off or on?
    		a. Power is off
    		    i. Turn on system; switch to correct source
    		b. Power is on
    		    Was the source that was just selected the same source or a different one?
    			i. Same Source
    			    a. Do source function; change preset, track, etc
    			ii. Different source
    			    a. Switch to correct input 
        */
        PUSH:
        {
    	nPanel_Index = GET_LAST(dvKeypads) + 5
    	nPanel_Address = nPanel_Index + 144
    	nButton = GET_LAST(nKeypad_Buttons)
    	
    	debug("'MIO Keypad : ',ITOA(nPanel_Address),' - What is the current power state?'")
    	SELECT
    	{
    	    ACTIVE(strWhPwr[nPanel_Index] = 'F' AND nButton < 5):
    	    {
    		debug("'MIO Keypad : ',ITOA(nPanel_Address),' - The power is off!'")
    		debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Turning the power on!'")
    		debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Which zone?'")
    		
    		
    		
    		ON[nPanel_Address,nButton]		/// Feedback for button #'s 1 - 4
    		strWhPwr[nPanel_Index] = 'N'		/// Set room power state to on
    	    }
    	    ACTIVE(strWhPwr[nPanel_Index] = 'N' AND nButton < 5):
    	    {
    		debug("'MIO Keypad : ',ITOA(nPanel_Address),' - The power is already on!'")
    		
    		debug("'MIO Keypad : ',ITOA(nPanel_Address),' - What source was selected?'")
    	    	
    		IF(nCur_Source = nButton)
    		{
    		    debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Same source pushed!'")
    		    debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Which zone?'")
    		}
    		ELSE
    		{
    		    nCur_Source = nButton
    		    debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Differenet source pushed!'")
    		    debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Which zone?'")
    		}
    		
    		PULSE[nPanel_Address,nButton]		/// Feedback for button #'s 1 - 4
    		
    		WAIT 5
    		{
    		    ON[nPanel_Address,nButton]		/// Feedback for button #'s 1 - 4
    		}
    	    }
    	    ACTIVE(nButton = 5):
    	    {
    		debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Power off selected!'")
    		debug("'MIO Keypad : ',ITOA(nPanel_Address),' - Which Zone?'")
    		
    		ON[nPanel_Address,nButton]		/// Feedback for button # 5
    		strWhPwr[nPanel_Index] = 'F'		/// Set room power state to off
    	    }
    	}
        }
        RELEASE:
        {
    	nCur_Source = nButton
        }
    }
    
Sign In or Register to comment.