mathertel / OneButton

An Arduino library for using a single button for multiple purpose input.
http://www.mathertel.de/Arduino/OneButtonLibrary.aspx
Other
954 stars 230 forks source link

Minimum value of setClickTicks for double click feature #69

Closed hoilett closed 3 years ago

hoilett commented 4 years ago

It might be useful to note somewhere in the code that it will be hard to detect a double click unless setClickTicks is at least 200 milliseconds (or so). Anything shorter than 200 ms and there just isn't enough time for the user to press a button twice.

When I started thinking a bit, it makes sense that there needed to be a bit of time passed in order to register a double click, but it wasn't immediately obvious how that factored into the setClickTicks function itself (at least not to me...maybe everyone else is fine).

I initially had setClickTicks to 10 ms in order to make the button very responsive. When I tried adding a double click feature, I noticed the double click callback function simply would not register, even when I tried clicking the button as fast as possible. Eventually, I realized that I had to increase setClickTicks to at least 200 ms. I ultimately set setClickTicks to 275 ms which I thought was more comfortable.

Anyways, just a suggestion. Really great library.

mathertel commented 3 years ago

Thanks, I added some comments to the readme. in version 2 the default will be 400/800.

hoilett commented 3 years ago

@mathertel awesome. Thanks.