mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-20 23:05:19 +03:00
Merge pull request #6031 from mikeller/fix_osd_altitude_display
Fixed OSD altitude display for negative altitude > -1.
This commit is contained in:
commit
522e90ab17
2 changed files with 20 additions and 13 deletions
|
@ -270,14 +270,13 @@ static char osdGetTemperatureSymbolForSelectedUnit(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void osdFormatAltitudeString(char * buff, int altitude, bool pad)
|
static void osdFormatAltitudeString(char * buff, int altitude)
|
||||||
{
|
{
|
||||||
const int alt = osdGetMetersToSelectedUnit(altitude);
|
const int alt = osdGetMetersToSelectedUnit(altitude) / 10;
|
||||||
int altitudeIntergerPart = abs(alt / 100);
|
|
||||||
if (alt < 0) {
|
tfp_sprintf(buff, "%5d %c", alt, osdGetMetersToSelectedUnitSymbol());
|
||||||
altitudeIntergerPart *= -1;
|
buff[5] = buff[4];
|
||||||
}
|
buff[4] = '.';
|
||||||
tfp_sprintf(buff, pad ? "%4d.%01d%c" : "%d.%01d%c", altitudeIntergerPart, abs((alt % 100) / 10), osdGetMetersToSelectedUnitSymbol());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void osdFormatPID(char * buff, const char * label, const pid8_t * pid)
|
static void osdFormatPID(char * buff, const char * label, const pid8_t * pid)
|
||||||
|
@ -551,7 +550,7 @@ static bool osdDrawSingleElement(uint8_t item)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OSD_ALTITUDE:
|
case OSD_ALTITUDE:
|
||||||
osdFormatAltitudeString(buff, getEstimatedAltitude(), true);
|
osdFormatAltitudeString(buff, getEstimatedAltitude());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OSD_ITEM_TIMER_1:
|
case OSD_ITEM_TIMER_1:
|
||||||
|
@ -1370,7 +1369,7 @@ static void osdShowStats(uint16_t endBatteryVoltage)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (osdStatGetState(OSD_STAT_MAX_ALTITUDE)) {
|
if (osdStatGetState(OSD_STAT_MAX_ALTITUDE)) {
|
||||||
osdFormatAltitudeString(buff, stats.max_altitude, false);
|
osdFormatAltitudeString(buff, stats.max_altitude);
|
||||||
osdDisplayStatisticLabel(top++, "MAX ALTITUDE", buff);
|
osdDisplayStatisticLabel(top++, "MAX ALTITUDE", buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -486,7 +486,7 @@ TEST(OsdTest, TestAlarms)
|
||||||
displayPortTestBufferSubstring(12, 1, "%c16.8%c", SYM_BATT_FULL, SYM_VOLT);
|
displayPortTestBufferSubstring(12, 1, "%c16.8%c", SYM_BATT_FULL, SYM_VOLT);
|
||||||
displayPortTestBufferSubstring(1, 1, "%c00:", SYM_FLY_M); // only test the minute part of the timer
|
displayPortTestBufferSubstring(1, 1, "%c00:", SYM_FLY_M); // only test the minute part of the timer
|
||||||
displayPortTestBufferSubstring(20, 1, "%c01:", SYM_ON_M); // only test the minute part of the timer
|
displayPortTestBufferSubstring(20, 1, "%c01:", SYM_ON_M); // only test the minute part of the timer
|
||||||
displayPortTestBufferSubstring(23, 7, " 0.0%c", SYM_M);
|
displayPortTestBufferSubstring(23, 7, " .0%c", SYM_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
@ -717,7 +717,7 @@ TEST(OsdTest, TestElementAltitude)
|
||||||
osdRefresh(simulationTime);
|
osdRefresh(simulationTime);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
displayPortTestBufferSubstring(23, 7, " 0.0%c", SYM_M);
|
displayPortTestBufferSubstring(23, 7, " .0%c", SYM_M);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
simulationAltitude = 247;
|
simulationAltitude = 247;
|
||||||
|
@ -742,6 +742,14 @@ TEST(OsdTest, TestElementAltitude)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
displayPortTestBufferSubstring(23, 7, " -2.4%c", SYM_M);
|
displayPortTestBufferSubstring(23, 7, " -2.4%c", SYM_M);
|
||||||
|
|
||||||
|
// when
|
||||||
|
simulationAltitude = -70;
|
||||||
|
displayClearScreen(&testDisplayPort);
|
||||||
|
osdRefresh(simulationTime);
|
||||||
|
|
||||||
|
// then
|
||||||
|
displayPortTestBufferSubstring(23, 7, " -.7%c", SYM_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue