From 8eab511786148cdab1ea9618750ced61f173691e Mon Sep 17 00:00:00 2001 From: chromoxdor <33860956+chromoxdor@users.noreply.github.com> Date: Sun, 1 Dec 2024 15:50:58 +0100 Subject: [PATCH] Update _P097_Esp32Touch.ino - Hopefully fixed compile errors for non-touch ESP32 variants by standardizing the use of uint32_t for the threshold parameter on ESP32 Classic. The value remains limited by P097_MAX_THRESHOLD_VALUE to 4095. --- src/_P097_Esp32Touch.ino | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/_P097_Esp32Touch.ino b/src/_P097_Esp32Touch.ino index 74cbedb014..8de1c5ef56 100644 --- a/src/_P097_Esp32Touch.ino +++ b/src/_P097_Esp32Touch.ino @@ -1,4 +1,5 @@ #include "_Plugin_Helper.h" + #ifdef USES_P097 // ####################################################################################################### @@ -8,21 +9,20 @@ # if defined(ESP32) && !defined(ESP32C2) && !defined(ESP32C3) && !defined(ESP32C6) -# ifdef ESP32_CLASSIC - # define HAS_T0_INPUT 1 - # define HAS_T10_TO_T14 0 - # define LAST_TOUCH_INPUT_INDEX 10 - # define P097_MAX_THRESHOLD_VALUE 4095 -# endif // ifdef ESP32_CLASSIC -# if defined(ESP32S2) || defined(ESP32S3) - # define HAS_T0_INPUT 0 - -// temporary disabled since T10 to T14 are causing problems - # define HAS_T10_TO_T14 0 - # define LAST_TOUCH_INPUT_INDEX 14 - # define P097_MAX_THRESHOLD_VALUE 500000 // couldn't find a max value but threshold for ESP32S2 & ESP32S3 is uint32_t -# endif // if defined(ESP32S2) || defined(ESP32S3) - +// Device-specific configuration +# if defined(ESP32_CLASSIC) + # define HAS_T0_INPUT 1 + # define HAS_T10_TO_T14 0 + # define LAST_TOUCH_INPUT_INDEX 10 + # define P097_MAX_THRESHOLD_VALUE 4095 +# elif defined(ESP32S2) || defined(ESP32S3) + # define HAS_T0_INPUT 0 + +// Temporary disabled since T10 to T14 are causing problems + # define HAS_T10_TO_T14 0 + # define LAST_TOUCH_INPUT_INDEX 14 + # define P097_MAX_THRESHOLD_VALUE 500000 // couldn't find a max value but threshold for ESP32S2 & ESP32S3 is uint32_t +# endif // if defined(ESP32_CLASSIC) # define PLUGIN_097 # define PLUGIN_ID_097 97 @@ -32,7 +32,6 @@ # define P097_MAX_LONGPRESS_VALUE 10000 - # define P097_SEND_TOUCH_EVENT PCONFIG(0) # define P097_SEND_RELEASE_EVENT PCONFIG(1) # define P097_SEND_DURATION_EVENT PCONFIG(2) @@ -308,7 +307,7 @@ boolean Plugin_097(uint8_t function, struct EventStruct *event, String& string) /********************************************************************************** * Touch pin callback functions **********************************************************************************/ -void P097_setEventParams(int pin, touch_value_t threshold) { +void P097_setEventParams(int pin, uint32_t threshold) { int adc, ch, t; if (getADC_gpio_info(pin, adc, ch, t)) {