diff --git a/src/main/telemetry/hott.c b/src/main/telemetry/hott.c index c918edae6..4e600b367 100644 --- a/src/main/telemetry/hott.c +++ b/src/main/telemetry/hott.c @@ -64,6 +64,7 @@ #include "build/debug.h" #include "common/axis.h" +#include "common/time.h" #include "drivers/system.h" @@ -73,6 +74,7 @@ #include "sensors/sensors.h" #include "sensors/battery.h" +#include "sensors/barometer.h" #include "flight/pid.h" #include "flight/navigation.h" @@ -201,7 +203,12 @@ void hottPrepareGPSResponse(HOTT_GPS_MSG_t *hottGPSMessage) hottGPSMessage->home_distance_L = GPS_distanceToHome & 0x00FF; hottGPSMessage->home_distance_H = GPS_distanceToHome >> 8; - const uint16_t hottGpsAltitude = (GPS_altitude) + HOTT_GPS_ALTITUDE_OFFSET; // GPS_altitude in m ; offset = 500 -> O m + uint16_t altitude = GPS_altitude; + if (!STATE(GPS_FIX)) { + altitude = baro.BaroAlt / 100; + } + + const uint16_t hottGpsAltitude = (altitude) + HOTT_GPS_ALTITUDE_OFFSET; // GPS_altitude in m ; offset = 500 -> O m hottGPSMessage->altitude_L = hottGpsAltitude & 0x00FF; hottGPSMessage->altitude_H = hottGpsAltitude >> 8; diff --git a/src/test/unit/telemetry_hott_unittest.cc b/src/test/unit/telemetry_hott_unittest.cc index 68505e972..62d4be0b1 100644 --- a/src/test/unit/telemetry_hott_unittest.cc +++ b/src/test/unit/telemetry_hott_unittest.cc @@ -33,6 +33,7 @@ extern "C" { #include "sensors/sensors.h" #include "sensors/battery.h" + #include "sensors/barometer.h" #include "io/serial.h" #include "io/gps.h" @@ -172,6 +173,8 @@ int32_t mAhDrawn; uint32_t fixedMillis = 0; +baro_t baro; + uint32_t millis(void) { return fixedMillis; }