mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-14 06:42:34 +00:00
Further fix compass calibration (#8740)
* Update calibration logic for ICM20948 sensor Initialize highest and lowest magnetic values based on sensor data readiness during calibration. * Refactor BMX160 calibration to use magnetometer data Update calibration logic to initialize highest and lowest values using magnetometer data. * Add missed viable defines in ::calibrate()
This commit is contained in:
@@ -115,8 +115,13 @@ int32_t BMX160Sensor::runOnce()
|
|||||||
void BMX160Sensor::calibrate(uint16_t forSeconds)
|
void BMX160Sensor::calibrate(uint16_t forSeconds)
|
||||||
{
|
{
|
||||||
#if !defined(MESHTASTIC_EXCLUDE_SCREEN)
|
#if !defined(MESHTASTIC_EXCLUDE_SCREEN)
|
||||||
|
sBmx160SensorData_t magAccel;
|
||||||
|
sBmx160SensorData_t gAccel;
|
||||||
LOG_DEBUG("BMX160 calibration started for %is", forSeconds);
|
LOG_DEBUG("BMX160 calibration started for %is", forSeconds);
|
||||||
highestX = 0, lowestX = 0, highestY = 0, lowestY = 0, highestZ = 0, lowestZ = 0;
|
sensor.getAllData(&magAccel, NULL, &gAccel);
|
||||||
|
highestX = magAccel.x, lowestX = magAccel.x;
|
||||||
|
highestY = magAccel.y, lowestY = magAccel.y;
|
||||||
|
highestZ = magAccel.z, lowestZ = magAccel.z;
|
||||||
|
|
||||||
doCalibration = true;
|
doCalibration = true;
|
||||||
uint16_t calibrateFor = forSeconds * 1000; // calibrate for seconds provided
|
uint16_t calibrateFor = forSeconds * 1000; // calibrate for seconds provided
|
||||||
|
|||||||
@@ -157,7 +157,17 @@ void ICM20948Sensor::calibrate(uint16_t forSeconds)
|
|||||||
{
|
{
|
||||||
#if !defined(MESHTASTIC_EXCLUDE_SCREEN) && HAS_SCREEN
|
#if !defined(MESHTASTIC_EXCLUDE_SCREEN) && HAS_SCREEN
|
||||||
LOG_DEBUG("BMX160 calibration started for %is", forSeconds);
|
LOG_DEBUG("BMX160 calibration started for %is", forSeconds);
|
||||||
highestX = 0, lowestX = 0, highestY = 0, lowestY = 0, highestZ = 0, lowestZ = 0;
|
if (sensor->dataReady()) {
|
||||||
|
sensor->getAGMT();
|
||||||
|
highestX = sensor->agmt.mag.axes.x;
|
||||||
|
lowestX = sensor->agmt.mag.axes.x;
|
||||||
|
highestY = sensor->agmt.mag.axes.y;
|
||||||
|
lowestY = sensor->agmt.mag.axes.y;
|
||||||
|
highestZ = sensor->agmt.mag.axes.z;
|
||||||
|
lowestZ = sensor->agmt.mag.axes.z;
|
||||||
|
} else {
|
||||||
|
highestX = 0, lowestX = 0, highestY = 0, lowestY = 0, highestZ = 0, lowestZ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
doCalibration = true;
|
doCalibration = true;
|
||||||
uint16_t calibrateFor = forSeconds * 1000; // calibrate for seconds provided
|
uint16_t calibrateFor = forSeconds * 1000; // calibrate for seconds provided
|
||||||
|
|||||||
Reference in New Issue
Block a user