Just wondering if anybody has any examples that show differentiating between normal presses and "Long presses" on buttons? Maybe using the bounce2 library, since I'm using that already..
I'm worried about not triggering the "short press" behavior on a long press..
I'm guessing that for every button I have, a time counter needs to be involved and triggered on every button press and then reset on button release. then at the time of release, the "held time" would be known and then you can decide if it was a long press or short press?
Thinking about it more.. as soon as a program wants to have a distinction between a "short" and "long" button press, it now has to wait for the RELEASE of the button to know how long it was held for before doing any action.
I'll have to go around the house pressing buttons on everything, but I think it would be weird to press a button and not have anything happen until I release it.
In general, no library is required for this function.
Two timers based on the millis() function are required.
Timer1 to debounce the key.
Timer2 to measure the time the button is pressed and released.
I use the IPO model for the description:
INPUT: read in button and debounce
PROCESSING1: if (ButtonBecomesPressed) stores current millis()
PROCESSING2: if (ButtonBecomesReleased) calculate current millis() minus saved millis