From bf0a5ca83dc6c41217b701ef2d4101c67f9bbbbd Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Mon, 5 May 2025 21:18:33 -0500 Subject: [PATCH] Cleanup for 20948 compass --- src/main.cpp | 3 ++- src/motion/ICM20948Sensor.cpp | 12 +++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 12d123780..7ce993bf1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1300,7 +1300,8 @@ void setup() LOG_DEBUG("Free heap : %7d bytes", ESP.getFreeHeap()); LOG_DEBUG("Free PSRAM : %7d bytes", ESP.getFreePsram()); #endif - accelerometerThread->calibrate(30); + if (accelerometerThread) + accelerometerThread->calibrate(30); } #endif uint32_t rebootAtMsec; // If not zero we will reboot at this time (used to reboot shortly after the update completes) diff --git a/src/motion/ICM20948Sensor.cpp b/src/motion/ICM20948Sensor.cpp index 293e06648..dd0d5efba 100755 --- a/src/motion/ICM20948Sensor.cpp +++ b/src/motion/ICM20948Sensor.cpp @@ -88,18 +88,16 @@ int32_t ICM20948Sensor::runOnce() // lowestY, highestY, lowestZ, highestZ); } - int highestRealX = highestX - (highestX + lowestX) / 2; - magX -= (highestX + lowestX) / 2; magY -= (highestY + lowestY) / 2; magZ -= (highestZ + lowestZ) / 2; FusionVector ga, ma; - ga.axis.x = -(sensor->agmt.acc.axes.x); // default location for the BMX160 is on the rear of the board + ga.axis.x = (sensor->agmt.acc.axes.x); ga.axis.y = -(sensor->agmt.acc.axes.y); - ga.axis.z = (sensor->agmt.acc.axes.z); - ma.axis.x = -magX; - ma.axis.y = -magY; - ma.axis.z = magZ * 3; + ga.axis.z = -(sensor->agmt.acc.axes.z); + ma.axis.x = magX; + ma.axis.y = magY; + ma.axis.z = magZ; // If we're set to one of the inverted positions if (config.display.compass_orientation > meshtastic_Config_DisplayConfig_CompassOrientation_DEGREES_270) {