diff options
| author | cooljqln <cooljqln@noreply.codeberg.org> | 2024-04-11 07:02:53 +0000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2024-04-11 07:02:53 +0000 |
| commit | dd1ea595a7753706d4fa5f19b66f3dc1cbd56a02 (patch) | |
| tree | 60bfa4569af0f9506ccffe85f19e89bbe2a83332 /src/drivers/touchwheel.cpp | |
| parent | f580928cbab797e4e8a3eae5ae1c0b18b8066066 (diff) | |
| parent | 33919e9e3f419e13318fa6b8217d8c8dcd86c1eb (diff) | |
| download | tangara-fw-dd1ea595a7753706d4fa5f19b66f3dc1cbd56a02.tar.gz | |
Merge pull request 'jqln/input-devices' (#62) from jqln/input-devices into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/62
Reviewed-by: ailurux <ailurux@noreply.codeberg.org>
Diffstat (limited to 'src/drivers/touchwheel.cpp')
| -rw-r--r-- | src/drivers/touchwheel.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/drivers/touchwheel.cpp b/src/drivers/touchwheel.cpp index a20f434b..41b9a6af 100644 --- a/src/drivers/touchwheel.cpp +++ b/src/drivers/touchwheel.cpp @@ -28,6 +28,13 @@ namespace drivers { static const uint8_t kTouchWheelAddress = 0x1C; static const gpio_num_t kIntPin = GPIO_NUM_25; +auto TouchWheel::isAngleWithin(int16_t wheel_angle, + int16_t target_angle, + int threshold) -> bool { + int16_t difference = (wheel_angle - target_angle + 127 + 255) % 255 - 127; + return difference <= threshold && difference >= -threshold; +} + TouchWheel::TouchWheel() { gpio_config_t int_config{ .pin_bit_mask = 1ULL << kIntPin, |
