diff --git a/wled00/button.cpp b/wled00/button.cpp index bf093a2071..05c6ad4bbc 100644 --- a/wled00/button.cpp +++ b/wled00/button.cpp @@ -100,10 +100,8 @@ bool isButtonPressed(uint8_t i) 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; - } + if (touchInterruptGetLastStatus(pin)) + return true; #else if (digitalPinToTouchChannel(btnPin[i]) >= 0 && touchRead(pin) <= touchThreshold) { @@ -419,9 +417,10 @@ void handleIO() 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 + // used for ESP32 S2 and S3: nothing to do, ISR is just used to update registers of HAL driver + // asm volatile("nop" ::); //prevent compiler to remove this function (TODO: is this really needed? probably not) + + // #if defined SOC_TOUCH_VERSION_1 //ESP32 original -> unused + // touchInterruptSetThresholdDirection(false); //todo: need to flip direction, for that proably need to read current state or something. + // #endif } \ No newline at end of file diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 82fb911a4c..416497f2f1 100755 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -257,7 +257,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { #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) + touchAttachInterrupt(btnPin[s], touchButtonISR, touchThreshold<<4); //threshold on Touch V2 is much higher (1500 is a value given by Espressif example) } #endif