Log long-press from component
If this works fine, it could replace this part on the new implementation.
This commit is contained in:
@@ -165,8 +165,10 @@ script:
|
|||||||
if (model_idx == 1) {
|
if (model_idx == 1) {
|
||||||
button = 1; // Single button, always 1
|
button = 1; // Single button, always 1
|
||||||
} else {
|
} else {
|
||||||
const uint8_t step = ${TOUCH_POSITION_MAX_VALUE} / model_idx; // Width of each button region
|
const uint8_t width = ${TOUCH_POSITION_MAX_VALUE} / model_idx; // Width of each button region
|
||||||
button = (touch_position / step) + 1; // Determine 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)
|
if (button > model_idx)
|
||||||
button = model_idx; // Clamp to max button count
|
button = model_idx; // Clamp to max button count
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
####################################################################################################
|
####################################################################################################
|
||||||
---
|
---
|
||||||
substitutions:
|
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:
|
binary_sensor:
|
||||||
- id: bs_multi_touch
|
- id: bs_multi_touch
|
||||||
@@ -206,6 +206,15 @@ tx_ultimate_easy:
|
|||||||
id: tx_ultimate
|
id: tx_ultimate
|
||||||
uart: uart_touch
|
uart: uart_touch
|
||||||
|
|
||||||
|
on_long_touch_release:
|
||||||
|
- lambda: |-
|
||||||
|
const uint8_t touch_position = static_cast<uint8_t>(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:
|
on_multi_touch_release:
|
||||||
- lambda: ESP_LOGI("tx_ultimate_easy", "Multi-touch released");
|
- lambda: ESP_LOGI("tx_ultimate_easy", "Multi-touch released");
|
||||||
- script.execute: touch_on_multi_touch_release
|
- script.execute: touch_on_multi_touch_release
|
||||||
@@ -214,7 +223,7 @@ tx_ultimate_easy:
|
|||||||
- lambda: |-
|
- lambda: |-
|
||||||
const uint8_t touch_position = static_cast<uint8_t>(touch.x);
|
const uint8_t touch_position = static_cast<uint8_t>(touch.x);
|
||||||
if (touch_position > ${TOUCH_POSITION_MAX_VALUE}) { // Check for valid range
|
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 {
|
} else {
|
||||||
ESP_LOGI("tx_ultimate_easy", "Pressed at position %" PRIu8, touch_position);
|
ESP_LOGI("tx_ultimate_easy", "Pressed at position %" PRIu8, touch_position);
|
||||||
touch_on_press->execute(touch_position);
|
touch_on_press->execute(touch_position);
|
||||||
|
|||||||
Reference in New Issue
Block a user