1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-26 17:55:28 +03:00

pass gyro cal using array

This commit is contained in:
JuliooCesarMDM 2021-11-26 21:59:30 -03:00
parent c19290e1b3
commit bee6ac200a
5 changed files with 15 additions and 23 deletions

View file

@ -465,16 +465,13 @@ void setConfigBatteryProfileAndWriteEEPROM(uint8_t profileIndex)
beeperConfirmationBeeps(profileIndex + 1);
}
void setCalibrationGyroAndWriteEEPROM(void) { // fixes Test Unit compilation error
if (gyro.ok_to_save_cal) {
void setCalibrationGyroAndWriteEEPROM(int16_t getGyroZero[XYZ_AXIS_COUNT]) {
gyroConfigMutable()->gyro_zero_cal[X] = getGyroZero[X];
gyroConfigMutable()->gyro_zero_cal[Y] = getGyroZero[Y];
gyroConfigMutable()->gyro_zero_cal[Z] = getGyroZero[Z];
// save gyro calibration
gyroConfigMutable()->gyro_zero_cal[X] = gyro.getZero[X];
gyroConfigMutable()->gyro_zero_cal[Y] = gyro.getZero[Y];
gyroConfigMutable()->gyro_zero_cal[Z] = gyro.getZero[Z];
writeEEPROM();
readEEPROM();
gyro.ok_to_save_cal = false;
}
}
void beeperOffSet(uint32_t mask)

View file

@ -19,6 +19,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "common/axis.h"
#include "common/time.h"
#include "config/parameter_group.h"
#include "drivers/adc.h"
@ -131,7 +132,7 @@ uint8_t getConfigBatteryProfile(void);
bool setConfigBatteryProfile(uint8_t profileIndex);
void setConfigBatteryProfileAndWriteEEPROM(uint8_t profileIndex);
void setCalibrationGyroAndWriteEEPROM(void);
void setCalibrationGyroAndWriteEEPROM(int16_t getGyroZero[XYZ_AXIS_COUNT]);
bool canSoftwareSerialBeUsed(void);
void applyAndSaveBoardAlignmentDelta(int16_t roll, int16_t pitch);

View file

@ -884,9 +884,6 @@ void taskMainPidLoop(timeUs_t currentTimeUs)
annexCode(dT);
// saves gyro calibration in storage outside of "gyroUpdate" to avoid compilation errors
setCalibrationGyroAndWriteEEPROM();
if (rxConfig()->rcFilterFrequency) {
rcInterpolationApply(isRXDataNew);
}

View file

@ -355,7 +355,7 @@ bool gyroIsCalibrationComplete(void)
STATIC_UNIT_TESTED void performGyroCalibration(gyroDev_t *dev, zeroCalibrationVector_t *gyroCalibration)
{
#ifndef USE_IMU_FAKE
#ifndef USE_IMU_FAKE // fixes Test Unit compilation error
if (!gyroConfig()->init_gyro_cal_enabled) {
gyroCalibration[0].params.state = ZERO_CALIBRATION_DONE; // calibration ended
// pass the calibration values
@ -382,10 +382,9 @@ STATIC_UNIT_TESTED void performGyroCalibration(gyroDev_t *dev, zeroCalibrationVe
dev->gyroZero[Y] = v.v[Y];
dev->gyroZero[Z] = v.v[Z];
gyro.getZero[X] = dev->gyroZero[X];
gyro.getZero[Y] = dev->gyroZero[Y];
gyro.getZero[Z] = dev->gyroZero[Z];
gyro.ok_to_save_cal = true;
#ifndef USE_IMU_FAKE // fixes Test Unit compilation error
setCalibrationGyroAndWriteEEPROM(dev->gyroZero);
#endif
LOG_D(GYRO, "Gyro calibration complete (%d, %d, %d)", dev->gyroZero[X], dev->gyroZero[Y], dev->gyroZero[Z]);
schedulerResetTaskStatistics(TASK_SELF); // so calibration cycles do not pollute tasks statistics

View file

@ -42,8 +42,6 @@ typedef enum {
typedef struct gyro_s {
bool initialized;
bool ok_to_save_cal;
int16_t getZero[XYZ_AXIS_COUNT];
uint32_t targetLooptime;
float gyroADCf[XYZ_AXIS_COUNT];
} gyro_t;