05-05-2014 01:19 AM
Hello everybody!
Is it possible to set different events in an event structure for the same button?
More precisely I want to have 2 events: the first if the button is pressed regular and a second if the button is pressed for more than 5 seconds.
I have been searching the forum but did not find and threats concerning this topic.
Thanks for your help!
Solved! Go to Solution.
05-05-2014 03:19 AM
Hi jo,
first event is generated by "value change" of that button. Store the current state of the button in a shift register.
2nd event is generated by using the TimeOut event: here you only need to check the current button state, if TRUE you can do your event handling code…
05-05-2014 03:44 AM
Thank you GerdW for your replay!
First i solved it with this method i found by adding an case structure:
https://decibel.ni.com/content/docs/DOC-11639
But actually your method works better!
Thanks
05-05-2014 03:45 AM
Because you cannot add an event timeout if you use the method i just posted...
05-05-2014 03:49 AM
Hi jo,
that example does just what it claims to: it calculates the time a button was pressed - after the button has been released.
You cannot use this for your task as you want to generate an event while the button is still pressed!
That's why I suggested to use "value change" and "TimeOut" events instead…
05-05-2014 04:03 AM
Yes that was exactly my problem 🙂
07-14-2014 09:31 AM
Dear jobauer, Dear GerdW,
Could you please post a runnable program which solves jobauers problem? I have some difficulties to adapt GerdWs solution to my program. So, I would be happy to see the code.
07-14-2014 09:33 AM
07-14-2014 10:00 AM
Hi GerdW,
Thanks for the quick reply.
At the moment I use in my code an event structure and test if there is a value change of my button. If there is a value change, some action will happen (some data will be deleted). This works fine so far.
Now I want that some other action will happen (more data will be deleted) if the same button is pressed for more than e.g. 5 s (the same action as before may still happen in this case).
I really do not understand how I can achieve this with the Timeout event and a check of the current button state.
I hope you understand my problem better now. If not, then I will try to write a simplified example code of my problem (the whole program is too complex to post here).
07-14-2014 10:02 AM