From c36af8a220e21826a00ab0490c9c97c29c918e5d Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sat, 2 Aug 2025 23:26:49 +0200 Subject: [PATCH] Return last position on swipe As per #110 --- .../tx_ultimate_easy/tx_ultimate_easy.cpp | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/components/tx_ultimate_easy/tx_ultimate_easy.cpp b/components/tx_ultimate_easy/tx_ultimate_easy.cpp index d233abf..1efc794 100644 --- a/components/tx_ultimate_easy/tx_ultimate_easy.cpp +++ b/components/tx_ultimate_easy/tx_ultimate_easy.cpp @@ -141,9 +141,33 @@ 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: - return uart_received_bytes[5]; + switch (uart_received_bytes[5]) { + case 12: { + for (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 (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: return uart_received_bytes[6];