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

GPS altitude: cleanup all occurancies to assume source is in cm per lsb resolution

Harmonized (and partly corrected) all occurancies of gpsSol.llh.alt and getEstimatedAltitude() to handle altiude sourced in cm resolution.
This was introduced by GSP_RESCUE/RTH.
Introduced a naming convention that include the unit into the variable/function names:
gpsSol.llh.alt -> gpsSol.llh.alt_cm
getEstimatedAltitude() -> getEstimatedAltitude_cm()
This commit is contained in:
AirBreak69 2018-06-24 12:52:22 +02:00 committed by mikeller
parent bbdd717505
commit 0e52e21524
23 changed files with 105 additions and 105 deletions

View file

@ -38,7 +38,7 @@
#include "sensors/sensors.h"
#include "sensors/barometer.h"
static int32_t estimatedAltitude = 0; // in cm
static int32_t estimatedAltitudeCm = 0; // in cm
#define BARO_UPDATE_FREQUENCY_40HZ (1000 * 25)
@ -77,7 +77,7 @@ void calculateEstimatedAltitude(timeUs_t currentTimeUs)
#ifdef USE_GPS
if (sensors(SENSOR_GPS) && STATE(GPS_FIX)) {
gpsAlt = gpsSol.llh.alt;
gpsAlt = gpsSol.llh.altCm;
haveGpsAlt = true;
if (gpsSol.hdop != 0) {
@ -99,11 +99,11 @@ if (sensors(SENSOR_GPS) && STATE(GPS_FIX)) {
gpsAlt -= gpsAltOffset;
if (haveGpsAlt && haveBaroAlt) {
estimatedAltitude = gpsAlt * gpsTrust + baroAlt * (1 - gpsTrust);
estimatedAltitudeCm = gpsAlt * gpsTrust + baroAlt * (1 - gpsTrust);
} else if (haveGpsAlt) {
estimatedAltitude = gpsAlt;
estimatedAltitudeCm = gpsAlt;
} else if (haveBaroAlt) {
estimatedAltitude = baroAlt;
estimatedAltitudeCm = baroAlt;
}
DEBUG_SET(DEBUG_ALTITUDE, 0, (int32_t)(100 * gpsTrust));
@ -117,9 +117,9 @@ bool isAltitudeOffset(void)
}
#endif
int32_t getEstimatedAltitude(void)
int32_t getEstimatedAltitudeCm(void)
{
return estimatedAltitude;
return estimatedAltitudeCm;
}
// This should be removed or fixed, but it would require changing a lot of other things to get rid of.