diff --git a/src/main/interface/settings.c b/src/main/interface/settings.c index 95c45a2b85..69ab23108b 100644 --- a/src/main/interface/settings.c +++ b/src/main/interface/settings.c @@ -867,20 +867,21 @@ const clivalue_t valueTable[] = { { "osd_core_temp_pos", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_CORE_TEMPERATURE]) }, // OSD stats enabled flags are stored as bitmapped values inside a 32bit parameter + // It is recommended to keep the settings order the same as the enumeration. This way the settings are displayed in the cli in the same order making it easier on the users + { "osd_stat_rtc_date_time", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_RTC_DATE_TIME, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, + { "osd_stat_tim_1", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_TIMER_1, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, + { "osd_stat_tim_2", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_TIMER_2, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, { "osd_stat_max_spd", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_MAX_SPEED, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, { "osd_stat_max_dist", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_MAX_DISTANCE, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, { "osd_stat_min_batt", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_MIN_BATTERY, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, + { "osd_stat_endbatt", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_END_BATTERY, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, + { "osd_stat_battery", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_BATTERY, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, { "osd_stat_min_rssi", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_MIN_RSSI, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, { "osd_stat_max_curr", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_MAX_CURRENT, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, { "osd_stat_used_mah", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_USED_MAH, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, { "osd_stat_max_alt", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_MAX_ALTITUDE, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, { "osd_stat_bbox", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_BLACKBOX, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, - { "osd_stat_endbatt", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_END_BATTERY, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, - { "osd_stat_battery", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_BATTERY, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, { "osd_stat_bb_no", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_BLACKBOX_NUMBER, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, - { "osd_stat_rtc_date_time", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_RTC_DATE_TIME, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, - { "osd_stat_tim_1", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_TIMER_1, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, - { "osd_stat_tim_2", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_TIMER_2, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, #endif diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 1f13c9cf6b..fd42c90211 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -1249,6 +1249,14 @@ static bool isSomeStatEnabled(void) return (osdConfig()->enabled_stats != 0); } +// *** IMPORTANT *** +// The order of the OSD stats as displayed on-screen must match the osd_stats_e enumeration. +// This is because the fields are presented in the configurator in the order of the enumeration +// and we want the configuration order to match the on-screen display order. If you change the +// display order you *must* update the osd_stats_e enumeration to match. Additionally the +// changes to the stats display order *must* be implemented in the configurator otherwise the +// stats selections will not be populated correctly and the settings will become corrupted. + static void osdShowStats(uint16_t endBatteryVoltage) { uint8_t top = 2; diff --git a/src/main/io/osd.h b/src/main/io/osd.h index e34cbc78c9..eae57aa4f5 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -95,21 +95,30 @@ typedef enum { OSD_ITEM_COUNT // MUST BE LAST } osd_items_e; +// *** IMPORTANT *** +// The order of the OSD stats enumeration *must* match the order they're displayed on-screen +// This is because the fields are presented in the configurator in the order of the enumeration +// and we want the configuration order to match the on-screen display order. +// Changes to the stats display order *must* be implemented in the configurator otherwise the +// stats selections will not be populated correctly and the settings will become corrupted. +// +// Also - if the stats are reordered then the PR version must be incremented. Otherwise there +// is no indication that the stored config must be reset and the bitmapped values will be incorrect. typedef enum { + OSD_STAT_RTC_DATE_TIME, + OSD_STAT_TIMER_1, + OSD_STAT_TIMER_2, OSD_STAT_MAX_SPEED, + OSD_STAT_MAX_DISTANCE, OSD_STAT_MIN_BATTERY, + OSD_STAT_END_BATTERY, + OSD_STAT_BATTERY, OSD_STAT_MIN_RSSI, OSD_STAT_MAX_CURRENT, OSD_STAT_USED_MAH, OSD_STAT_MAX_ALTITUDE, OSD_STAT_BLACKBOX, - OSD_STAT_END_BATTERY, - OSD_STAT_TIMER_1, - OSD_STAT_TIMER_2, - OSD_STAT_MAX_DISTANCE, OSD_STAT_BLACKBOX_NUMBER, - OSD_STAT_RTC_DATE_TIME, - OSD_STAT_BATTERY, OSD_STAT_COUNT // MUST BE LAST } osd_stats_e;