Button Event for all channels?
Youn
Posts: 2
Currently I'm doing something like this...
Firrst of all is there a shorthand way to do this instead of having to define the huge array? I was thinking just "BUTTON_EVENT[someDevice]" but that doesn't work...
Secondly, and not so important, I was unable to get 'button.input.channel' to return any value, and I was having to assign it first to a variable, I'd rather not have to assign it to a variable, is there a way to use it within an expression string like shown above, or should it work the way illustrated and maybe something else in my code is causing problems? Perhaps having other button_events defined for same device cause problems?
Thanks
integer keypad_buttons[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,etc...} BUTTON_EVENT[someDevice,keypad_buttons] { PUSH: { SEND_STRING someOtherDevice, "'button ',itoa(button.input.channel)" } }
Firrst of all is there a shorthand way to do this instead of having to define the huge array? I was thinking just "BUTTON_EVENT[someDevice]" but that doesn't work...
Secondly, and not so important, I was unable to get 'button.input.channel' to return any value, and I was having to assign it first to a variable, I'd rather not have to assign it to a variable, is there a way to use it within an expression string like shown above, or should it work the way illustrated and maybe something else in my code is causing problems? Perhaps having other button_events defined for same device cause problems?
Thanks
0
Comments
button.input.channel works fine for me.
Could you post a compilable program that illustrates the problem?
'button.input.channel' will never return anything outside the button_event because it becomes nul as soon as the event is over. Your send_string should work fine within the button_event.
Try using nSomeVarialbe = Get_Last(keypad_buttons) to return the index of the array keypad_buttons. This can very valuable as a pointer to other arrays.
I'd then create a virtual device to represent the dvd and write something like:
Channel_Event[vdvDVD,0]
{
On:
{
Send_command dvIR,"'SP',channel.channel. + 50"
}
}
And then I could treat the virtual device exactly like a real IR device in my IR routing code.
An easy way to get around that is store the button.input.channel
In fact, I do it with all the paramerters as a matter of course.
DEV dev_TP_Master_1[ ] = // this links all the touch panels together
{dvTP_1_Library, // info to all.
dvTP_1_Masterbed,
dvTP_1_Kitchen,
dvTP_1_Garage,
dvTP_1_Den,
dvTP_1_Ground
}
Button_Event[dev_TP_Master_1,big_ole_button_array]
{
push:
{
TP_DEVICE=Button.Input.Device.Number
TP_PORT=Button.Input.Device.Port
TP_SYSTEM=Button.Input.Device.System
TP_BUTTON_PUSHED=BUTTON.INPUT.CHANNEL
TO[TP_DEVICE:TP_PORT:TP_SYSTEM,TP_BUTTON_PUSHED] // feedback to button on TP
etc...
that's how I like to do it...
I?m not sure how much of a shortcut this is especially considering the sequential numbering tool but you do have the option to create a variable array and plug in your numbers with a loop.
For example let?s say you have 200 lights and want a button for each and you want the first light button to start at 101. Consider the following:
It looks like it is in the function from the code example given.
Great idea, Joe.
Monitoring all pushes for a timeout function or whatnot, I use BUTTON_EVENT[dvTP,0] - which I believe was suggested by Joe in a somewhat related thread.
Well then . . . I guess it's just sheer luck that it works absolutely perfect on all of my jobs that I've done. Out of pure curiosity - have you tried it, or are you going off of your vast knowledge of the NetLinx Programming Language? Since you posted so quickly after my suggestion, I'll guess you didn't even test it.
Like they say . . . don't knock it until you try it. Trust me, it works.
I'll be posting code later.
--D
I guess it's all about pragmatics.
Understood - I misread often as well. I just thought I was clear in the way that I suggested it by saying it is what I do for my TV macros.
No hard feelings, right? Not trying to make an excuse, but I'm occasionaly rough on the edges before lunch, but I'm really not that bad of a guy - really! Perhaps I should stay off the forums before I feed my appetite for the BK Big Fish.