mathertel / OneButton

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

Add Debounce method for use in SpesialInput. #119

Closed IhorNehrutsa closed 1 year ago

IhorNehrutsa commented 1 year ago

Thank you Matthias for the fast review. Comments are welcome.

mathertel commented 1 year ago

yes, this one was missing. Now code is duplicated in debounce(const int value) and tick(). You can call debounce() in tick() so it seems. Please add some documentation that tick() is debouncing by itself but tick(bool activeLevel) is not.

mathertel commented 1 year ago

This will be a major release as the interface is changing.

IhorNehrutsa commented 1 year ago

Backward compatibility is saved at that moment. Old code will work with

  void setDebounceTicks(const unsigned int ms); // obsolete
  void setClickTicks(const unsigned int ms); // obsolete
  void setPressTicks(const unsigned int ms); // obsolete

and future code will work with

  void setDebounceMs(const unsigned int ms);
  void setClickMs(const unsigned int ms);
  void setPressMs(const unsigned int ms);

Both

  void tick(void);
  void tick(bool level);

perform debouncing itself.