fix(joystick): add offsets

This commit is contained in:
2026-04-28 19:18:32 +02:00
parent 5c9a089781
commit bcb2047f60
2 changed files with 5 additions and 2 deletions
+3
View File
@@ -25,4 +25,7 @@ class Joystick {
uint8_t vrx;
uint8_t vry;
uint8_t sw;
const uint8_t xOffset = 13;
const uint8_t yOffset = 10;
};
+2 -2
View File
@@ -9,11 +9,11 @@ Joystick::Joystick() : vrx(A0), vry(A1), sw(4) {
// Map the analog readings from the joystick to a range of -100 to 100 for both X and Y axes
double Joystick::getX() const {
return map(analogRead(vrx), 0, 1023, -100, 100);
return map(analogRead(vrx), 0, 1023, -100, 100) + xOffset;
}
double Joystick::getY() const {
return map(analogRead(vry), 0, 1023, -100, 100);
return map(analogRead(vry), 0, 1023, -100, 100) + yOffset;
}
// Check if the joystick button is pressed (active LOW)