From 7be17752532782acc73029204f4ed6384acdf81d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Spychalski?= Date: Fri, 26 May 2023 08:47:28 +0200 Subject: [PATCH] Merge pull request #9076 from iNavFlight/MrD_Fix-for-the-DJI-OSD-Imperial-altitude-hack Fix bug for DJI O3's altitude when using imperial --- src/main/io/osd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 5e4879a603d..3fa9694576b 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -532,6 +532,7 @@ static void osdFormatWindSpeedStr(char *buff, int32_t ws, bool isValid) */ void osdFormatAltitudeSymbol(char *buff, int32_t alt) { + uint8_t totalDigits = 4U; uint8_t digits = 4U; uint8_t symbolIndex = 4U; uint8_t symbolKFt = SYM_ALT_KFT; @@ -543,6 +544,7 @@ void osdFormatAltitudeSymbol(char *buff, int32_t alt) #ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it and change the values if (isBfCompatibleVideoSystem(osdConfig())) { + totalDigits++; digits++; symbolIndex++; symbolKFt = SYM_ALT_FT; @@ -555,7 +557,7 @@ void osdFormatAltitudeSymbol(char *buff, int32_t alt) case OSD_UNIT_GA: FALLTHROUGH; case OSD_UNIT_IMPERIAL: - if (osdFormatCentiNumber(buff + 4 - digits, CENTIMETERS_TO_CENTIFEET(alt), 1000, 0, 2, digits)) { + if (osdFormatCentiNumber(buff + totalDigits - digits, CENTIMETERS_TO_CENTIFEET(alt), 1000, 0, 2, digits)) { // Scaled to kft buff[symbolIndex++] = symbolKFt; } else { @@ -568,7 +570,7 @@ void osdFormatAltitudeSymbol(char *buff, int32_t alt) FALLTHROUGH; case OSD_UNIT_METRIC: // alt is alredy in cm - if (osdFormatCentiNumber(buff + 4 - digits, alt, 1000, 0, 2, digits)) { + if (osdFormatCentiNumber(buff + totalDigits - digits, alt, 1000, 0, 2, digits)) { // Scaled to km buff[symbolIndex++] = SYM_ALT_KM; } else {