mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 16:55:36 +03:00
Fixed OSD altitude display for negative altitude > -1.
This commit is contained in:
parent
c1e88ae7f4
commit
e30f1fadd9
1 changed files with 5 additions and 9 deletions
|
@ -270,14 +270,10 @@ static char osdGetTemperatureSymbolForSelectedUnit(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void osdFormatAltitudeString(char * buff, int altitude, bool pad)
|
||||
static void osdFormatAltitudeString(char * buff, int altitude)
|
||||
{
|
||||
const int alt = osdGetMetersToSelectedUnit(altitude);
|
||||
int altitudeIntergerPart = abs(alt / 100);
|
||||
if (alt < 0) {
|
||||
altitudeIntergerPart *= -1;
|
||||
}
|
||||
tfp_sprintf(buff, pad ? "%4d.%01d%c" : "%d.%01d%c", altitudeIntergerPart, abs((alt % 100) / 10), osdGetMetersToSelectedUnitSymbol());
|
||||
const int alt = osdGetMetersToSelectedUnit(altitude) / 10;
|
||||
tfp_sprintf(buff, "%s%d.%01d%c", alt < 0 ? "-" : "", abs(alt / 10), abs(alt % 10), osdGetMetersToSelectedUnitSymbol());
|
||||
}
|
||||
|
||||
static void osdFormatPID(char * buff, const char * label, const pid8_t * pid)
|
||||
|
@ -551,7 +547,7 @@ static bool osdDrawSingleElement(uint8_t item)
|
|||
break;
|
||||
|
||||
case OSD_ALTITUDE:
|
||||
osdFormatAltitudeString(buff, getEstimatedAltitude(), true);
|
||||
osdFormatAltitudeString(buff, getEstimatedAltitude());
|
||||
break;
|
||||
|
||||
case OSD_ITEM_TIMER_1:
|
||||
|
@ -1370,7 +1366,7 @@ static void osdShowStats(uint16_t endBatteryVoltage)
|
|||
}
|
||||
|
||||
if (osdStatGetState(OSD_STAT_MAX_ALTITUDE)) {
|
||||
osdFormatAltitudeString(buff, stats.max_altitude, false);
|
||||
osdFormatAltitudeString(buff, stats.max_altitude);
|
||||
osdDisplayStatisticLabel(top++, "MAX ALTITUDE", buff);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue