Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug for DJI O3's altitude when using imperial #9076

Merged
merged 1 commit into from
May 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
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