diff options
| author | Rockwell Schrock <rockwell@schrock.me> | 2025-02-01 00:16:04 -0500 |
|---|---|---|
| committer | Rockwell Schrock <rockwell@schrock.me> | 2025-02-01 01:18:29 -0500 |
| commit | 6c323f0fd075beb406df04d444fc4029b733ceb4 (patch) | |
| tree | 3d100b972079b34c7e7e26e73681bf4396e40fe9 /src/tangara/input/input_touch_wheel.cpp | |
| parent | b98e67972bca390961ecd2240ab3d3553ea0bf86 (diff) | |
| download | tangara-fw-6c323f0fd075beb406df04d444fc4029b733ceb4.tar.gz | |
Don't detect center button touch until 250ms after wheel touch
Diffstat (limited to 'src/tangara/input/input_touch_wheel.cpp')
| -rw-r--r-- | src/tangara/input/input_touch_wheel.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/tangara/input/input_touch_wheel.cpp b/src/tangara/input/input_touch_wheel.cpp index 19ac5211..6621a77e 100644 --- a/src/tangara/input/input_touch_wheel.cpp +++ b/src/tangara/input/input_touch_wheel.cpp @@ -21,6 +21,8 @@ #include "lua/property.hpp" #include "ui/ui_events.hpp" +#include "esp_timer.h" + namespace input { TouchWheel::TouchWheel(drivers::NvsStorage& nvs, drivers::TouchWheel& wheel) @@ -77,7 +79,16 @@ auto TouchWheel::read(lv_indev_data_t* data) -> void { data->enc_diff = 0; } - centre_.update(wheel_data.is_button_touched && !wheel_data.is_wheel_touched, + // Prevent accidental center button touches while scrolling + if (wheel_data.is_wheel_touched) { + last_wheel_touch_time_ = esp_timer_get_time(); + } + + bool wheel_touch_timed_out = + esp_timer_get_time() - last_wheel_touch_time_ > SCROLL_TIMEOUT_US; + + centre_.update(wheel_touch_timed_out && wheel_data.is_button_touched && + !wheel_data.is_wheel_touched, data); // If the user is touching the wheel but not scrolling, then they may be |
