-
-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathEasyButtonTouch.cpp
More file actions
38 lines (33 loc) · 735 Bytes
/
Copy pathEasyButtonTouch.cpp
File metadata and controls
38 lines (33 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* EasyButtonTouch.cpp
* @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()
{
_current_state = _readPin();
_time = millis();
_last_state = _current_state;
_changed = false;
_last_change = _time;
}
bool EasyButtonTouch::_readPin()
{
ADCFilter.Filter(touchRead(_pin));
return ADCFilter.Current() < _touch_threshold;
}
#endif
#endif