[esp32_touch] Work around ESP-IDF v5.4 regression in touch_pad_read_filtered()

This commit is contained in:
J. Nick Koston 2025-07-28 22:08:29 -10:00
parent ace375944c
commit e0e0a1a420
No known key found for this signature in database

View File

@ -201,15 +201,13 @@ void IRAM_ATTR ESP32TouchComponent::touch_isr_handler(void *arg) {
touch_pad_t pad = child->get_touch_pad(); touch_pad_t pad = child->get_touch_pad();
// Read current value using ISR-safe API // Read current value using ISR-safe API
uint32_t value; // IMPORTANT: ESP-IDF v5.4 regression - touch_pad_read_filtered() is no longer ISR-safe
if (component->iir_filter_enabled_()) { // In v5.3 and earlier it was ISR-safe, but v5.4 added mutex protection that causes:
uint16_t temp_value = 0; // "assert failed: xQueueSemaphoreTake queue.c:1718"
touch_pad_read_filtered(pad, &temp_value); // We must use raw values even when filter is enabled as a workaround.
value = temp_value; // Users should adjust thresholds to compensate for the lack of IIR filtering.
} else { // See: https://github.com/espressif/esp-idf/issues/17045
// Use low-level HAL function when filter is not enabled uint32_t value = touch_ll_read_raw_data(pad);
value = touch_ll_read_raw_data(pad);
}
// Skip pads that arent in the trigger mask // Skip pads that arent in the trigger mask
if (((mask >> pad) & 1) == 0) { if (((mask >> pad) & 1) == 0) {