Closed ForestCat4 closed 7 years ago
Can you explain the situation in a better way? Actually i didn't get it. El may 7, 2016 11:03 AM, "ForestCat4" notifications@github.com escribió:
Not sure how difficult this would be to implement. Consider this scenario:
A group of 5 buttons, which perform toggle the values of 5 elements in an array, Array1
If the 5th button is 'long-pressed', it changes the target of the 5 buttons to a different array, Array2
If Button5 is long-pressed again, it switches back to Array1.
Is there currently a way to have Button5 only change the value of the 5th array element upon release of a 'click', so that, for example, if Array1[5] = '1', a long-press of Button5 won't change it back to '0' before (or after) switching to the second array?
If not, would you consider adding that functionality? Very useful for ui/menu type of functions.
Thanks.
— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/rlogiacco/AnalogButtons/issues/4
I 'm not sure the functionality you are looking for would fit into the AnalogButtons library: you want to use one button for both a long press and a short press, with the long press not being detected as a short press. To do so you need to intercept the short press, start a timer and, unless a long press is detected, fire the short press event. Otherwise fire a long press.
What the library can do for you is giving you the possibility to execute whatever code you want both for a short press and a long press, so nobody prevents you to have the short press function do something like:
- store the current millisecond
- activate the short press flag
Using a matching long press function which:
- clears the short press flag
- do whatever your long press function should do
This can be paired with a piece of code in your looping function which:
- checks if the short press flag is active and compares current time with the stored time
- if long press time is passed but the flag is still active, execute the short press function
Does it make sense to you? Is this what you are looking for?
Guys, have a look at the attached AnalogButtonsCPP.zip
It does what I needed, and may better explain what I was trying to do. My changes are annotated w/ 'nn_' at the head of the comment. The goal was to be able to do a quick tap(and release) of a button and have it register (almost) immediately, while also being able to "intercept" a long hold without generating a "click".
NOTE: It is quick & dirty, and I'm sure there are more elegant solutions, but it seems to be working...
This will be fixed in the upcoming 1.2.0
release: any feedback before the release gets published is welcome
Not sure how difficult this would be to implement. Consider this scenario:
A group of 5 buttons, which toggle the values of 5 elements in an array, Array1
If the 5th button is 'long-pressed', it changes the target of the 5 buttons to a different array, Array2
If Button5 is long-pressed again, it switches back to Array1.
Is there currently a way to have Button5 only change the value of the 5th array element upon release of a 'click', so that, for example, if Array1[5] = '1', a long-press of Button5 won't change it back to '0' before (or after) switching to the second array?
If not, would you consider adding that functionality? Very useful for ui/menu type of functions.
Thanks.
EDIT: I was able to mod the library to do this. It's a bit of a hack, but seems to be stable. Also removed the 'repeating hold', since it was not the functionality my project needed. If anyone wants it, let me know.