LennartHennigs / Button2

Arduino/ESP button library that provides callback functions to track single, double, triple and long clicks. It also takes care of debouncing.
MIT License
487 stars 81 forks source link

Question: what should `wasPressedFor()`return for double and triple clicks? #35

Open LennartHennigs opened 2 years ago

LennartHennigs commented 2 years ago

Hey, I noticed that wasPressedFor() always the returns the time for the last click. This sounds ok but for double and triple clicks it might not be helpful.

What would you expect?

Ideas are welcome.

ryancasler commented 1 year ago

I would vote for B. I can't think of a use-case where I would need to know the total amount of time that a button had been clicked for over multiple clicks.

Alekeep commented 10 months ago

Happened upon this question while looking to handle an application need. Thus far, I have only used this button2 for simple pin press input so may have bad assumptions about other usage. I need to detect multiple clicks beyond the specificly handled single, double, and triple and also to know if the last click is short or long. First, may I ask, will getNumberOfClicks() return a count higher than 3? If so in answe to your question, I would want wasPressedFor() to remain as-is to provide the length of the last click. Thanks!

LennartHennigs commented 8 months ago

@Alekeep yes, getNumberOfClicks()returns the true number.

ok, length if the last click.

Alekeep commented 8 months ago

@LennartHennigs, this seems to be the most useful approach... at least for me. Thanks!