mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 05:15:25 +03:00
Fix OSD stats alignment and formatting
Fixes the alignment and formatting of the following stats: * Max altitude * Max speed * Max ESC temperature
This commit is contained in:
parent
8984a7195f
commit
138f403204
5 changed files with 52 additions and 33 deletions
|
@ -206,6 +206,15 @@ int osdConvertTemperatureToSelectedUnit(int tempInDegreesCelcius)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void osdFormatAltitudeString(char * buff, int32_t altitudeCm)
|
||||
{
|
||||
const int alt = osdGetMetersToSelectedUnit(altitudeCm) / 10;
|
||||
|
||||
tfp_sprintf(buff, "%5d %c", alt, osdGetMetersToSelectedUnitSymbol());
|
||||
buff[5] = buff[4];
|
||||
buff[4] = '.';
|
||||
}
|
||||
|
||||
#ifdef USE_GPS
|
||||
static void osdFormatCoordinate(char *buff, char sym, int32_t val)
|
||||
{
|
||||
|
@ -386,6 +395,33 @@ char osdGetMetersToSelectedUnitSymbol(void)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts speed based on the current unit system.
|
||||
* @param value in cm/s to convert
|
||||
*/
|
||||
int32_t osdGetSpeedToSelectedUnit(int32_t value)
|
||||
{
|
||||
switch (osdConfig()->units) {
|
||||
case OSD_UNIT_IMPERIAL:
|
||||
return CM_S_TO_MPH(value);
|
||||
default:
|
||||
return CM_S_TO_KM_H(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the correct speed symbol for the current unit system
|
||||
*/
|
||||
char osdGetSpeedToSelectedUnitSymbol(void)
|
||||
{
|
||||
switch (osdConfig()->units) {
|
||||
case OSD_UNIT_IMPERIAL:
|
||||
return SYM_MPH;
|
||||
default:
|
||||
return SYM_KPH;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(USE_ADC_INTERNAL) || defined(USE_ESC_SENSOR)
|
||||
char osdGetTemperatureSymbolForSelectedUnit(void)
|
||||
{
|
||||
|
@ -731,15 +767,7 @@ static void osdElementGpsSats(osdElementParms_t *element)
|
|||
|
||||
static void osdElementGpsSpeed(osdElementParms_t *element)
|
||||
{
|
||||
// FIXME ideally we want to use SYM_KMH symbol but it's not in the font any more, so we use K (M for MPH)
|
||||
switch (osdConfig()->units) {
|
||||
case OSD_UNIT_IMPERIAL:
|
||||
tfp_sprintf(element->buff, "%3dM", CM_S_TO_MPH(gpsSol.groundSpeed));
|
||||
break;
|
||||
default:
|
||||
tfp_sprintf(element->buff, "%3dK", CM_S_TO_KM_H(gpsSol.groundSpeed));
|
||||
break;
|
||||
}
|
||||
tfp_sprintf(element->buff, "%3d%c", osdGetSpeedToSelectedUnit(gpsSol.groundSpeed), osdGetSpeedToSelectedUnitSymbol());
|
||||
}
|
||||
#endif // USE_GPS
|
||||
|
||||
|
@ -1376,15 +1404,6 @@ const osdElementDrawFn osdElementDrawFunction[OSD_ITEM_COUNT] = {
|
|||
#endif
|
||||
};
|
||||
|
||||
void osdFormatAltitudeString(char * buff, int32_t altitudeCm)
|
||||
{
|
||||
const int alt = osdGetMetersToSelectedUnit(altitudeCm) / 10;
|
||||
|
||||
tfp_sprintf(buff, "%5d %c", alt, osdGetMetersToSelectedUnitSymbol());
|
||||
buff[5] = buff[4];
|
||||
buff[4] = '.';
|
||||
}
|
||||
|
||||
static void osdAddActiveElement(osd_items_e element)
|
||||
{
|
||||
if (VISIBLE(osdConfig()->item_pos[element])) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue