From 33919e9e3f419e13318fa6b8217d8c8dcd86c1eb Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 11 Apr 2024 15:16:35 +1000 Subject: Migrate all existing control schemes to the cool new world --- src/drivers/touchwheel.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/drivers/touchwheel.cpp') 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, -- cgit v1.2.3