Hello All,
In my program I want to capture the sequence of how a button is pressed. I was thinking "Easy", till I started to think about how to do this...
I did search the forum and was not able to find anything.
This is in plain terms what I'm trying to do...
1.) Press & Hold for > 2 seconds (* Set iMode = 0;)
2.) Press once (* Set iMode = 1;)
3.) Press twice (* Set iMode = 2;)
4.) Press three Times (* Set iMode = 3;)
It could go on but I actually only have three modes...
At first I thought to capture when the button is pressed, but if this is in a loop how would it know the difference of a continual press from multiple presses.
That got me thinking maybe I really need to be capturing releases?
I was thinking to try the following approach...
1.) On first press check to see if the press event timer is runing... If Not, start the timer and record ReleaseCount=0
2.) On next loop check to see if button is pressed, if it is do nothing. If it is not pressed set ReleaseCount = 1;
3.) Check total elapsed time on each loop, if the time is greater then 2 seconds exit the routine and return the ReleaseCount Value
All that said, I would still need to be sure the event does not immediatly enter another press analisis routine if the user is still holding down the button from the original (first) button press sequence...
Does any of this make sense? Has anyone experience doing something like this?
Thank You
Tim
Hello All,
In my program I want to capture the sequence of how a button is pressed. I was thinking "Easy", till I started to think about how to do this...
I did search the forum and was not able to find anything.
This is in plain terms what I'm trying to do...
1.) Press & Hold for > 2 seconds (* Set iMode = 0;)
2.) Press once (* Set iMode = 1;)
3.) Press twice (* Set iMode = 2;)
4.) Press three Times (* Set iMode = 3;)
It could go on but I actually only have three modes...
At first I thought to capture when the button is pressed, but if this is in a loop how would it know the difference of a continual press from multiple presses.
That got me thinking maybe I really need to be capturing releases?
I was thinking to try the following approach...
1.) On first press check to see if the press event timer is runing... If Not, start the timer and record ReleaseCount=0
2.) On next loop check to see if button is pressed, if it is do nothing. If it is not pressed set ReleaseCount = 1;
3.) Check total elapsed time on each loop, if the time is greater then 2 seconds exit the routine and return the ReleaseCount Value
All that said, I would still need to be sure the event does not immediatly enter another press analisis routine if the user is still holding down the button from the original (first) button press sequence...
Does any of this make sense? Has anyone experience doing something like this?
Thank You
Tim