Joystick-Button
[Deleted User]
Posts: 0
Hello,
who can help me with programming an Joysick-Button?
Wow will it designed in TP4 and programmed in NetLinx-Studio?
Has someone an example for me?
so long
who can help me with programming an Joysick-Button?
Wow will it designed in TP4 and programmed in NetLinx-Studio?
Has someone an example for me?
so long
0
Comments
You could as easily work from LEVEL_EVENTS on those levels, but to my mind you run into a lot of uneccesary processing if someone is just gliding their finger around on the button. If you need your device to track that (like a PTZ control), then that is what you want. If you only care where they end up, what I listed above is fine. I will sometimes put in a small timeline, like a 2-second one, for anti-bounce control, so that the code on my release won't fire ten times in succession if they lifted their finger in a less than clean fashion.
Dave,
I have done a couple of joystick buttons (Escient X,Y protocol command for example). It was my understanding (and I coded accordingly and it seems to work) that the X and Y levels associated with the joystick button are limited to a range of 0-255. Hence, if you are setting up a 720x480 button as would be the case with an Escient X,Y passthru window, the x and y level values you get back would not be actual coordinates but instead need to be mapped into the coordinates based on the scale of the window. I have a formula I use that determines the scale factor for X and Y and then the level values for the joystick are manipulated using the scale factor to convert them into actual coordinates. Is this also your understanding?
Reese
Dave,
Thanks for the info -- the TPD4 documentation still indicates that the level range permitted on the joystick button is 0-255. This may be a documentation error or worse, TPD4 lets you specify a level range larger than 255 but it does not work. Since I coded my joystick modules to adhere to the documentation, I have never tried a level range larger than 255. However, since the level range can not be set individually for X and Y, you are correct that for anything other than a square window, scaling is still required.
Reese
The one that Reese talks about using, for example, is to control an Escient product - the button takes up the entire screen, and is a video window. What you see on the button is the GUI from the Escient video output, and touching the button is just like clicking on the Escient display. Your events just send the Escient the XY coords of your touch so it can act on it.
For something like a PTZ control, you can put whatever graphic or shape you like on the button, presumably something with aroows or some other hint of direction, so when they push it, or move their fingers on it, you translate the movement to the camera or codex.
Maybe the attached file will help tie it together for you. It is a sample MVP-8400 touchpanel file with a Main Page that has one button - a joystick button. As Dave described, there are many uses for a joystick button and many ways to configure it. The most common, as he described, is for manipulation of cameras or user interfaces where they can be provided on the touchpanel within a video window. The joystick button then acts as an overlay that when touched, can be used to obtain x,y coordinates relative to the window and in turn the coordinates can be translated as needed and sent to a device for control or alternately used to control a device directly.
In the sample file, the joystick button is a 320 by 240 pixel button and has an address port of 10, a channel port of 10, and a level port of 10. If your touchpanel device is 10001, then you would build EVENT handlers for 10001:10:0 or 10001:10:[your system number]. The address port would be used if you want to send variable text to the button or to alter the appearance of the button dynamically. The channel port, as Dave said, can be used when the joystick button is pressed to trigger a BUTTON_EVENT. Under this event, you would obtain the level values from the joystick (having done a CREATE_LEVEL previously for the touchpanel device and the two levels). The joystick button itself also has two levels associated with it, x and y. You configure the level port and first level (x) and TPD4 assumes that the second level (y) is the next sequential level. In my sample, port 10 is used for the level and the x level is 1 and the y level is 2.
By doing a CREATE_LEVEL using 10001:10:0 level 1 and 10001:10:0 level 2 and associating these with an integer variable, whenever the BUTTON_EVENT is triggered, you can obtain the current X and Y values from the variables and do whatever actions you desire. I left the level ranges set as 0-255 and in this sample, touching the button in the top left corner will generate a BUTTON_EVENT at which point the x,y levels will be 0,0. If you touch the very center of the button, the levels will 128,128 (roughly). If you touch the very bottom right corner of the window, the level values will be 255,255. Scaling would be needed to convert the x,y values into actual window coordinates for the button if the button is not square or if the level range does not match the actual dimensions of the button. For example, 128 would be roughly 50% of the level range for X which would translate into 50% of the X dimension (in this case 50% of 320 which is an X coordinate of 160). Basically you would be using the level to determine the relative position of the joystick cursor and then converting that value into an absolute coordinate.
Hope this helps --
Reese
Thank you all for help.
so long