Skip to content

Commit

Permalink
fixed bug with std::function
Browse files Browse the repository at this point in the history
  • Loading branch information
LennartHennigs committed Sep 16, 2021
1 parent defc3d7 commit 9bdf38d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

## Unreleased

## [1.6.5] - 2021-09-12
- Fixed problem with `std::function` as found by [ItsFlo](https://github.com/ItsFlo) in pull request [#29](https://github.com/LennartHennigs/Button2/pull/29)

## [1.6.4] - 2021-09-12
- Use `std::function` to allow C++ 11 lambda functions
- Use `std::function` to allow C++ 11 lambda functions as suggested by [jacobdekeizer](https://github.com/jacobdekeizer) in pull request [#29](https://github.com/LennartHennigs/Button2/pull/29)

## [1.6.3] - 2021-09-12
- added two new examples: `[MultiHandlerTwoButtons.ino](https://github.com/LennartHennigs/Button2/blob/master/examples/MultiHandlerTwoButtons/MultiHandlerTwoButtons.ino)` and `[TrackDualButtonClick.ino](https://github.com/LennartHennigs/Button2/blob/master/examples/TrackDualButtonClick/TrackDualButtonClick.ino.ino)`
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": "Button2",
"version": "1.6.4",
"version": "1.6.5",
"keywords": "button",
"description": "Arduino Library to simplify working with buttons.",
"homepage": "https://github.com/LennartHennigs/Button2",
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=Button2
version=1.6.4
version=1.6.5
author=Lennart Hennigs
maintainer=Lennart Hennigs <mail@lennarthennigs.de>
sentence=Arduino/ESP library to simplify working with buttons.
Expand Down
9 changes: 7 additions & 2 deletions src/Button2.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
#define Button2_h

/////////////////////////////////////////////////////////////////

#include <functional>
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP8266)
#include <functional>
#endif
#include "Arduino.h"

/////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -54,7 +55,11 @@ class Button2 {
unsigned int down_time_ms = 0;
bool pressed_triggered = false;

#if defined(ARDUINO_ARCH_ESP32) || defined(ESP8266)
typedef std::function<void(Button2 &btn)> CallbackFunction;
#else
typedef void (*CallbackFunction)(Button2 &);
#endif

CallbackFunction pressed_cb = NULL;
CallbackFunction released_cb = NULL;
Expand Down

0 comments on commit 9bdf38d

Please sign in to comment.