Long Button Press Detection #1730
Unanswered
GeorgeIoak
asked this question in
Q&A - Touch
Replies: 1 comment 3 replies
-
I think the problem is that justPressed() etc looks at the history of the past 2 press states stored in the library to look for a change. This means you must keep that history up to date in the first for loop by ussing key[b].pressed(true) if it has been pressed and key[b].pressed(false) if it is not. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Has anyone done something with detecting long button presses. I'm trying to create a UI for a thermostat that has UP/DOWN buttons and a tap will change by 1 but a hold of more than 1 second will change by 10.
I was experimenting with GUIslice and had something working but I'm thinking of abandoning GUIslice and just using TFT_eSPI for my simple UI.
Here's my test code for right now (based on the https://github.com/Bodmer/TFT_eSPI/blob/master/examples/Generic/TFT_Button_Label_Datum/TFT_Button_Label_Datum.ino example)
But I'm getting my debug statement of
"Button held more than 1 sec"
coming through repeatedly rather than only after 1 second. I'm thinking maybekey[b].press(true)
is resetting the timer when it changes the button state but I'm not sure.Before I start digging in I thought I'd ask since I'm sure others have handled long button presses before?
Beta Was this translation helpful? Give feedback.
All reactions