Home AMX User Forum AMX General Discussion

Metreau keypads along with TPs

I am looking for guidance on how to implement Metreau keypads (13 btns) when you have TPs and duet modules...
Each keypad must be able to control various sources (AM/FM/XM tuner, 4 Satellite boxes, DVD changer etc.)
Some room will have 2 keypads (when there is a TV in the room), others will have only one keypad (Audio only) for a total number of keypads = 27.

Do you create a UI module for the keypads and defining only buttons for the keypads?
For devices like DVD player, do you try to keep all controls for it on the same keypad instead of having Play/pause on one Kpd and then Next, Prev etc on the 2nd Kpd?

Thanks for sharing your experience on this.

Comments

  • TurnipTruckTurnipTruck Posts: 1,485
    I create a virtual device that translates keypad presses into the same devchan values as used on the touchpanels. I beleive I posted it here once. I call it "Virtual Keypad."
  • ericmedleyericmedley Posts: 4,177
    I create a virtual device that translates keypad presses into the same devchan values as used on the touchpanels. I beleive I posted it here once. I call it "Virtual Keypad."

    You could also just create two sets of button arrays and tie them to the same button_event.

    primitive example:
    define_variable
    
    volatile integer TP_Source_Buttons[]=
    {
    101,102,103,104
    }
    
    volatile integer KP_Source_Buttons[]=
    {
    1,2,3,4
    }
    
    DEFINE_EVENT
    
    button_event[TP_1,TP_Source_Buttons]
    button_event[KP_1,KP_Source_Buttons]
    {
    push:
      {
      if(button.input.channel>100) it's a TP
        {
        source=get_last(TP_Source_Buttons)
        }
      else //  <100   -   it's a keypad
        {
         source=get_last(KP_Source_Buttons)   
        }
      // you've got the source, now go do something.
      }
    }
    
    

    You could also create another dev array with both keypads and TPs and simplify it even more. Just a thought. There's lots of ways to get this gig done.
    :D
  • Pep_SDPep_SD Posts: 106
    Eric and David,

    One more time, thank you for your valuable inputs - definitely bringing different perspective to think about!
  • TurnipTruckTurnipTruck Posts: 1,485
    Latest Version
    //New in 3.10
    //Added Keypad Bringtness Commands
    
    MODULE_NAME='mdlKeyPadManager_3_10' (DEV vdvKeypadManager,						//Module Virtual Device
    									    DEV vdvKeypads[],							//Array of Virtual Keypads
    									    DEV dKeypads[],								//Array of Actual Keypads
    									    INTEGER nKeypadEnable[],					//Aray of Keypad Enable/Disable
    									    INTEGER nTableInput[][][],   //[5] [16] [2]		//Table of Keypad Assignments
    									    INTEGER nIncomingLevels[],					//Table of Incoming Levels
    									    INTEGER nOffBrightness,						//Button On Brightness
    									    INTEGER nOnBrightness)						//Button Off Brightness
    
    DEFINE_DEVICE
    
    DEFINE_CONSTANT
    VOLATILE INTEGER nTotKPs=5
    VOLATILE INTEGER nTotVKPs=3
    
    DEFINE_TYPE
    
    DEFINE_VARIABLE
    VOLATILE INTEGER nUI
    VOLATILE INTEGER nBut
    VOLATILE INTEGER nLoop
    VOLATILE INTEGER nLoopUI
    VOLATILE INTEGER nLoopBut
    VOLATILE INTEGER nTableOutput[255][nTotKPs][nTotVKPs]
    
    VOLATILE INTEGER nAssignedPort
    VOLATILE INTEGER nAssignedChannel
    
    DEFINE_LATCHING
    
    DEFINE_MUTUALLY_EXCLUSIVE
    
    DEFINE_START
    FOR (nLoopUI=1;nLoopUI<=nTotKPs;nLoopUI++)						//Loop of Each Keypad 1-5
        {
        FOR (nLoopBut=1;nLoopBut<=16;nLoopBut++)						//Loops of each Button of each keypad 1-16
    	{
    	nAssignedPort=nTableInput[nLoopUI][nLoopBut][1]
    	nAssignedChannel=nTableInput[nLoopUI][nLoopBut][2]
    	IF (nAssignedPort>0)
    	    {
    	    nTableOutput[nAssignedChannel][nLoopUI][nAssignedPort]=nLoopBut
    	    }
    	}
        }
    
    DEFINE_EVENT
    DATA_EVENT [vdvKeypads]
    {
    ONLINE:
        SET_VIRTUAL_LEVEL_COUNT(DATA.DEVICE,10)
    }
    DATA_EVENT [dKeypads]
    {
    ONLINE:
        SEND_COMMAND DATA.DEVICE,"'@BRT-',ITOA(nOnBrightness),',',ITOA(nOffBrightness)"
    }
    BUTTON_EVENT [dKeypads,0]
    {
    PUSH:
        {
        nUI=GET_LAST (dKeypads)
        IF (nKeypadEnable[nUI])
    	{
    	nBut=BUTTON.INPUT.CHANNEL
    	IF (nTableInput[nUI][nBut][1]>0)		//There is an virtual keypad button assogned to this real button
    	    {
    	    DO_PUSH_TIMED (vdvKeypads[nTableInput[nUI][nBut][1]], nTableInput[nUI][nBut][2],DO_PUSH_TIMED_INFINITE)
    	    }
    	}
        }
    RELEASE:
        {
        nUI=GET_LAST (dKeypads)
        IF (nKeypadEnable[nUI])
    	{    
    	nBut=BUTTON.INPUT.CHANNEL
    	IF (nTableInput[nUI][nBut][1]>0)		//There is an virtual keypad button assogned to this real button
    	    {
    	    DO_RELEASE (vdvKeypads[nTableInput[nUI][nBut][1]], nTableInput[nUI][nBut][2])
    	    }
    	}
        }    
    }
    
    CHANNEL_EVENT [vdvKeypads,0]
    {
    ON:
        {
        nUI=GET_LAST (vdvKeypads)
        nBut=CHANNEL.CHANNEL
        FOR (nLoop=1;nLoop<=nTotKPs;nLoop++)
    	{
    	IF (nTableOutput[nBut][nLoop][nUI]>0)
    	    ON [dKeypads[nLoop],nTableOutput[nBut][nLoop][nUI]]
    	}
        }
    OFF:
        {
        nUI=GET_LAST (vdvKeypads)
        nBut=CHANNEL.CHANNEL
        FOR (nLoop=1;nLoop<=nTotKPs;nLoop++)
    	{
    	IF (nTableOutput[nBut][nLoop][nUI]>0)
    	    OFF [dKeypads[nLoop],nTableOutput[nBut][nLoop][nUI]]
    	}
        }    
    }
    
    LEVEL_EVENT [vdvKeypads,0]
    {
    IF (nIncomingLevels[LEVEL.INPUT.LEVEL])	//There is an assigned level
        SEND_LEVEL dKeypads[nIncomingLevels[LEVEL.INPUT.LEVEL]],1,LEVEL.VALUE
    }
    
    DEFINE_PROGRAM
    
Sign In or Register to comment.