Skip to content

Commit

Permalink
Remove settings parameter; update to use the new kilometer and miles …
Browse files Browse the repository at this point in the history
…symbols
  • Loading branch information
etracer65 committed Jun 27, 2019
1 parent 2e9e99f commit b962416
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/main/cli/settings.c
Expand Up @@ -1130,7 +1130,6 @@ const clivalue_t valueTable[] = {
// PG_OSD_CONFIG
#ifdef USE_OSD
{ "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.
// This makes it easier for the user to relate the CLI output as warnings are in the same relative
Expand Down
4 changes: 2 additions & 2 deletions src/main/drivers/max7456_symbols.h
Expand Up @@ -48,12 +48,12 @@

// Unit Icons (Metric)
#define SYM_M 0x0C
#define SYM_KM 0x4B // 'K'
#define SYM_KM 0x7D
#define SYM_C 0x0E

// Unit Icons (Imperial)
#define SYM_FT 0x0F
#define SYM_MILES 0x4D // 'M'
#define SYM_MILES 0x7E
#define SYM_F 0x0D

// Heading Graphics
Expand Down
5 changes: 2 additions & 3 deletions src/main/osd/osd.c
Expand Up @@ -302,7 +302,6 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
osdConfig->profile[i][0] = '\0';
}
osdConfig->rssi_dbm_alarm = 60;
osdConfig->dynamic_distance_units = true;
}

static void osdDrawLogo(int x, int y)
Expand Down Expand Up @@ -710,9 +709,9 @@ static bool osdDisplayStat(int statistic, uint8_t displayRow)
#define METERS_PER_KILOMETER 1000
#define METERS_PER_MILE 1609
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 {
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);
return true;
Expand Down
1 change: 0 additions & 1 deletion src/main/osd/osd.h
Expand Up @@ -257,7 +257,6 @@ typedef struct osdConfig_s {
char profile[OSD_PROFILE_COUNT][OSD_PROFILE_NAME_LENGTH + 1];
uint16_t link_quality_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;

PG_DECLARE(osdConfig_t, osdConfig);
Expand Down
2 changes: 1 addition & 1 deletion src/main/osd/osd_elements.c
Expand Up @@ -263,7 +263,7 @@ void osdFormatDistanceString(char *ptr, int distance, char leadingSymbol)
break;
}

if (convertedDistance < unitTransition || !osdConfig()->dynamic_distance_units) {
if (convertedDistance < unitTransition) {
tfp_sprintf(ptr, "%d%c", convertedDistance, unitSymbol);
} else {
const int displayDistance = convertedDistance * 100 / unitTransition;
Expand Down
3 changes: 0 additions & 3 deletions src/test/unit/osd_unittest.cc
Expand Up @@ -328,7 +328,6 @@ TEST(OsdTest, TestStatsImperial)
// and
// using imperial unit system
osdConfigMutable()->units = OSD_UNIT_IMPERIAL;
osdConfigMutable()->dynamic_distance_units = false;

// and
// this timer 1 configuration
Expand Down Expand Up @@ -415,7 +414,6 @@ TEST(OsdTest, TestStatsMetric)
// given
// using metric unit system
osdConfigMutable()->units = OSD_UNIT_METRIC;
osdConfigMutable()->dynamic_distance_units = false;

// set timer 1 configuration to tenths precision
osdConfigMutable()->timers[OSD_TIMER_1] = OSD_TIMER(OSD_TIMER_SRC_TOTAL_ARMED, OSD_TIMER_PREC_TENTHS, 0);
Expand Down Expand Up @@ -472,7 +470,6 @@ TEST(OsdTest, TestStatsMetricDistanceUnits)
// given
// using metric unit system
osdConfigMutable()->units = OSD_UNIT_METRIC;
osdConfigMutable()->dynamic_distance_units = true;

// set timer 1 configuration to tenths precision
osdConfigMutable()->timers[OSD_TIMER_1] = OSD_TIMER(OSD_TIMER_SRC_TOTAL_ARMED, OSD_TIMER_PREC_TENTHS, 0);
Expand Down

0 comments on commit b962416

Please sign in to comment.