Note: Unreleased changes are checked in but not part of an official release (available through the Arduino IDE or PlatfomIO) yet. This allows you to test WiP features and give feedback to them.
- nothing, so far
- fixed bug, that first long press was not properly detected, see issue #72
- added
byte resetClickCount()
function - click count is no longer resetted in
resetPressedState()
- updated examples
- expanded condition to check for API version 2.0 (for UNO R4, RP2040, ...)
- renamed Button2 constants, they now start with
BTN_
(BREAKING CHANGE) - added
Hardware.h
– it implements hardware pin abstraction. Needed for unit testing - added Unit Tests
- added
resetPressedState()
function - added
ESP32S2S3CapacitiveTouch.ino
suggested by ryancasler in PR #57
getNumberOfClicks()
now works inside a callback and after thewait()
statement(s).- Refactored code in
Button2.cpp
- Included PR for issue #54
- Another stab at the bug #46
- Fixed bug #46 that in some instances long clicks are wrongly triggered
- Refactored the main
loop()
- Rewrote click detection
- Cleaned up the long press handling
- Removed compiler switches – they made the code unreadable and they only saved a few bytes (could be a BREAKING CHANGE)
- Added
byte getLongClickCount()
function - Updated the LongpressHandler example
- Defaults (x>3)-clicks to triple
- Fixed bug with button ID
- Removed the capacitive touch functionality out of main library. (BREAKING CHANGE). The constructor and
begin()
lost a parameter. Instead I provide a custom handler example for cap. touch ESP32CapacitiveTouch.ino. For reasons, see #45. - Added an ESP32 timer interrupt example ESP32TimerInterrupt.ino based on #43.
- Added compiler switches in
Button.h
to remove click detection code, as mentioned in #44. - Clarified the difference between the
setLongClickHandler
and thesetLongClickDetectedHandler
in the README and the MultiHandler example as mentioned in #41. (The handler set viasetLongClickHandler
waits until you release the button, the second one is called as soon as the defined long-click time has passed.) - Made
byte _getState()
into aconst
function.
- Added example for the M5Stack Core2 - showing how to add a custom handler for the touch buttons.
- Fixed bug –
longclick_detected_counter
is not properly initalized as mentioned in #37.
- House keeping
- Refactored
loop()
- cleaned up conditions, should be easier to understand now. - Renamed
getAttachedPin()
togetPin()
(BREAKING CHANGE). - Fixed a bug that the first click type was falsly returned by
getClickType()
.
- Refactored
- Possibility define your own "_getState" function for non standard buttons as suggested in #32.
- Refactored
isPressedRaw()
to also use_getState()
. - Introduced a
VIRTUAL_PIN
constant – using it in the constructor orbegin()
will skip pin initalization. - Added
setButtonStateFunction(StateCallbackFunction f)
to assign your own "_getState" function. - Added CustomButtonStateHandler.ino example.
- Refactored
- Improved click type handling.
- Added
clickType
and removed constants for determining the click type (BREAKING CHANGE) - Renamed
getClickType()
togetType()
(BREAKING CHANGE) - Added
clickToString
function to print theclickType
enum value
- Added
- Added IDs button instances
- Added
getID()
, it returns an auto incrementedint
ID for the button, as suggest in #34 - Added
setID()
, it allows you to set your own IDs – but then you need to ensure its uniqeness yourself
- Added
- Added possibility to use the button class inside your main
loop()
function (instead of using callback handlers)- Added
bool wasPressed()
function - Added
read(bool keepState = false)
, it returns the button press type (as aclickType
enum) - Added
wait(bool keepState = false)
, it combineswasPressed()
andread()
methods and halts execution until a button press took place - Added
waitForClick()
,waitForDouble()
,waitForTriple()
andwaitForLong()
as well - Added ButtonLoop.ino example to showcase the "loop" functions
- Added
- Use
std::function
to allow C++ 11 lambda functions as suggested by jacobdekeizer in pull request #29
- added two new examples: MultiHandlerTwoButtons.ino and TrackDualButtonClick.ino
- added examples to the README.md
- initialized
pin
in_getState()
- a bit of variable clean up
- updated setting of inital state of
state
andprev_state
- updated README.md
- added
const
to getter functions
- added getter/setter functions for debounce, longclick and doubleclick timeouts
- removed debounce timeout parameter from
contructor
andbegin()
- Fixed a bug in the
loop()
function
- Added default constructor and
begin()
function - Added pull request by skelstar to add the
setLongClickDetectedHandler()
function which is triggered as soon as the longclick timeout has passed
- Updated LongpressHandler example - changed variable name to from
button
tobutton
- toggled
pressed
andreleased
(as suggesed by TommyC81 in #16) - added debug function
isPressedRaw()
(as suggesed by TommyC81 in #16) - fixed bug with
click_count
(as suggesed by TommyC81 in #16) - changed return types of
getNumberOfClicks()
andgetClickType()
tobyte
- Added capacitive touch sensor capabilties (for ESP32) (as suggested by qubolino in #11)
- Removed deprecated entry in the library.properties file (as suggested by SangLe) in #15
- Added
const
modifier to functions (as suggested by Anton-V-K in #13)
- Added possibility to define your own timeouts for clicks (as suggested by cmeldas in #10)
- Removed
yield()
in mainloop()
since it caused some problems - Created and added CHANGELOG.md
- Changed the private functions to protected (as suggested by Nagymadar in #9)
- Added support for active high buttons (as suggested by Nagymadar in #8)
- Added
reset()
function to unset all functions (as suggested by Nagymadar in #7) - Added a
yield()
command to the mainloop()
- Changed the times for double and triple click
- Fixed error in
SingleButton.ino
(as suggested by alexthe-red in #3) - Added the library to the Arduino IDE
- initial release
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.