Getting started with concrete real world examples¶
Below are some script examples going from very basic to getting more and more complex
Use Case If I press a talk button on
channel x I want
channel y to follow
Functional Description To make this behavior we set an event to trigger if the
talk state of channel 1 (x) changes. When the event run's the value of the
talk state of channel 1 is assigned to channel 2 (y)
event channel.talk channel.talk = channel.talk end
Use Case When i turn down the level of a channel its lowest volume is -40 dB, I want this to be completely muted.
Functional Description To make this behavior we need to set an event on all 32
channel levels, this is done in a for loop. in the event we check if the value is lower than -39, if so we set the
channel listen to off effectively muting the channel, if the value is higher, it will enable the listen again.
for i = 1 to 32 event channel.level[i] if event.value <= -39 channel.listen[event.index] = channel.listen.off else channel.listen[event.index] = channel.listen.on end end end
Remote Talk via GPIO Command¶
Use Case I have an operator that does not have
free hands and a WPX as device. The operator can use a foot-switch to enable a talk. The foot-switch is connected to the GPI of a 4-Wire port. I want to control the talk of a channel on the WPX with the foot-switch
Functional Description On the 4Wire port we will assign a group to a free channel and set its Channel Mode to
GPIO Control The GPI with the foot-switch connected will be set to function
gpio control with the previous assigned channel. this makes this gpio control command available on all devices with this group assigned to one of its channels.
In the Script we wil set an event on incoming changes on the GPIO control property of the said channel. once the event triggers it will set the talk according to the value of the GPIO control property.
/* this script takes the GPIO (remote inputs) from 1 channel if anything sends a GPIOcontrol command to what is assigned to the remote channels it will set the talk of the operated channel. */ define remote_channel 32 define operated_channel 1 event channel.input.gpio[remote_channel] if channel.input.gpio[remote_channel] == channel.gpiocontrol.on channel.talk[operated_channel] = channel.talk.on else channel.talk[operated_channel] = channel.talk.off end end
BPX Button Lock¶
Use Case I am using wireless sports beltpacks under overalls and usually have a talk always enabled, occasionally we want to toggle a talk. For unintentional toggling of talks or undesired sending of calls we want to be able to block/unblock the functionality of the 4 buttons with a key combination.
Functional Description To achieve the desired behavior we start by creating 2 functions, one to lock the buttons and one to unlock the buttons. The lock button function will override the default Green-GO behavior by setting an event on the button and doing nothing in the event, the unlock button clears this events on the buttons.
the script will trigger a timer if lock.button.2 is pressed while lock button 1 was already pressed. When the timer event is triggered a final check if both button one and 2 are still pressed will toggle the lock state.
finally the script checks on the ui.draw event a check is done if the buttons are locked and one or multiple buttons are pressed, in that case a lock screen will be drawn to inform the user that the buttons are locked.
define lock.button.1 ui.bpx.3 define lock.button.2 ui.bpx.4 define time.delay 2000 var locked = 0 function lock_buttons() if ui.bpx.1 != lock.button.2 event ui.button[ui.bpx.1] end end if ui.bpx.2 != lock.button.2 event ui.button[ui.bpx.2] end end if ui.bpx.3 != lock.button.2 event ui.button[ui.bpx.3] end end if ui.bpx.4 != lock.button.2 event ui.button[ui.bpx.4] end end end function unlock_buttons() if ui.bpx.1 != lock.button.2 cancel ui.button[ui.bpx.1] end if ui.bpx.2 != lock.button.2 cancel ui.button[ui.bpx.2] end if ui.bpx.3 != lock.button.2 cancel ui.button[ui.bpx.3] end if ui.bpx.4 != lock.button.2 cancel ui.button[ui.bpx.4] end event ui.button[lock.button.1] end end // make sure not disable the default function of lock button 1 event ui.button[lock.button.1] end // start timer when lock button 2 is pressed after lock button 1 event ui.button[lock.button.2] if ui.button[lock.button.2] == ui.button.pressed if ui.button[lock.button.1] == ui.button.pressed timer = time.delay end end end // if both buttons are pressed after the set time toggle the lock state event timer if ui.button[lock.button.2] == ui.button.pressed if ui.button[lock.button.1] == ui.button.pressed if locked == 0 lock_buttons() locked = 1 else unlock_buttons() locked = 0 end end end end // draw the lock screen function draw.lock() ui.window(0, 20, ui.bpx.display.width, 24) ui.fontmode = ui.fontmode.hcenter ui.clear(ui.color.white) ui.color = ui.color.black ui.draw.text.at(2,2, "LOCKED") end // check if any button is pressed function check.buttons() if ui.button[ui.bpx.1] == ui.button.pressed return 1 end if ui.button[ui.bpx.2] == ui.button.pressed return 1 end if ui.button[ui.bpx.3] == ui.button.pressed return 1 end if ui.button[ui.bpx.4] == ui.button.pressed return 1 end end // take over screen if locked and at least one button is pressed event ui.draw if locked if check.buttons() ui.clear() draw.lock() end end end