diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index ea3c246..dc50d74 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -55,9 +55,10 @@ jobs: - name: Update stable tag if: | - success() && - github.event_name == 'workflow_dispatch' && - inputs.update_stable + success() && ( + github.event_name == 'workflow_dispatch' && inputs.update_stable || + github.event_name == 'push' + ) run: | # Verify version bump was successful if [ ! -f "./versioning/VERSION" ]; then @@ -74,7 +75,7 @@ jobs: # Update tag NEW_VERSION=$(cat ./versioning/VERSION) echo "Updating stable tag to $NEW_VERSION" - git tag -fa stable -m "Update stable tag" + git tag -fa stable -m "Update stable tag to $NEW_VERSION" git push origin stable --force - name: Update latest tag @@ -99,6 +100,6 @@ jobs: # Update tag NEW_VERSION=$(cat ./versioning/VERSION) echo "Updating latest tag to $NEW_VERSION" - git tag -fa latest -m "Update latest tag" + git tag -fa latest -m "Update latest tag to $NEW_VERSION" git push origin latest --force ... diff --git a/README.md b/README.md index 9a81137..8368b31 100644 --- a/README.md +++ b/README.md @@ -161,11 +161,11 @@ Follow these steps to get your TX Ultimate device up and running with ESPHome. packages: remote_package: url: https://github.com/edwardtfn/TX-Ultimate-Easy - ref: stable # Or you can specify a version, like `ref: v2024.12.6` or `ref: latest` to the latest non-stable + ref: main # Or you can specify a version, like `ref: v2024.12.6` or `ref: latest` refresh: 5min files: - - ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml # Core (essential) packages - - ESPHome/TX-Ultimate-Easy-ESPHome_standard.yaml # Non-essential, but recommended packages + - ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml # Core (essential) packages + - ESPHome/TX-Ultimate-Easy-ESPHome_standard.yaml # Non-essential, but recommended packages ``` You can also use a specific version tag for better control over updates: ```yaml @@ -225,14 +225,14 @@ Here's an example of the advanced configuration: packages: remote_package: url: https://github.com/edwardtfn/TX-Ultimate-Easy - ref: stable # Or you can specify a version, like `ref: v2024.12.6` or `ref: latest` to the latest non-stable + ref: main # Or you can specify a version, like `ref: v2024.12.6` or `ref: latest` refresh: 5min files: # Core (essential) packages - - ESPHome/TX-Ultimate-Easy-ESPHome_core_common.yaml # Basic shared settings - - ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml # Button logic - - ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml # LED configuration - - ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml # Touch panel support + - ESPHome/TX-Ultimate-Easy-ESPHome_core_common.yaml # Basic shared settings + - ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml # Button logic + - ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml # LED configuration + - ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml # Touch panel support # Optional but recommended packages - ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_relays.yaml # Relay control diff --git a/components/tx_ultimate_easy/tx_ultimate_easy.cpp b/components/tx_ultimate_easy/tx_ultimate_easy.cpp index d233abf..82f560b 100644 --- a/components/tx_ultimate_easy/tx_ultimate_easy.cpp +++ b/components/tx_ultimate_easy/tx_ultimate_easy.cpp @@ -69,9 +69,9 @@ namespace esphome { if (this->gang_count_ == 1) return 1; - //Calculate button number Change to round up insted of truncate (integer division) + // Calculate button number Change to round up instead of truncate (integer division) const uint8_t width = (TOUCH_MAX_POSITION + gang_count_) / this->gang_count_; // Width of each button region - if (width < 1) // Invalid width - and prevents division by zero removed "width > gang_count_" issue with 2 gang + if (width < 1) // Invalid width - and prevents division by zero return 0; const uint8_t button = std::min( static_cast((position / width) + 1), // Convert position to button index @@ -141,8 +141,36 @@ namespace esphome { switch (uart_received_bytes[4]) { case TOUCH_STATE_RELEASE: case TOUCH_STATE_MULTI_TOUCH: + return uart_received_bytes[5]; + case TOUCH_STATE_SWIPE_LEFT: case TOUCH_STATE_SWIPE_RIGHT: + // uart_received_bytes[5] indicates swipe direction: + // 12 = find last touch position (scan right to left) + // 13 = find first touch position (scan left to right) + // Bytes 6-7 contain a 10-bit bitmap of touch positions: + // Byte 7: bits 0-7 represent positions 1-8 + // Byte 6: bits 0-1 represent positions 9-10 + switch (uart_received_bytes[5]) { + case 12: + for (uint8_t i = 10; i > 0; i--) { + if (i > 8 + ? uart_received_bytes[6] & (1 << (i - 9)) + : uart_received_bytes[7] & (1 << (i - 1))) { + return i; + } + } + break; + case 13: + for (uint8_t i = 1; i <= 10; i++) { + if (i > 8 + ? uart_received_bytes[6] & (1 << (i - 9)) + : uart_received_bytes[7] & (1 << (i - 1))) { + return i; + } + } + break; + } return uart_received_bytes[5]; default: @@ -152,8 +180,10 @@ namespace esphome { int TxUltimateEasy::get_touch_state(const std::array &uart_received_bytes) { int state = uart_received_bytes[4]; - if (state == TOUCH_STATE_PRESS && uart_received_bytes[5] != 0) state = TOUCH_STATE_RELEASE; - if (state == TOUCH_STATE_RELEASE && uart_received_bytes[5] == TOUCH_STATE_MULTI_TOUCH) state = TOUCH_STATE_MULTI_TOUCH; + if (state == TOUCH_STATE_PRESS && uart_received_bytes[5] != 0) + state = TOUCH_STATE_RELEASE; + if (state == TOUCH_STATE_RELEASE && uart_received_bytes[5] == TOUCH_STATE_MULTI_TOUCH) + state = TOUCH_STATE_MULTI_TOUCH; if (state == TOUCH_STATE_SWIPE) { state = (uart_received_bytes[5] == TOUCH_STATE_SWIPE_RIGHT) ? TOUCH_STATE_SWIPE_RIGHT : (uart_received_bytes[5] == TOUCH_STATE_SWIPE_LEFT) ? TOUCH_STATE_SWIPE_LEFT : state;