Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "EasyButton",
"keywords": "IO, button, sensor, arduino",
"description": "EasyButton is an small Arduino library for debouncing momentary contact switches like tactile buttons. It uses events and callbacks to trigger actions when a button is pressed once or held for a given duration. It also provides a sequence counter to be able to rise an event when a given pattern of presses has been matched.",
"version": "2.0.3",
"repository": {
"type": "git",
"url": "https://github.com/evert-arias/EasyButton"
},
"url": "https://easybtn.earias.me",
"frameworks": "arduino",
"platforms": "espressif8266, espressif32",
"dependencies": [
{
"owner": "megunolink",
"name": "MegunoLink",
"version": "^1.33"
}
],
"authors": [
{
"name": "Evert Arias",
"email": "evert.arias@hotmail.com"
},
{
"name": "Felix A. Epp",
"url": "https://github.com/eppfel"
}
]
}
5 changes: 3 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name=EasyButton
version=2.0.1
version=2.0.3
author=Evert Arias <evert.arias@hotmail.com>
maintainer=Evert Arias <evert.arias@hotmail.com>
sentence=Arduino library for debouncing momentary contact switches, detect press, release, long press and sequences with event definitions and callbacks.
paragraph=EasyButton is an small Arduino library for debouncing momentary contact switches like tactile buttons. It uses events and callbacks to trigger actions when a button is pressed once or held for a given duration. It also provides a sequence counter to be able to rise an event when a given pattern of presses has been matched.
category=Signal Input/Output
url=https://easybtn.earias.me
architectures=*
architectures=*
depends=MegunoLink
2 changes: 1 addition & 1 deletion src/EasyButton.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* EasyButton.cpp
* @author Evert Arias
* @version 2.0.0
* @version 2.0.3
* @license MIT
*/

Expand Down
2 changes: 1 addition & 1 deletion src/EasyButton.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* EasyButton.h
* @author Evert Arias
* @version 2.0.0
* @version 2.0.3
* @license MIT
*/

Expand Down
2 changes: 1 addition & 1 deletion src/EasyButtonBase.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* EasyButtonBase.h
* @author Evert Arias
* @version 2.0.0
* @version 2.0.3
* @license MIT
*/

Expand Down
2 changes: 1 addition & 1 deletion src/EasyButtonBase.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* EasyButtonBase.h
* @author Evert Arias
* @version 2.0.0
* @version 2.0.3
* @license MIT
*/

Expand Down
21 changes: 17 additions & 4 deletions src/EasyButtonTouch.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
/**
* EasyButtonTouch.cpp
* @author Evert Arias, Gutierrez PS
* @version 2.0.0
* @author Evert Arias, Gutierrez PS, Felix A. Epp
* @version 2.0.3
* @license MIT
*/

#if defined(ESP32)
#include "EasyButtonTouch.h"
#if defined(SOC_TOUCH_SENSOR_SUPPORTED) || (defined(SOC_TOUCH_SENSOR_NUM) && SOC_TOUCH_SENSOR_NUM > 1)

void EasyButtonTouch::setThreshold(int threshold)
{
_touch_threshold = threshold;
}

void EasyButtonTouch::begin(int threshold)
{
_touch_threshold = threshold;
begin();
}

void EasyButtonTouch::begin()
{
Expand All @@ -19,7 +31,8 @@ void EasyButtonTouch::begin()

bool EasyButtonTouch::_readPin()
{
return touchRead(_pin) < _touch_threshold;
ADCFilter.Filter(touchRead(_pin));
return ADCFilter.Current() < _touch_threshold;
}

#endif
#endif
14 changes: 10 additions & 4 deletions src/EasyButtonTouch.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
/**
* EasyButtonTouch.h
* @author Evert Arias, Gutierrez PS
* @version 2.0.0
* @author Evert Arias, Gutierrez PS, Felix A. Epp
* @version 2.0.3
* @license MIT
*/

#if !defined(_EasyButtonTouch_h) and defined(ESP32)
#define _EasyButtonTouch_h
#include <include/soc/soc_caps.h>
#if defined(SOC_TOUCH_SENSOR_SUPPORTED) || (defined(SOC_TOUCH_SENSOR_NUM) && SOC_TOUCH_SENSOR_NUM > 1)

#include <Arduino.h>
#include <Filter.h>
#include "EasyButton.h"

class EasyButtonTouch : public EasyButton
{
public:
EasyButtonTouch(uint8_t pin, uint32_t debounce_time = 35, uint16_t threshold = 50) : EasyButton(pin, debounce_time, false, false), _touch_threshold(threshold) {}
EasyButtonTouch(uint8_t pin, uint32_t debounce_time = 35, uint16_t threshold = 50) : EasyButton(pin, debounce_time, false, false), _touch_threshold(threshold), ADCFilter(5, threshold) {}
void begin();
void begin(int threshold);
void setThreshold(int threshold);

private:
uint16_t _touch_threshold; // If touchRead() is below the threshold, the button is considered pressed.
ExponentialFilter<long> ADCFilter;

bool _readPin();
};

#endif
#endif
2 changes: 1 addition & 1 deletion src/EasyButtonVirtual.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* EasyButtonVirtual.h
* @author Evert Arias, Jose Gabriel Companioni Benitez
* @version 2.0.0
* @version 2.0.3
* @license MIT
*/

Expand Down
2 changes: 1 addition & 1 deletion src/EasyButtonVirtual.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* EasyButtonVirtual.h
* @author Evert Arias, Jose Gabriel Companioni Benitez
* @version 2.0.0
* @version 2.0.3
* @license MIT
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Sequence.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Sequence.h
* @author Evert Arias, Jose Gabriel Companioni Benitez
* @version 2.0.0
* @version 2.0.3
* @license MIT
*/

Expand Down
2 changes: 1 addition & 1 deletion src/Sequence.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Sequence.h
* @author Evert Arias, Jose Gabriel Companioni Benitez
* @version 2.0.0
* @version 2.0.3
* @license MIT
*/

Expand Down