From 0485079a62b09b25b99faee6740865fe4b8de28d Mon Sep 17 00:00:00 2001 From: Ihor Nehrutsa Date: Mon, 8 May 2023 09:52:53 +0300 Subject: [PATCH] Add debouncedValue() func Update README.md --- README.md | 11 +++++++++++ src/OneButton.h | 1 + 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 7f60d12..67b67d2 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,14 @@ btn.attachClick(handleClick); btn.attachDoubleClick([]() { Serial.println("Double Pressed!"); }); + +// Handler function for MultiClick the button with self pointer as a parameter +static void handleMultiClick(OneButton *oneButton) { + Serial.println("MultiClick pin=%d debouncedValue=%d!", oneButton->pin(), oneButton->debouncedValue()); +} + +// MultiClick button event attachment with self pointer as a parameter +btn.attachMultiClick(handleMultiClick, &btn); ``` @@ -155,6 +163,9 @@ it is hard to click twice or you will create a press instead of a click. | ----------------------- | ------------------------------------------------------------------------------ | | `bool isLongPressed()` | Detect whether or not the button is currently inside a long press. | | `int getPressedTicks()` | Get the current number of milliseconds that the button has been held down for. | +| `int pin()` | Get the OneButton pin | +| `int state()` | Get the OneButton state | +| `int debouncedValue()` | Get the OneButton debounced value | ### `tick()` and `reset()` diff --git a/src/OneButton.h b/src/OneButton.h index 804f5ac..85b40dc 100644 --- a/src/OneButton.h +++ b/src/OneButton.h @@ -228,6 +228,7 @@ class OneButton int pin() const { return _pin; }; stateMachine_t state() const { return _state; }; int debounce(const int value); + int debouncedValue() const { return debouncedPinLevel; }; }; #endif