Skip to content

Commit 2123878

Browse files
committed
Conditional inclusion of touch features
Ensure touch features are only included on ESP32 variants that supports touch. Relies on include/soc/soc_caps.h in recent versions of the IDF
1 parent 4e81841 commit 2123878

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/EasyButtonTouch.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#if defined(ESP32)
99
#include "EasyButtonTouch.h"
10+
#if defined(SOC_TOUCH_SENSOR_SUPPORTED)
1011

1112
void EasyButtonTouch::setThreshold(int threshold)
1213
{
@@ -33,5 +34,5 @@ bool EasyButtonTouch::_readPin()
3334
ADCFilter.Filter(touchRead(_pin));
3435
return ADCFilter.Current() < _touch_threshold;
3536
}
36-
37+
#endif
3738
#endif

src/EasyButtonTouch.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#if !defined(_EasyButtonTouch_h) and defined(ESP32)
99
#define _EasyButtonTouch_h
10+
#include <include/soc/soc_caps.h>
11+
#if defined(SOC_TOUCH_SENSOR_SUPPORTED)
1012

1113
#include <Arduino.h>
1214
#include <Filter.h>
@@ -26,5 +28,5 @@ class EasyButtonTouch : public EasyButton
2628

2729
bool _readPin();
2830
};
29-
31+
#endif
3032
#endif

0 commit comments

Comments
 (0)