Skip to content

Commit

Permalink
Add debouncedValue() func
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
IhorNehrutsa committed May 8, 2023
1 parent 1280bd0 commit 0485079
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```
Expand Down Expand Up @@ -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()`
Expand Down
1 change: 1 addition & 0 deletions src/OneButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0485079

Please sign in to comment.