Skip to content

Commit

Permalink
Merge pull request #9076 from iNavFlight/MrD_Fix-for-the-DJI-OSD-Impe…
Browse files Browse the repository at this point in the history
…rial-altitude-hack

Fix bug for DJI O3's altitude when using imperial
  • Loading branch information
DzikuVx authored and MrD-RC committed Jun 8, 2023
1 parent d6ce6e7 commit 99348e5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/io/osd.c
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 99348e5

Please sign in to comment.