diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml index 50b7170..6de6fcf 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml @@ -116,15 +116,18 @@ script: - id: button_click_event mode: restart + parameters: + button_id: uint8_t + click_count: uint8_t then: - delay: milliseconds: ${BUTTON_MULTI_CLICK_DELAY} - lambda: |- - const std::string button_name = "bs_button_" + std::to_string(id(button_press_button)); + const std::string button_name = "bs_button_" + std::to_string(button_id); 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"; + if (click_count == 1) event_name = "click"; + else if (click_count == 2) event_name = "double_click"; + else event_name = std::to_string(click_count) + "_click"; button_action->execute(button_name.c_str(), event_name.c_str()); - id: buttons_release @@ -210,7 +213,7 @@ script: ESP_LOGW("core_hw_buttons", "Ignoring button press (too short)"); } else if (press_duration >= ${BUTTON_CLICK_MIN_LENGTH} and press_duration <= ${BUTTON_CLICK_MAX_LENGTH}) { // Short/normal click - button_click_event->execute(); + button_click_event->execute(id(button_press_button), id(click_counter)); } else if (press_duration >= ${BUTTON_LONG_PRESS_DELAY} and press_duration <= ${BUTTON_PRESS_TIMEOUT}) { button_action->execute(("bs_button_" + std::to_string(id(button_press_button))).c_str(), "long_click"); } else if (press_duration > ${BUTTON_PRESS_TIMEOUT}) { // Timeout or invalid diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index 7bb4e55..9bbf7a0 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -113,12 +113,15 @@ script: - id: !extend button_click_event then: - lambda: |- - if (id(click_counter) == 1) { // Single click + ESP_LOGW("DEBUG", "button_click_event"); + ESP_LOGW("DEBUG", " button_id: %" PRIu8, button_id); + ESP_LOGW("DEBUG", " click_count: %" PRIu8, click_count); + if (click_count == 1) { // Single click if (!bs_multi_touch->state and !bs_swipe_left->state and !bs_swipe_down->state and !bs_swipe_right->state) { // Ignore if other events are active - switch (id(button_press_button)) { + switch (button_id) { case 1: if (sl_button_1_action->active_index().has_value() and sl_button_1_action->active_index().value() == 1) diff --git a/components/tx_ultimate_easy/tx_ultimate_easy.cpp b/components/tx_ultimate_easy/tx_ultimate_easy.cpp index 6d90d4c..c6cce8d 100644 --- a/components/tx_ultimate_easy/tx_ultimate_easy.cpp +++ b/components/tx_ultimate_easy/tx_ultimate_easy.cpp @@ -131,6 +131,7 @@ namespace esphome { state == TOUCH_STATE_SWIPE_LEFT || state == TOUCH_STATE_SWIPE_RIGHT || state == TOUCH_STATE_MULTI_TOUCH) && + // Multi-touch events may have x < 0, all other events require valid x position (uart_received_bytes[6] >= 0 || state == TOUCH_STATE_MULTI_TOUCH); }