From 66ac5ac81b6ee25a39482bbe31e9199e8e51ec5a Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Fri, 8 Mar 2024 18:14:59 +0100 Subject: [PATCH] Revert "fixed touch buttons for ESP32 S2 and S3" This reverts commit 09041551862361cd8c7444ca25403f5f96a9077b. --- wled00/button.cpp | 27 ++++----------------------- wled00/cfg.cpp | 13 ++----------- wled00/fcn_declare.h | 1 - 3 files changed, 6 insertions(+), 35 deletions(-) diff --git a/wled00/button.cpp b/wled00/button.cpp index bf093a2071..29cb0abebf 100644 --- a/wled00/button.cpp +++ b/wled00/button.cpp @@ -99,21 +99,11 @@ bool isButtonPressed(uint8_t i) case BTN_TYPE_TOUCH: case BTN_TYPE_TOUCH_SWITCH: #if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3) - #ifdef SOC_TOUCH_VERSION_2 //ESP32 S2 and S3 provide a function to check touch state (state is updated in interrupt) - if (touchInterruptGetLastStatus(pin)) - { - return true; - } - #else - if (digitalPinToTouchChannel(btnPin[i]) >= 0 && touchRead(pin) <= touchThreshold) - { - return true; - } - #endif + if (digitalPinToTouchChannel(btnPin[i]) >= 0 && touchRead(pin) <= touchThreshold) return true; #endif - break; - } - return false; + break; + } + return false; } void handleSwitch(uint8_t b) @@ -416,12 +406,3 @@ void handleIO() offMode = true; } } - -void IRAM_ATTR touchButtonISR() -{ - -#if defined SOC_TOUCH_VERSION_1 //ESP32 original - touchInterruptSetThresholdDirection(flase); //todo: need to flip direction, for that proably need to read current state or something. -#endif - // For S2 and S3: nothing to do, ISR is just used to update registers of HAL driver -} \ No newline at end of file diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 82fb911a4c..771ada25b3 100755 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -228,7 +228,6 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { // read multiple button configuration JsonObject btn_obj = hw["btn"]; - CJSON(touchThreshold, btn_obj[F("tt")]); bool pull = btn_obj[F("pull")] | (!disablePullUp); // if true, pullup is enabled disablePullUp = !pull; JsonArray hw_btn_ins = btn_obj["ins"]; @@ -253,16 +252,8 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { btnPin[s] = -1; pinManager.deallocatePin(pin,PinOwner::Button); } - //if touch pin, enable the touch interrupt on ESP32 S2 & S3 - #ifdef SOC_TOUCH_VERSION_2 // ESP32 S2 and S3 have a fucntion to check touch state but need to attach an interrupt to do so - else if ((buttonType[s] == BTN_TYPE_TOUCH || buttonType[s] == BTN_TYPE_TOUCH_SWITCH)) - { - touchAttachInterrupt(btnPin[s], touchButtonISR, touchThreshold<<2); //threshold on Touch V2 is much higher (TODO: may need shift by 3 if very noisy) - } - #endif - else - #endif + #endif { if (disablePullUp) { pinMode(btnPin[s], INPUT); @@ -308,7 +299,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { } } } - + CJSON(touchThreshold,btn_obj[F("tt")]); CJSON(buttonPublishMqtt,btn_obj["mqtt"]); int hw_ir_pin = hw["ir"]["pin"] | -2; // 4 diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index c902dad64f..47a8173cce 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -20,7 +20,6 @@ void doublePressAction(uint8_t b=0); bool isButtonPressed(uint8_t b=0); void handleButton(); void handleIO(); -void IRAM_ATTR touchButtonISR(); //cfg.cpp bool deserializeConfig(JsonObject doc, bool fromFS = false);