From 857c43940dc82621a71c4c1aaa280e4ae7698f13 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sat, 21 Dec 2024 21:54:54 +0100 Subject: [PATCH] CodeRabbitAI Nitpick --- ...TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml | 16 ++++++++-------- .../TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml | 3 +++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml index a7bfec1..072479e 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml @@ -23,7 +23,7 @@ substitutions: BUTTON_CLICK_MIN_LENGTH: '50' # The minimum duration the click should last, in msec BUTTON_CLICK_MAX_LENGTH: '350' # The maximum duration the click should last, in msec BUTTON_MULTI_CLICK_DELAY: '500' # The time to wait for another click, in msec - BUTTON_PRESS_TIMEOUT: '10000' # Ignore if buttor is pressed for longer than this time, in msec + BUTTON_PRESS_TIMEOUT: '10000' # Ignore if button is pressed for longer than this time, in msec BUTTON_LONG_PRESS_DELAY: '800' # The time to wait to consider a long press, in msec binary_sensor: @@ -120,12 +120,12 @@ script: - delay: milliseconds: ${BUTTON_MULTI_CLICK_DELAY} - lambda: |- - button_action->execute( - ("bs_button_" + std::to_string(id(button_press_button))).c_str(), - (id(click_counter) == 1 ? "click" : - (id(click_counter) == 2 ? "double_click" : - (std::to_string(id(click_counter)) + "_click").c_str())) - ); + const std::string button_name = "bs_button_" + std::to_string(id(button_press_button)); + std::string event_name; + if (id(click_counter) == 1) event_name = "click"; + else if (id(click_counter) == 2) event_name = "double_click"; + else event_name = std::to_string(id(click_counter)) + "_click"; + button_action->execute(button_name.c_str(), event_name.c_str()); - id: buttons_release mode: restart @@ -165,7 +165,7 @@ script: if (model_idx == 1) { button = 1; // Single button, always 1 } else { - const uint8_t step = 10 / model_idx; // Calculate step size for regions + const uint8_t step = ${TOUCH_POSITION_MAX_VALUE} / model_idx; // Width of each button region button = (touch_x / step) + 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 86bf53c..b8c8b90 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml @@ -11,6 +11,9 @@ ##### - For normal system use, modifications to this file are NOT required. ##### #################################################################################################### --- +substitutions: + TOUCH_POSITION_MAX_VALUE: '10' # Maximum touch position value + binary_sensor: - id: bs_multi_touch name: Multi-touch