Remove settings parameter; update to use the new kilometer and miles symbols

This commit is contained in:
Bruce Luckcuck 2019-06-27 10:14:14 -04:00
parent 2e9e99ff42
commit b962416333
6 changed files with 5 additions and 11 deletions

View File

@ -1130,7 +1130,6 @@ const clivalue_t valueTable[] = {
// PG_OSD_CONFIG // PG_OSD_CONFIG
#ifdef USE_OSD #ifdef USE_OSD
{ "osd_units", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_UNIT }, PG_OSD_CONFIG, offsetof(osdConfig_t, units) }, { "osd_units", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_UNIT }, PG_OSD_CONFIG, offsetof(osdConfig_t, units) },
{ "osd_dynamic_distance_units", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, dynamic_distance_units) },
// Please try to keep the OSD warnings in the same order as presented in the Configurator. // Please try to keep the OSD warnings in the same order as presented in the Configurator.
// This makes it easier for the user to relate the CLI output as warnings are in the same relative // This makes it easier for the user to relate the CLI output as warnings are in the same relative

View File

@ -48,12 +48,12 @@
// Unit Icons (Metric) // Unit Icons (Metric)
#define SYM_M 0x0C #define SYM_M 0x0C
#define SYM_KM 0x4B // 'K' #define SYM_KM 0x7D
#define SYM_C 0x0E #define SYM_C 0x0E
// Unit Icons (Imperial) // Unit Icons (Imperial)
#define SYM_FT 0x0F #define SYM_FT 0x0F
#define SYM_MILES 0x4D // 'M' #define SYM_MILES 0x7E
#define SYM_F 0x0D #define SYM_F 0x0D
// Heading Graphics // Heading Graphics

View File

@ -302,7 +302,6 @@ 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 = true;
} }
static void osdDrawLogo(int x, int y) static void osdDrawLogo(int x, int y)
@ -710,9 +709,9 @@ static bool osdDisplayStat(int statistic, uint8_t displayRow)
#define METERS_PER_KILOMETER 1000 #define METERS_PER_KILOMETER 1000
#define METERS_PER_MILE 1609 #define METERS_PER_MILE 1609
if (osdConfig()->units == OSD_UNIT_IMPERIAL) { if (osdConfig()->units == OSD_UNIT_IMPERIAL) {
tfp_sprintf(buff, "%dMI", statsConfig()->stats_total_dist_m / METERS_PER_MILE); tfp_sprintf(buff, "%d%c", statsConfig()->stats_total_dist_m / METERS_PER_MILE, SYM_MILES);
} else { } else {
tfp_sprintf(buff, "%dKM", statsConfig()->stats_total_dist_m / METERS_PER_KILOMETER); tfp_sprintf(buff, "%d%c", statsConfig()->stats_total_dist_m / METERS_PER_KILOMETER, SYM_KM);
} }
osdDisplayStatisticLabel(displayRow, "TOTAL DISTANCE", buff); osdDisplayStatisticLabel(displayRow, "TOTAL DISTANCE", buff);
return true; return true;

View File

@ -257,7 +257,6 @@ typedef struct osdConfig_s {
char profile[OSD_PROFILE_COUNT][OSD_PROFILE_NAME_LENGTH + 1]; char profile[OSD_PROFILE_COUNT][OSD_PROFILE_NAME_LENGTH + 1];
uint16_t link_quality_alarm; uint16_t link_quality_alarm;
uint8_t rssi_dbm_alarm; uint8_t rssi_dbm_alarm;
uint8_t dynamic_distance_units; // Whether to change from meters to km or ft to miles automatically
} osdConfig_t; } osdConfig_t;
PG_DECLARE(osdConfig_t, osdConfig); PG_DECLARE(osdConfig_t, osdConfig);

View File

@ -263,7 +263,7 @@ void osdFormatDistanceString(char *ptr, int distance, char leadingSymbol)
break; break;
} }
if (convertedDistance < unitTransition || !osdConfig()->dynamic_distance_units) { if (convertedDistance < unitTransition) {
tfp_sprintf(ptr, "%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;

View File

@ -328,7 +328,6 @@ 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
@ -415,7 +414,6 @@ 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);
@ -472,7 +470,6 @@ TEST(OsdTest, TestStatsMetricDistanceUnits)
// given // given
// using metric unit system // using metric unit system
osdConfigMutable()->units = OSD_UNIT_METRIC; osdConfigMutable()->units = OSD_UNIT_METRIC;
osdConfigMutable()->dynamic_distance_units = true;
// 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);