diff --git a/CHANGELOG.md b/CHANGELOG.md index c6ce328..55dd579 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 27e9047..d4593b9 100644 --- a/README.md +++ b/README.md @@ -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 @@ -67,6 +68,7 @@ OneButton btn = OneButton( ); ``` + ### Initialize a Button to VCC ```CPP @@ -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 @@ -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, @@ -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: @@ -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 @@ -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: @@ -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: diff --git a/library.json b/library.json index 4b5f3a1..a97e4e5 100644 --- a/library.json +++ b/library.json @@ -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": { diff --git a/library.properties b/library.properties index 6bcef60..3767bb2 100644 --- a/library.properties +++ b/library.properties @@ -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.