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

getPressedTicks() #91

Closed cranefist closed 1 year ago

cranefist commented 3 years ago

getPressedTicks() Does not seem to exist?

maxint-rd commented 2 years ago

I missed it too! I've added this to OneButton.h in the class definition, just between the isLongPressed() method and the private: keyword

  int getPressedTicks() { return(millis()-_startTime); };   // MaxintRD 211230: Added missing method

NOTE: unfortunately this method cannot be used in the handler for LongPressStop. By that time the variable_startTime has been reused. It can be used however in the handler of DuringLongPress, to see how long the button was pressed at that moment.

IhorNehrutsa commented 1 year ago

Add getPressedMs() function in #124 Use this function in the DuringLongPress and LongPressStop events to get the time since the button was pressed.

mathertel commented 1 year ago

fixed by https://github.com/mathertel/OneButton/pull/124