1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 17:25:20 +03:00

Added calibration menu to CMS.

This commit is contained in:
mikeller 2019-11-16 12:24:49 +13:00 committed by Michael Keller
parent c6e5882dd9
commit cedcf2d7e2
41 changed files with 387 additions and 143 deletions

View file

@ -275,7 +275,7 @@ bool baroDetect(baroDev_t *dev, baroSensor_e baroHardwareToUse)
return true;
}
bool isBaroCalibrationComplete(void)
bool baroIsCalibrationComplete(void)
{
return calibratingB == 0;
}
@ -434,7 +434,7 @@ int32_t baroCalculateAltitude(void)
// calculates height from ground via baro readings
// see: https://github.com/diydrones/ardupilot/blob/master/libraries/AP_Baro/AP_Baro.cpp#L140
if (isBaroCalibrationComplete()) {
if (baroIsCalibrationComplete()) {
BaroAlt_tmp = lrintf((1.0f - pow_approx((float)(baroPressureSum / PRESSURE_SAMPLE_COUNT) / 101325.0f, 0.190259f)) * 4433000.0f); // in cm
BaroAlt_tmp -= baroGroundAltitude;
baro.BaroAlt = lrintf((float)baro.BaroAlt * CONVERT_PARAMETER_TO_FLOAT(barometerConfig()->baro_noise_lpf) + (float)BaroAlt_tmp * (1.0f - CONVERT_PARAMETER_TO_FLOAT(barometerConfig()->baro_noise_lpf))); // additional LPF to reduce baro noise
@ -453,11 +453,11 @@ void performBaroCalibrationCycle(void)
baroGroundPressure += baroPressureSum / PRESSURE_SAMPLE_COUNT;
baroGroundAltitude = (1.0f - pow_approx((baroGroundPressure / 8) / 101325.0f, 0.190259f)) * 4433000.0f;
if (baroGroundPressure == savedGroundPressure)
calibratingB = 0;
else {
calibratingB--;
savedGroundPressure=baroGroundPressure;
if (baroGroundPressure == savedGroundPressure) {
calibratingB = 0;
} else {
calibratingB--;
savedGroundPressure = baroGroundPressure;
}
}