diff options
Diffstat (limited to 'src/drivers/relative_wheel.cpp')
| -rw-r--r-- | src/drivers/relative_wheel.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/drivers/relative_wheel.cpp b/src/drivers/relative_wheel.cpp index 2b8c9b20..e90143ae 100644 --- a/src/drivers/relative_wheel.cpp +++ b/src/drivers/relative_wheel.cpp @@ -16,6 +16,8 @@ namespace drivers { RelativeWheel::RelativeWheel(TouchWheel& touch) : touch_(touch), is_enabled_(true), + sensitivity_(128), + threshold_(10), is_clicking_(false), was_clicking_(false), is_first_read_(true), @@ -47,12 +49,10 @@ auto RelativeWheel::Update() -> void { int delta = 128 - last_angle_; uint8_t rotated_angle = new_angle + delta; - int threshold = 10; - - if (rotated_angle < 128 - threshold) { + if (rotated_angle < 128 - threshold_) { ticks_ = 1; last_angle_ = new_angle; - } else if (rotated_angle > 128 + threshold) { + } else if (rotated_angle > 128 + threshold_) { ticks_ = -1; last_angle_ = new_angle; } else { @@ -64,6 +64,17 @@ auto RelativeWheel::SetEnabled(bool en) -> void { is_enabled_ = en; } +auto RelativeWheel::SetSensitivity(uint8_t val) -> void { + sensitivity_ = val; + int tmax = 35; + int tmin = 5; + threshold_ = (((255. - sensitivity_)/255.)*(tmax - tmin) + tmin); +} + +auto RelativeWheel::GetSensitivity() -> uint8_t { + return sensitivity_; +} + auto RelativeWheel::is_clicking() const -> bool { if (!is_enabled_) { return false; |
