Skip to content

Commit

Permalink
Merge pull request #120 from IhorNehrutsa/docs
Browse files Browse the repository at this point in the history
Add debouncedValue() func and docu.
  • Loading branch information
mathertel committed May 9, 2023
2 parents d11a767 + 0485079 commit 47d92eb
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 @@ -80,6 +80,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);
```
### Don't forget to `tick()`
Expand Down Expand Up @@ -151,6 +159,9 @@ There is no functional change on them.
| ----------------------- | ------------------------------------------------------------------------------ |
| `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 @@ -231,6 +231,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 47d92eb

Please sign in to comment.