diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml index 667b380..50b7170 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml @@ -165,8 +165,10 @@ script: if (model_idx == 1) { button = 1; // Single button, always 1 } else { - const uint8_t step = ${TOUCH_POSITION_MAX_VALUE} / model_idx; // Width of each button region - button = (touch_position / step) + 1; // Determine button region + const uint8_t width = ${TOUCH_POSITION_MAX_VALUE} / model_idx; // Width of each button region + ESP_LOGV("core_hw_buttons", "Button regions: width=%" PRIu8 ", touch_position=%" PRIu8, + width, touch_position); + button = (touch_position / width) + 1; // Determine button region if (button > model_idx) button = model_idx; // Clamp to max button count } diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml index 81636b3..0a47ab3 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml @@ -12,7 +12,7 @@ #################################################################################################### --- substitutions: - TOUCH_POSITION_MAX_VALUE: '10' # Maximum touch position value + TOUCH_POSITION_MAX_VALUE: '10' # Maximum touch position value returned by the touch pad via uart binary_sensor: - id: bs_multi_touch @@ -206,6 +206,15 @@ tx_ultimate_easy: id: tx_ultimate uart: uart_touch + on_long_touch_release: + - lambda: |- + const uint8_t touch_position = static_cast(touch.x); + if (touch_position > ${TOUCH_POSITION_MAX_VALUE}) { // Check for valid range + ESP_LOGE("tx_ultimate_easy", "Invalid long-touch position: %" PRIu8, touch_position); + } else { + ESP_LOGI("tx_ultimate_easy", "Long-touch released at position %" PRIu8, touch_position); + } + on_multi_touch_release: - lambda: ESP_LOGI("tx_ultimate_easy", "Multi-touch released"); - script.execute: touch_on_multi_touch_release @@ -214,7 +223,7 @@ tx_ultimate_easy: - lambda: |- const uint8_t touch_position = static_cast(touch.x); if (touch_position > ${TOUCH_POSITION_MAX_VALUE}) { // Check for valid range - ESP_LOGE("core_hw_buttons", "Invalid touch position: %" PRIu8, touch_position); + ESP_LOGE("tx_ultimate_easy", "Invalid touch position: %" PRIu8, touch_position); } else { ESP_LOGI("tx_ultimate_easy", "Pressed at position %" PRIu8, touch_position); touch_on_press->execute(touch_position);