mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-20 14:55:21 +03:00
add missing haveGpsAlt and haveBaroAlt checks
simplify conditions
This commit is contained in:
parent
fe4c3ac149
commit
bd5b73d6b0
1 changed files with 14 additions and 27 deletions
|
@ -144,37 +144,24 @@ if (sensors(SENSOR_GPS) && STATE(GPS_FIX)) {
|
||||||
baroAlt -= baroAltOffset;
|
baroAlt -= baroAltOffset;
|
||||||
gpsAlt -= gpsAltOffset;
|
gpsAlt -= gpsAltOffset;
|
||||||
|
|
||||||
if(positionConfig()->altSource == BARO_ONLY){
|
|
||||||
estimatedAltitudeCm = baroAlt;
|
if (haveGpsAlt && haveBaroAlt && positionConfig()->altSource == DEFAULT) {
|
||||||
#ifdef USE_VARIO
|
|
||||||
estimatedVario = calculateEstimatedVario(baroAlt, dTime);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (positionConfig()->altSource == GPS_ONLY){
|
|
||||||
estimatedAltitudeCm = gpsAlt;
|
|
||||||
#if defined(USE_VARIO) && defined(USE_GPS)
|
|
||||||
estimatedVario = gpsVertSpeed;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (haveGpsAlt && haveBaroAlt) {
|
|
||||||
estimatedAltitudeCm = gpsAlt * gpsTrust + baroAlt * (1 - gpsTrust);
|
estimatedAltitudeCm = gpsAlt * gpsTrust + baroAlt * (1 - gpsTrust);
|
||||||
#ifdef USE_VARIO
|
#ifdef USE_VARIO
|
||||||
// baro is a better source for vario, so ignore gpsVertSpeed
|
// baro is a better source for vario, so ignore gpsVertSpeed
|
||||||
estimatedVario = calculateEstimatedVario(baroAlt, dTime);
|
estimatedVario = calculateEstimatedVario(baroAlt, dTime);
|
||||||
#endif
|
#endif
|
||||||
} else if (haveGpsAlt) {
|
} else if (haveGpsAlt && (positionConfig()->altSource == GPS_ONLY || positionConfig()->altSource == DEFAULT )) {
|
||||||
estimatedAltitudeCm = gpsAlt;
|
estimatedAltitudeCm = gpsAlt;
|
||||||
#if defined(USE_VARIO) && defined(USE_GPS)
|
#if defined(USE_VARIO) && defined(USE_GPS)
|
||||||
estimatedVario = gpsVertSpeed;
|
estimatedVario = gpsVertSpeed;
|
||||||
#endif
|
#endif
|
||||||
} else if (haveBaroAlt) {
|
} else if (haveBaroAlt && (positionConfig()->altSource == BARO_ONLY || positionConfig()->altSource == DEFAULT)) {
|
||||||
estimatedAltitudeCm = baroAlt;
|
estimatedAltitudeCm = baroAlt;
|
||||||
#ifdef USE_VARIO
|
#ifdef USE_VARIO
|
||||||
estimatedVario = calculateEstimatedVario(baroAlt, dTime);
|
estimatedVario = calculateEstimatedVario(baroAlt, dTime);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue