B4R Question Button complex processing

peacemaker

Expert
Licensed User
Longtime User
Hi, All

How better to process the button usage with MCU (esp32 family, if more detailed) - if task is to control complex button clicking ?
Short click, long click, double-click, triple-click...

Say,
1) single short click - to wake MCU up
2) Next short clicks - for listing the work modes
3) long click - some setup
4) After some pause the single short click - deepsleeping.

Any lib for such button usage ?
 

Cableguy

Expert
Licensed User
Longtime User
Use a timer after wake-up... button down -> timer on if time passed is bigger than x time, then its a long press... button up -> another timer to way for second click if timer1 is off or long = false

No such lib, but a module could be easily built for this fonction
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
What I am thinking is how does a short click is different than the bouncing in terms of time duration. Once you can answer this I believe you are close to all solutions.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
What I am thinking is how does a short click is different than the bouncing in terms of time duration. Once you can answer this I believe you are close to all solutions.

Actually, now thinking about it, there is no difference. At the first bounce you define it was clicked and then if it is a long click after bouncing period it will still be clicked.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
You set a minimal timer1 duration so that button down is true, then on button up set Timer1 off, and start timer 2 to detect second click
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Upvote 0
Top