summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua/settings.lua9
-rw-r--r--src/drivers/include/relative_wheel.hpp7
-rw-r--r--src/drivers/relative_wheel.cpp13
-rw-r--r--src/ui/encoder_input.cpp2
-rw-r--r--src/ui/include/encoder_input.hpp2
5 files changed, 19 insertions, 14 deletions
diff --git a/lua/settings.lua b/lua/settings.lua
index bb5c8eb3..952292e4 100644
--- a/lua/settings.lua
+++ b/lua/settings.lua
@@ -260,14 +260,15 @@ function settings.input()
text = "Scroll Sensitivity",
}:add_style(theme.settings_title)
+ local slider_scale = 4; -- Power steering
local sensitivity = menu.content:Slider {
- w = lvgl.PCT(100),
+ w = lvgl.PCT(90),
h = 5,
- range = { min = 5, max = 45 },
- value = controls.scroll_sensitivity:get(),
+ range = { min = 0, max = 255/slider_scale },
+ value = controls.scroll_sensitivity:get()/slider_scale,
}
sensitivity:onevent(lvgl.EVENT.VALUE_CHANGED, function()
- controls.scroll_sensitivity:set(sensitivity:value())
+ controls.scroll_sensitivity:set(sensitivity:value()*slider_scale)
end)
return menu
diff --git a/src/drivers/include/relative_wheel.hpp b/src/drivers/include/relative_wheel.hpp
index a44e3598..e1106143 100644
--- a/src/drivers/include/relative_wheel.hpp
+++ b/src/drivers/include/relative_wheel.hpp
@@ -25,8 +25,8 @@ class RelativeWheel {
auto Update() -> void;
auto SetEnabled(bool) -> void;
- auto SetThreshold(int) -> void;
- auto GetThreshold() -> int;
+ auto SetSensitivity(uint8_t) -> void;
+ auto GetSensitivity() -> uint8_t;
auto is_clicking() const -> bool;
auto ticks() const -> std::int_fast16_t;
@@ -39,7 +39,8 @@ class RelativeWheel {
TouchWheel& touch_;
bool is_enabled_;
- int threshold_;
+ uint8_t sensitivity_;
+ uint8_t threshold_;
bool is_clicking_;
bool was_clicking_;
diff --git a/src/drivers/relative_wheel.cpp b/src/drivers/relative_wheel.cpp
index 056c80c9..e90143ae 100644
--- a/src/drivers/relative_wheel.cpp
+++ b/src/drivers/relative_wheel.cpp
@@ -16,6 +16,7 @@ namespace drivers {
RelativeWheel::RelativeWheel(TouchWheel& touch)
: touch_(touch),
is_enabled_(true),
+ sensitivity_(128),
threshold_(10),
is_clicking_(false),
was_clicking_(false),
@@ -48,7 +49,6 @@ auto RelativeWheel::Update() -> void {
int delta = 128 - last_angle_;
uint8_t rotated_angle = new_angle + delta;
-
if (rotated_angle < 128 - threshold_) {
ticks_ = 1;
last_angle_ = new_angle;
@@ -64,12 +64,15 @@ auto RelativeWheel::SetEnabled(bool en) -> void {
is_enabled_ = en;
}
-auto RelativeWheel::SetThreshold(int val) -> void {
- threshold_ = val;
+auto RelativeWheel::SetSensitivity(uint8_t val) -> void {
+ sensitivity_ = val;
+ int tmax = 35;
+ int tmin = 5;
+ threshold_ = (((255. - sensitivity_)/255.)*(tmax - tmin) + tmin);
}
-auto RelativeWheel::GetThreshold() -> int {
- return threshold_;
+auto RelativeWheel::GetSensitivity() -> uint8_t {
+ return sensitivity_;
}
auto RelativeWheel::is_clicking() const -> bool {
diff --git a/src/ui/encoder_input.cpp b/src/ui/encoder_input.cpp
index 3eebe16e..3b5af2c1 100644
--- a/src/ui/encoder_input.cpp
+++ b/src/ui/encoder_input.cpp
@@ -275,7 +275,7 @@ auto EncoderInput::Read(lv_indev_data_t* data) -> void {
auto EncoderInput::scroll_sensitivity(uint8_t val) -> void {
scroll_sensitivity_ = val;
- relative_wheel_->SetThreshold(scroll_sensitivity_);
+ relative_wheel_->SetSensitivity(scroll_sensitivity_);
}
auto EncoderInput::UpdateKeyState(Keys key, uint64_t ms, bool clicked) -> void {
diff --git a/src/ui/include/encoder_input.hpp b/src/ui/include/encoder_input.hpp
index 17e278b2..7dfac071 100644
--- a/src/ui/include/encoder_input.hpp
+++ b/src/ui/include/encoder_input.hpp
@@ -38,7 +38,7 @@ class EncoderInput {
auto registration() -> lv_indev_t* { return registration_; }
auto mode(drivers::NvsStorage::InputModes mode) { mode_ = mode; }
- auto scroll_sensitivity(uint8_t val) -> void;
+ auto scroll_sensitivity(uint8_t val) -> void; // Value between 0-255, used to scale the threshold
auto lock(bool l) -> void { is_locked_ = l; }
private: