Skip to content

Commit

Permalink
Version 2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mathertel committed Dec 2, 2023
1 parent 5c6d3e3 commit 27f9a6a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file starting 2021.

## [2.5.0] - 2023-12-02

This release is a minor update including som smaller fixes.

* Functions marked with deprecated will be removed in version 3.x
* Formatting of source code conformint the standard Arduino IDE 2.0 formatting using .clang-format
* Version for platform.io in sync with version for Arduino
* Introducing the `OneButtonTiny` class for small environments with limited program space and memory.


## [2.1.0] - 2023-05-10

This release is a minor update as there is new internal functionality and
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ You can find more details on this library at

The change log of this library can be found in [CHANGELOG](CHANGELOG.md).


## Getting Started

Clone this repository into `Arduino/Libraries` or use the built-in Arduino IDE Library manager to install
Expand Down Expand Up @@ -67,6 +68,7 @@ OneButton btn = OneButton(
);
```


### Initialize a Button to VCC

```CPP
Expand All @@ -86,6 +88,7 @@ OneButton btn = OneButton(
);
```


### Attach State Events

Once you have your button initialized, you can handle events by attaching them to the button
Expand Down Expand Up @@ -127,6 +130,7 @@ void loop() {
}
```


### Usage with lambdas that capture context

You __can't pass__ a lambda-__with-context__ to an argument which expects a __function pointer__. To work that around,
Expand All @@ -139,6 +143,7 @@ okBtn.attachClick([](void *ctx){Serial.println(*((BtnHandler*)ctx) -> state);},
See also discussion in [Issue #112](https://github.com/mathertel/OneButton/issues/112).
## State Events
Here's a full list of events handled by this library:
Expand All @@ -152,6 +157,7 @@ Here's a full list of events handled by this library:
| `attachDuringLongPress` | Fires periodically as long as the button is held down. |
| `attachLongPressStop` | Fires when the button is released after a long hold. |
### Event Timing
Valid events occur when `tick()` is called after a specified number of milliseconds. You can use
Expand All @@ -175,6 +181,7 @@ The former functions `setDebounceTicks`, `setClickTicks` and `setPressTicks` are
The term `Ticks` in these functions where confusing. Replace them with the ...Ms function calls.
There is no functional change on them.
### Additional Functions
`OneButton` also provides a couple additional functions to use for querying button status:
Expand All @@ -187,11 +194,13 @@ There is no functional change on them.
| `int state()` | Get the OneButton state |
| `int debouncedValue()` | Get the OneButton debounced value |
### `tick()` and `reset()`
You can specify a logic level when calling `tick(bool)`, which will skip reading the pin and use
that level instead. If you wish to reset the internal state of your buttons, call `reset()`.
## Troubleshooting
If your buttons aren't acting they way they should, check these items:
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "OneButton",
"version": "2.0.3",
"version": "2.5.0",
"keywords": "arduino, button, pushbutton",
"description": "This Arduino library is improving the usage of a singe button for input. It shows how to use an digital input pin with a single pushbutton attached for detecting some of the typical button press events like single clicks, double clicks and long-time pressing. This enables you to reuse the same button for multiple functions and lowers the hardware invests.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=OneButton
version=2.1.0
version=2.5.0
author=Matthias Hertel
maintainer=Matthias Hertel, https://www.mathertel.de
sentence=Arduino library for improving the usage of a singe input button.
Expand Down

0 comments on commit 27f9a6a

Please sign in to comment.