Skip to content

Commit

Permalink
Update _P097_Esp32Touch.ino
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
chromoxdor committed Dec 1, 2024
1 parent 0dc0e73 commit 8eab511
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/_P097_Esp32Touch.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "_Plugin_Helper.h"

#ifdef USES_P097

// #######################################################################################################
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 8eab511

Please sign in to comment.