diff options
| author | slord <slord@noreply.codeberg.org> | 2025-02-04 21:17:57 +0000 |
|---|---|---|
| committer | slord <slord@noreply.codeberg.org> | 2025-02-04 21:17:57 +0000 |
| commit | 508c8c79102c6d095f92eaf72f42d3f61ef5e7ba (patch) | |
| tree | 8ea20e3fd06a5c6f84d88eb822ba8ef5f8667bcd /src/tangara/input/input_touch_wheel.cpp | |
| parent | ff733e8f0c827e3d2d91bb7db29a85807867ab5e (diff) | |
| parent | 813db15da84ee82066564b51f83be451cf121a00 (diff) | |
| download | tangara-fw-508c8c79102c6d095f92eaf72f42d3f61ef5e7ba.tar.gz | |
Merge branch 'main' into playlist-browser
Diffstat (limited to 'src/tangara/input/input_touch_wheel.cpp')
| -rw-r--r-- | src/tangara/input/input_touch_wheel.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/tangara/input/input_touch_wheel.cpp b/src/tangara/input/input_touch_wheel.cpp index 19ac5211..fba8a4cd 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 @@ -113,7 +124,7 @@ auto TouchWheel::triggers() return {centre_, up_, right_, down_, left_}; } -auto TouchWheel::onLock() -> void { +auto TouchWheel::onLock(drivers::NvsStorage::LockedInputModes mode) -> void { wheel_.LowPowerMode(true); locked_ = true; } |
