From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event for long time button-press?

Solved!
Go to solution

Dear GerdW,

 

Thanks for this suggestion. I tried to implement it, but it does not really work as I want.

In the attachment you can find my example code:

If I run the vi and press on the Calculate button, values will be filled into both arrays.

If I want to delete the data of Array1, I click on the Calculate button again (to stop the calculation) and then I click once on the Delete Data button.

Array1 will be deleted then, but I have to wait 5s until the test if the Delete Data button is pressed more than 5 s is done (if so, Array2 will be deleted too Smiley Happy). In these 5 s I cannot do anything and this is something which I want to avoid.

Can you give me a hint how I can adapt my program to avoid this problem?

0 Kudos
Message 11 of 17
(670 Views)

Try changing the mechanical action of your delete button to Switch Until Released.  This will cause a Value Change event when you press the button and when you release it.  So you just store the time when you pressed the button in a feedback node.  When you release, you subtract the current time from the previous time.  If it is more than 5 seconds, delete your second array.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 12 of 17
(660 Views)

Dear crossrulz,

 

WOW, this is almost exactly what I want to have!

Would the following be possible:

When I press Delete and wait for 5 s, I want that Array2 is deleted after these 5 s without releasing the Delete button.

At the moment I have to press the Delete button for 5 seconds (slowly counting up to 5). After releasing it I will see if I pressed long enough. If I had luck, I waited long enough and Array2 is deleted. If I have bad luck, I have to press again on Delete.

So, it would be great if your program could be slightly adapted.

0 Kudos
Message 13 of 17
(653 Views)

@partial wrote:

So, it would be great if your program could be slightly adapted.


That's simple enough.  You just put a timeout value in a shift register.  When you initially push the button, set the timeout to 5000 (5 seconds) and clear array 1.  In your timeout you clear array 2.  If you release the button too soon, you will still get the value change, but you want to set the timeout to -1 (wait forever).  This will keep the Timeout case from running and clearing your array.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 14 of 17
(643 Views)

Dear crossrulz,

 

Thank you very much for your explanations and your new code.

I was able to adapt it to my real program and it works fine!

Thanks a lot for the help!

0 Kudos
Message 15 of 17
(632 Views)

The way crossrulz explained was the same way i solved it in the end.

 

https://decibel.ni.com/content/docs/DOC-11639

(if you need some more stuffSmiley Wink )

0 Kudos
Message 16 of 17
(601 Views)

Dear jobauer,

I found your nice program in advance. But unfortunately I did not recognize that I can adapt this program too.

But the whole discussion here helped me a lot to learn and understand more about how to use Event Structures.

0 Kudos
Message 17 of 17
(593 Views)