04-07-2022 07:17 AM
Dear;
Kindly note that i have created a user interface panel on my cisco codec Pro touch 10 tablet, which contains a toggle button to switch the main display on and off and a slider for controlling ceiling microphone volume and a a buttons to switch between HDMI inputs. my panel look like the attached screenshot.
i need helo with programing a Macro which is linked to each widgets created in the UI in order to apply a change as when I press off the Main display should turn off and when I press on it should turn on as well. as for now even I turn it on or off nothing happens on the main display because there is no Macros configured for the widgets yet, which I need your help in.
Thank you in advance.
05-20-2022 05:52 AM - edited 05-20-2022 06:06 AM
Hello,
Here's an example of what the macro could look like. You have to find some things yourself like: 
NOTE that your question talks about "ceiling microphone volume" but the photo shows "speaker volume". I took "microphone volume"
import xapi from 'xapi';
const my_microphone_number = 2
function onGui(event) {  //__ Process widget activity
  //__ 'slider' widgets respond to 'changed'
  if (event.Type == 'changed') {
    switch(event.WidgetId) {
      case 'mic_volume_slider':
        const newMicVolume = parseInt(event.Value / (255/70));  // based on volume range of 0..70
        // DJ: you have to check which microphone, instead of [2] below 
        xapi.Configuration.Audio.Input.Microphone[my_microphone_number].Level.set(newMicVolume);
        break;
    }
  };
  //__ button widgets respond to 'pressed'
  if (event.Type == 'pressed') {
    switch(event.WidgetId) {
      case 'my_inputselector':
        // DJ: switches to the button value (1-6) of groupbutton 'my_inputselector'
        xapi.Command.Video.Input.SetMainVideoSource({ ConnectorId: event.Value });
        break;
      case 'toggle_display':
        // DJ: put your command to turn off a display here
        console.log(">> someone pressed the toggle_display button!");
        break;
    }
  }
}
//__ run 'onGui' function if someone presses a button
xapi.event.on('UserInterface Extensions Widget Action', onGui);
 
					
				
				
			
		
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide