Multiple projector switching using variables?
Good Morning.
I have a classroom with 2 projectors, and need to be able to display multiple sources to each of the projectors at different times. I could create popup pages with different channel source buttons, and have multiple button events for each button unique to each projector, but I would like to be able to send a command to each projector based on which projector is selected on the projector select button.
Confused?
I'm using a module to control the projectors, and all that is working OK, I just want to choose the projector responding to a command with a variable set by a projector selector button. I was thinking of something like this: (I found this code elsewhere on the list, as an example)
DEFINE_DEVICE
dv_proj_1 = 5001:01:0 // proj one
dv_proj_2 = 5001:02:0 // proj two
DEFINE_VARIABLE
volatile dev dev_proj_sel[]=
{0,1}
volatile dev dev_projs[]=
{
dv_proj_1
,dv_proj_2
}
DEFINE_EVENT
button_event[dev_TP,1] // power on
{
push:
{
local_var integer pj_id
pj_id=get_last(dev_proj_sel)
send_command dev_projs[pj_id],'commence_world_takeover'
}
}
Is there a better way, or will this work?
Doug Menke
I have a classroom with 2 projectors, and need to be able to display multiple sources to each of the projectors at different times. I could create popup pages with different channel source buttons, and have multiple button events for each button unique to each projector, but I would like to be able to send a command to each projector based on which projector is selected on the projector select button.
Confused?
I'm using a module to control the projectors, and all that is working OK, I just want to choose the projector responding to a command with a variable set by a projector selector button. I was thinking of something like this: (I found this code elsewhere on the list, as an example)
DEFINE_DEVICE
dv_proj_1 = 5001:01:0 // proj one
dv_proj_2 = 5001:02:0 // proj two
DEFINE_VARIABLE
volatile dev dev_proj_sel[]=
{0,1}
volatile dev dev_projs[]=
{
dv_proj_1
,dv_proj_2
}
DEFINE_EVENT
button_event[dev_TP,1] // power on
{
push:
{
local_var integer pj_id
pj_id=get_last(dev_proj_sel)
send_command dev_projs[pj_id],'commence_world_takeover'
}
}
Is there a better way, or will this work?
Doug Menke
Comments
DEFINE_VARIABLE VOLATILE INTEGER nCUR_PROJ; DEFINE_EVENT BUTTON_EVENT[dv_TP,nPROJ_SEL_BTNS] { PUSH: { // Select which project we want to control nCUR_PROJ = GET_LAST(nPROJ_SEL_BTNS) } } BUTTON_EVENT[dv_TP,nPROJ_POWER_ON] { PUSH: { IF(nCUR_PROJ) // Send command only if a projector is select SEND_COMMAND vdv_PROJ[nCUR_PROJ],'TAKE OVER WORLD' ELSE // Otherwise send annoying double beep SEND_COMMAND BUTTON.INPUT.DEVICE,"'ADBEEP'"; } }Or you could set a DEV variable and set it like so:
DEFINE_VARIABLE DEV vdv_PROJ_SEL; BUTTON_EVENT[dv_TP,nPROJ_SEL_BTNS] { PUSH: { // Select which project we want to control vdv_PROJ_SEL = vdv_PROJ[GET_LAST(nPROJ_SEL_BTNS)] } } BUTTON_EVENT[dv_TP,nPROJ_POWER_ON] { PUSH: { IF(vdv_PROJ_SEL != 0:0:0) // Send command only if a projector is selected SEND_COMMAND vdv_PROJ_SEL,'TAKE OVER WORLD' ELSE // Otherwise send annoying double beep SEND_COMMAND BUTTON.INPUT.DEVICE,"'ADBEEP'"; } }There are MANY different ways you can do this.
volatile dev dev_proj_sel[]= {0,1}to:volatile dev dev_proj_sel[]= {1,2}The 0 will act as a wildcard and will be true for any button pushed during the button event that jjames listed.
--John
--John
volatile dev dev_proj_sel[]=
{1,2}
to
volatile integer dev_proj_sel[]=
{1,2}
I'll just guess oversight on your part. But John is correct, the zero would act as a wildcard.
Good luck and let us know how it turns out!