summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/include/relative_wheel.hpp7
-rw-r--r--src/drivers/relative_wheel.cpp13
2 files changed, 12 insertions, 8 deletions
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 {