diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-02-13 10:31:48 +1100 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2024-02-13 10:31:48 +1100 |
| commit | 26ae027d6721510e4b4a8107e95acc57efaaf2c6 (patch) | |
| tree | 50bec1d5581f2c8f6bb18e42013e180b266a7bca /src/drivers/relative_wheel.cpp | |
| parent | 0426d245c8d863f18babdfbaf21c8673b0746feb (diff) | |
| download | tangara-fw-26ae027d6721510e4b4a8107e95acc57efaaf2c6.tar.gz | |
Sensitivity value now between 0 and 255
Diffstat (limited to 'src/drivers/relative_wheel.cpp')
| -rw-r--r-- | src/drivers/relative_wheel.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
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 { |
