Preset Strategy

dtucker
dtucker Junior Member
What is the general strategy for savings presets (could be channel presets, camera presets, or something else).

In general I see "push to recall a preset", and "hold to save a preset".

However, if you are trying to save a preset, the PUSH event will fire before the HOLD event, meaning any time you try and save a preset, the previous preset will be recalled and then resaved. In short, the problem is both PUSH and HOLD fire, not PUSH or HOLD.

I can think of several messy ways to solve this problem, such as setting a timer on PUSH and reading it on RELEASE to see if they pushed or held. But I figure there may be a more elegant solution.

How do you all generally go about handling presets?

Comments

  • Jim Donachiue
    Jim Donachiue Junior Member
    I use a TouchPanel Structure with a ButtonHold variable
    On HOLD:
    - the ButtonHold variable is set to True.
    - Execute Code for a HOLD Event
    On RELEASE:
    - If ButtonHold is False
    - Execute Code for a RELEASE Event that would otherwise be done in a PUSH Event
    - the ButtonHold variable is set to False.
    DEFINE_TYPE
    Struct TTouchPanel
    {
    	Integer Initialized;//Deprecate AFL v3.0
    
    	Integer State;
    	Integer OnlineStatus;
    	Integer Zone;
    
    	//Indexes
    	Integer Use;
    	Integer Source;
    	Integer Display;
    	Integer Audio;
    	Integer MatrixSource;
    	Integer MatrixDisplay;
    
    	Char ActivePage[LEN_NAME];
    	Char ActivePopup[LEN_NAME];
    
    	//A Button on the Panel is in Hold State
    	Integer ButtonHold;
    }
    
    DEFINE_EVENT
    BUTTON_EVENT[tpsAudio, btnsAudioUp]
    {
    	HOLD[5, REPEAT]:
    	{
    		System.CurrentPanelIndex = Get_Last(tpsAudio);
    		//Set ButtonHold to True
    		TTouchPanel_SetButtonHold(System.CurrentPanelIndex, True);
    		//Code to Execute
    		TTouchPanel_SetAudio(System.CurrentPanelIndex,
    			Button.Input.Channel - OFFSET_VOLUME_UP);
    		Handle_AudioVolumeUp(System.CurrentPanelIndex, True);
    	}
    	RELEASE:
    	{
    		System.CurrentPanelIndex = Get_Last(tpsAudio);
    		if ( !TTouchPanel_GetButtonHold(System.CurrentPanelIndex) )
    		{//If ButtonHold is False then execute code
    			TTouchPanel_SetAudio(System.CurrentPanelIndex,
    				Button.Input.Channel - OFFSET_VOLUME_UP);
    			Handle_AudioVolumeUp(System.CurrentPanelIndex, False);
    		}
    		//Set ButtonHold to False
    		TTouchPanel_SetButtonHold(System.CurrentPanelIndex, False);
    	}
    }
    
  • nickm
    nickm Blinky Light Aficionado
    Don't use the PUSH event. Only use the HOLD and RELEASE events. Like so:
    BUTTON_EVENT [dvTP,1] {
      PUSH : {}
      HOLD[5] : {
        nFlag = 1
    
        // save preset
      }
      RELEASE : {
        IF(!nFlag) {
          // recall preset
        }
    
       OFF[nFlag]
      }
    }
    
  • dtucker
    dtucker Junior Member
    Thanks guys. That'll work fine.
  • a_riot42
    a_riot42 AMX Wizard
    I don't use the hold event for presets due to a bug in Netlinx, which I don't think has been fixed yet. If you have multiple instances of a module running that contains a structure for the presets, when you try to do an assignment in the hold event to the structure, its always the first module's structure that gets written to.
    Paul