mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Simplified leading symbol logic and change setting to default to ON
This commit is contained in:
parent
865515113e
commit
2e9e99ff42
3 changed files with 8 additions and 9 deletions
|
@ -302,7 +302,7 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
||||||
osdConfig->profile[i][0] = '\0';
|
osdConfig->profile[i][0] = '\0';
|
||||||
}
|
}
|
||||||
osdConfig->rssi_dbm_alarm = 60;
|
osdConfig->rssi_dbm_alarm = 60;
|
||||||
osdConfig->dynamic_distance_units = false;
|
osdConfig->dynamic_distance_units = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void osdDrawLogo(int x, int y)
|
static void osdDrawLogo(int x, int y)
|
||||||
|
|
|
@ -240,17 +240,15 @@ static void osdFormatCoordinate(char *buff, char sym, int32_t val)
|
||||||
}
|
}
|
||||||
#endif // USE_GPS
|
#endif // USE_GPS
|
||||||
|
|
||||||
void osdFormatDistanceString(char *result, int distance, char leadingSymbol)
|
void osdFormatDistanceString(char *ptr, int distance, char leadingSymbol)
|
||||||
{
|
{
|
||||||
const int convertedDistance = osdGetMetersToSelectedUnit(distance);
|
const int convertedDistance = osdGetMetersToSelectedUnit(distance);
|
||||||
char unitSymbol;
|
char unitSymbol;
|
||||||
char unitSymbolExtended;
|
char unitSymbolExtended;
|
||||||
int unitTransition;
|
int unitTransition;
|
||||||
char buff[10];
|
|
||||||
|
|
||||||
result[0] = leadingSymbol;
|
|
||||||
if (leadingSymbol != SYM_NONE) {
|
if (leadingSymbol != SYM_NONE) {
|
||||||
result[1] = 0;
|
*ptr++ = leadingSymbol;
|
||||||
}
|
}
|
||||||
switch (osdConfig()->units) {
|
switch (osdConfig()->units) {
|
||||||
case OSD_UNIT_IMPERIAL:
|
case OSD_UNIT_IMPERIAL:
|
||||||
|
@ -266,16 +264,15 @@ void osdFormatDistanceString(char *result, int distance, char leadingSymbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (convertedDistance < unitTransition || !osdConfig()->dynamic_distance_units) {
|
if (convertedDistance < unitTransition || !osdConfig()->dynamic_distance_units) {
|
||||||
tfp_sprintf(buff, "%d%c", convertedDistance, unitSymbol);
|
tfp_sprintf(ptr, "%d%c", convertedDistance, unitSymbol);
|
||||||
} else {
|
} else {
|
||||||
const int displayDistance = convertedDistance * 100 / unitTransition;
|
const int displayDistance = convertedDistance * 100 / unitTransition;
|
||||||
if (displayDistance >= 1000) { // >= 10 miles or km - 1 decimal place
|
if (displayDistance >= 1000) { // >= 10 miles or km - 1 decimal place
|
||||||
tfp_sprintf(buff, "%d.%d%c", displayDistance / 100, (displayDistance / 10) % 10, unitSymbolExtended);
|
tfp_sprintf(ptr, "%d.%d%c", displayDistance / 100, (displayDistance / 10) % 10, unitSymbolExtended);
|
||||||
} else { // < 10 miles or km - 2 decimal places
|
} else { // < 10 miles or km - 2 decimal places
|
||||||
tfp_sprintf(buff, "%d.%02d%c", displayDistance / 100, displayDistance % 100, unitSymbolExtended);
|
tfp_sprintf(ptr, "%d.%02d%c", displayDistance / 100, displayDistance % 100, unitSymbolExtended);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strcat(result, buff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void osdFormatPID(char * buff, const char * label, const pidf_t * pid)
|
static void osdFormatPID(char * buff, const char * label, const pidf_t * pid)
|
||||||
|
|
|
@ -328,6 +328,7 @@ TEST(OsdTest, TestStatsImperial)
|
||||||
// and
|
// and
|
||||||
// using imperial unit system
|
// using imperial unit system
|
||||||
osdConfigMutable()->units = OSD_UNIT_IMPERIAL;
|
osdConfigMutable()->units = OSD_UNIT_IMPERIAL;
|
||||||
|
osdConfigMutable()->dynamic_distance_units = false;
|
||||||
|
|
||||||
// and
|
// and
|
||||||
// this timer 1 configuration
|
// this timer 1 configuration
|
||||||
|
@ -414,6 +415,7 @@ TEST(OsdTest, TestStatsMetric)
|
||||||
// given
|
// given
|
||||||
// using metric unit system
|
// using metric unit system
|
||||||
osdConfigMutable()->units = OSD_UNIT_METRIC;
|
osdConfigMutable()->units = OSD_UNIT_METRIC;
|
||||||
|
osdConfigMutable()->dynamic_distance_units = false;
|
||||||
|
|
||||||
// set timer 1 configuration to tenths precision
|
// set timer 1 configuration to tenths precision
|
||||||
osdConfigMutable()->timers[OSD_TIMER_1] = OSD_TIMER(OSD_TIMER_SRC_TOTAL_ARMED, OSD_TIMER_PREC_TENTHS, 0);
|
osdConfigMutable()->timers[OSD_TIMER_1] = OSD_TIMER(OSD_TIMER_SRC_TOTAL_ARMED, OSD_TIMER_PREC_TENTHS, 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue