added interrupt detach to cfg.cpp

This commit is contained in:
Damian Schneider 2024-03-10 16:54:25 +01:00
parent 509675fe66
commit 0453a5fb3d

View File

@ -235,6 +235,9 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
if (!hw_btn_ins.isNull()) { if (!hw_btn_ins.isNull()) {
for (uint8_t b = 0; b < WLED_MAX_BUTTONS; b++) { // deallocate existing button pins for (uint8_t b = 0; b < WLED_MAX_BUTTONS; b++) { // deallocate existing button pins
pinManager.deallocatePin(btnPin[b], PinOwner::Button); // does nothing if trying to deallocate a pin with PinOwner != Button pinManager.deallocatePin(btnPin[b], PinOwner::Button); // does nothing if trying to deallocate a pin with PinOwner != Button
#ifdef SOC_TOUCH_VERSION_2 // ESP32 S2 and S3 have a fucntion to check touch state, detach any previous assignments
touchDetachInterrupt(btnPin[b]);
#endif
} }
uint8_t s = 0; uint8_t s = 0;
for (JsonObject btn : hw_btn_ins) { for (JsonObject btn : hw_btn_ins) {
@ -260,9 +263,8 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
touchAttachInterrupt(btnPin[s], touchButtonISR, touchThreshold<<4); //threshold on Touch V2 is much higher (1500 is a value given by Espressif example) touchAttachInterrupt(btnPin[s], touchButtonISR, touchThreshold<<4); //threshold on Touch V2 is much higher (1500 is a value given by Espressif example)
} }
#endif #endif
else else
#endif #endif
{ {
if (disablePullUp) { if (disablePullUp) {
pinMode(btnPin[s], INPUT); pinMode(btnPin[s], INPUT);