CodeRabbitAI Nitpick 2

This commit is contained in:
Edward Firmo
2024-12-21 22:08:19 +01:00
parent 857c43940d
commit 5ae4564e6a
2 changed files with 12 additions and 9 deletions

View File

@@ -148,16 +148,16 @@ script:
then:
- script.execute:
id: touch_on_press_buttons
touch_x: !lambda return touch_x;
touch_position: !lambda return touch_position;
- id: touch_on_press_buttons
mode: restart
parameters:
touch_x: uint8_t
touch_position: uint8_t
then:
- lambda: |-
id(button_press_start_time) = millis();
id(button_press_position) = touch_x;
id(button_press_position) = touch_position;
uint8_t button = 0;
auto model_index = sl_tx_model_gang->active_index();
if (model_index.has_value()) {
@@ -166,7 +166,7 @@ script:
button = 1; // Single button, always 1
} else {
const uint8_t step = ${TOUCH_POSITION_MAX_VALUE} / model_idx; // Width of each button region
button = (touch_x / step) + 1; // Determine button region
button = (touch_position / step) + 1; // Determine button region
if (button > model_idx)
button = model_idx; // Clamp to max button count
}

View File

@@ -127,7 +127,7 @@ script:
- id: touch_on_press
mode: restart
parameters:
touch_x: uint8_t
touch_position: uint8_t
then:
# Extended by:
# - HW Buttons
@@ -212,10 +212,13 @@ tx_ultimate_easy:
on_press:
- lambda: |-
ESP_LOGI("tx_ultimate_easy", "Pressed at position %" PRIu8, static_cast<uint8_t>(touch.x));
- script.execute:
id: touch_on_press
touch_x: !lambda return 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
ESP_LOGE("core_hw_buttons", "Invalid touch position: %" PRIu8, touch_position);
} else {
ESP_LOGI("tx_ultimate_easy", "Pressed at position %" PRIu8, touch_position);
touch_on_press->execute(touch_position);
}
on_release:
- lambda: ESP_LOGI("tx_ultimate_easy", "Released");