From c3fe3711a6b30c6321be3564f419a16817279e87 Mon Sep 17 00:00:00 2001 From: Uladzimir Bely Date: Sun, 19 Apr 2026 07:12:29 +0300 Subject: [PATCH] Fix analog joystik. After commits 8d8b640 and e07a949, analogRead() returns values in the range 0..4095, since PushButton.cpp continues working in 0..1023. This causes incorrect (too big) thresholdNS and thresholdEW values and joystick doesn't work (stucks in one direction). Fixes issue #24. --- src/userInterface/UserInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/userInterface/UserInterface.cpp b/src/userInterface/UserInterface.cpp index a77c7763..274e3725 100644 --- a/src/userInterface/UserInterface.cpp +++ b/src/userInterface/UserInterface.cpp @@ -119,8 +119,8 @@ void UI::init(const char version[], const KeyPad::Pin pins[7], const int SerialB pinMode(B_PIN1, INPUT_PULLUP); pinMode(B_PIN3, INPUT_PULLUP); delay(100); - int thresholdEW = analogRead(B_PIN1); - int thresholdNS = analogRead(B_PIN3); + int thresholdEW = analogRead(B_PIN1) >> 2; + int thresholdNS = analogRead(B_PIN3) >> 2; keyPad.init(pins, thresholdNS, thresholdEW); #else keyPad.init(pins, 0, 0);