From 9edce2359a62cd56fa9787114df84868b7436843 Mon Sep 17 00:00:00 2001 From: etracer65 Date: Sat, 24 Mar 2018 20:56:25 -0400 Subject: [PATCH] Add current battery voltage as an option for the OSD stats page (#5531) Allows the user to configure a new OSD stat item called "BATTERY" that will display a live and updating battery voltage. This would allow the user to see how their battery was recovering after disarming by comparing to the stat "END BATTERY". --- src/main/interface/settings.c | 1 + src/main/io/osd.c | 6 ++++++ src/main/io/osd.h | 1 + 3 files changed, 8 insertions(+) diff --git a/src/main/interface/settings.c b/src/main/interface/settings.c index cafc278074..aedddf6572 100644 --- a/src/main/interface/settings.c +++ b/src/main/interface/settings.c @@ -856,6 +856,7 @@ const clivalue_t valueTable[] = { { "osd_stat_max_alt", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats[OSD_STAT_MAX_ALTITUDE])}, { "osd_stat_bbox", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats[OSD_STAT_BLACKBOX])}, { "osd_stat_endbatt", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats[OSD_STAT_END_BATTERY])}, + { "osd_stat_battery", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats[OSD_STAT_BATTERY])}, { "osd_stat_bb_no", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats[OSD_STAT_BLACKBOX_NUMBER])}, { "osd_stat_rtc_date_time", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats[OSD_STAT_RTC_DATE_TIME])}, { "osd_stat_tim_1", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats[OSD_STAT_TIMER_1])}, diff --git a/src/main/io/osd.c b/src/main/io/osd.c index d9ed8b6dc7..aa8127258d 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -885,6 +885,7 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig) osdConfig->enabled_stats[OSD_STAT_TIMER_1] = false; osdConfig->enabled_stats[OSD_STAT_TIMER_2] = true; osdConfig->enabled_stats[OSD_STAT_RTC_DATE_TIME] = false; + osdConfig->enabled_stats[OSD_STAT_BATTERY] = false; osdConfig->units = OSD_UNIT_METRIC; @@ -1187,6 +1188,11 @@ static void osdShowStats(uint16_t endBatteryVoltage) osdDisplayStatisticLabel(top++, "END BATTERY", buff); } + if (osdConfig()->enabled_stats[OSD_STAT_BATTERY]) { + tfp_sprintf(buff, "%d.%1d%c", getBatteryVoltage() / 10, getBatteryVoltage() % 10, SYM_VOLT); + osdDisplayStatisticLabel(top++, "BATTERY", buff); + } + if (osdConfig()->enabled_stats[OSD_STAT_MIN_RSSI]) { itoa(stats.min_rssi, buff, 10); strcat(buff, "%"); diff --git a/src/main/io/osd.h b/src/main/io/osd.h index 2dd18130d4..8661602f9c 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -103,6 +103,7 @@ typedef enum { 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;