LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why do I need these two contants?

Solved!
Go to solution

This is a small project to simulate a touch pad. Basically everything is working. The sliders can be moved with the cursor keys or mouse. Clicking the scroll wheel will activate the touch pad and move the mouse to the position equivalent to the last values of the sliders.

 

I have zipped the whole project for testing.

 

My question: In the "Pane": Mouse Down, True case (larger one), there are two contants: 12 and 80. I cannot see why these are required to position the mouse correctly. The values do not seem to correspond to a border height or anything. Maybe someone could have a look and find the reason.

 

vtiu_0-1747825589880.png

 

I have saved the folder in Labview 2019 format.

 

Many thanks.

Mark

0 Kudos
Message 1 of 14
(348 Views)

Hi Mark,

 


@vtiu wrote:
there are two contants: 12 and 80. I cannot see why these are required to position the mouse correctly. The values do not seem to correspond to a border height or anything. Maybe someone could have a look and find the reason.

According to the comment in the block diagram those constants are related to the position of the 2D Picture control/indicator labelled "Mousepad"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 14
(344 Views)

Wow, that was quick! Try setting the constants to 0 and see where the mose goes. It moves the cursor to a different position and adjusts the sliders accordingly. 

 

Am I missing something?

 

Mark

0 Kudos
Message 3 of 14
(338 Views)

Hi Mark,

 


@vtiu wrote:

Try setting the constants to 0 and see where the mose goes.


There is some weird math in the subVI, and there is no good explanation for that.

The VI in your ZIP has different code than shown in the image in your 1st message…

Where should the "mouse" go to? What is the desired target position?

 


@vtiu wrote:

It moves the cursor to a different position and adjusts the sliders accordingly. 


And your VI does not "adjust the sliders accordingly"! What are these sliders good for?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 14
(329 Views)

The VI in your ZIP has different code than shown in the image in your 1st message… - I posted a partial screenshot to show where the constants are. My original post and my 2023 version are the same - sorry????

 

There is some weird math in the subVI - You mean the Slider2Pad(SubVI)?

 

The point is to move the sliders to a certain position. Then click the mouse wheel. The mouse cursor should move to the equivalent position on the "pad". For example, move the up/down slider to say 1800 and the left/right to 2000. Clicking the scroll wheel should move to the position lining up with the two sliders without the values changing.

 

Without the two constants it does not work.

 

Regards

Mark

0 Kudos
Message 5 of 14
(318 Views)

Hi Mark,

 


@vtiu wrote:

The VI in your ZIP has different code than shown in the image in your 1st message… - I posted a partial screenshot to show where the constants are. My original post and my 2023 version are the same - sorry????


I'm sorry, I was opening the wrong VI…

 


@vtiu wrote:

Without the two constants it does not work.


You need to handle differences between LabVIEW screen positions and Windows mouse position.

Atleast it seems to be a fixed offset as for me (virtual machine, Win10, taskbar moved to left side of the screen) your VI works with the same values…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 14
(289 Views)

I'm sorry, I was opening the wrong VI… - You had me worried for a second there 🙂

 

The position of the front panel is taken into account. As is the position of the 2D picture on the panel.

 

All I have done is to calculate the coordinates in the picture based on the sliders using y=mx+c.

 

Effectively, the X-axis goes from 500 to 2500 which equates to the picture left and width. Same with the Y-axis. This is detailed in the video here

 

https://www.youtube.com/watch?v=Zl5GW35dUjc at roughly 27 minutes.

 

The point is to control two servo motors as per video.

 

Regards

Mark

0 Kudos
Message 7 of 14
(276 Views)

The correct way to get mouse coordinates of a picture is with the mouse property. No need for any tweaks:

All that remains is the scaling between pad size and slider range.

 

altenbach_0-1747833240414.png

altenbach_0-1747833405409.png

 

The event should be mousepad...mouse down. Typically you don't care about mouse coordinates outside the picture (i.e. "pane"). This will greatly simplify your code!

 

 

(On a side note, it would be great to have that cluster as an event data node. Could be an idea....)

Message 8 of 14
(248 Views)

See if this can give you some general ideas...

 

altenbach_0-1747840446259.png

 

(Note: I uploaded a new VI recently, so make sure you have the correct one)

0 Kudos
Message 9 of 14
(214 Views)
Solution
Accepted by vtiu

Quick cleanup using subVIs for scale conversion between image and sliders.

 

altenbach_0-1747843942666.png

 

Message 10 of 14
(198 Views)