From 212387841300a45b59d460cad2d8bb4e37845366 Mon Sep 17 00:00:00 2001 From: Nick Reynolds Date: Wed, 26 Apr 2023 11:05:00 +0100 Subject: [PATCH 1/2] 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 --- src/EasyButtonTouch.cpp | 3 ++- src/EasyButtonTouch.h | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/EasyButtonTouch.cpp b/src/EasyButtonTouch.cpp index 8cf68cf..8843855 100644 --- a/src/EasyButtonTouch.cpp +++ b/src/EasyButtonTouch.cpp @@ -7,6 +7,7 @@ #if defined(ESP32) #include "EasyButtonTouch.h" +#if defined(SOC_TOUCH_SENSOR_SUPPORTED) void EasyButtonTouch::setThreshold(int threshold) { @@ -33,5 +34,5 @@ bool EasyButtonTouch::_readPin() ADCFilter.Filter(touchRead(_pin)); return ADCFilter.Current() < _touch_threshold; } - +#endif #endif \ No newline at end of file diff --git a/src/EasyButtonTouch.h b/src/EasyButtonTouch.h index dc8e48d..7de0b0b 100644 --- a/src/EasyButtonTouch.h +++ b/src/EasyButtonTouch.h @@ -7,6 +7,8 @@ #if !defined(_EasyButtonTouch_h) and defined(ESP32) #define _EasyButtonTouch_h +#include +#if defined(SOC_TOUCH_SENSOR_SUPPORTED) #include #include @@ -26,5 +28,5 @@ class EasyButtonTouch : public EasyButton bool _readPin(); }; - +#endif #endif \ No newline at end of file From f118f0eec0c930f4ef5309bca9b4e1bcf38bb7fd Mon Sep 17 00:00:00 2001 From: Nick Reynolds Date: Wed, 26 Apr 2023 11:58:25 +0100 Subject: [PATCH 2/2] Better detection of touch feature Add secondary way of detecting if touch is enabled, using the 'number of touch sensors'. --- src/EasyButtonTouch.cpp | 2 +- src/EasyButtonTouch.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EasyButtonTouch.cpp b/src/EasyButtonTouch.cpp index 8843855..ecf4a7b 100644 --- a/src/EasyButtonTouch.cpp +++ b/src/EasyButtonTouch.cpp @@ -7,7 +7,7 @@ #if defined(ESP32) #include "EasyButtonTouch.h" -#if defined(SOC_TOUCH_SENSOR_SUPPORTED) +#if defined(SOC_TOUCH_SENSOR_SUPPORTED) || (defined(SOC_TOUCH_SENSOR_NUM) && SOC_TOUCH_SENSOR_NUM > 1) void EasyButtonTouch::setThreshold(int threshold) { diff --git a/src/EasyButtonTouch.h b/src/EasyButtonTouch.h index 7de0b0b..88aef5a 100644 --- a/src/EasyButtonTouch.h +++ b/src/EasyButtonTouch.h @@ -8,7 +8,7 @@ #if !defined(_EasyButtonTouch_h) and defined(ESP32) #define _EasyButtonTouch_h #include -#if defined(SOC_TOUCH_SENSOR_SUPPORTED) +#if defined(SOC_TOUCH_SENSOR_SUPPORTED) || (defined(SOC_TOUCH_SENSOR_NUM) && SOC_TOUCH_SENSOR_NUM > 1) #include #include