Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
| osd_sidebar_scroll_arrows | | |
| osd_snr_alarm | 4 | Value below which Crossfire SNR Alarm pops-up. (dB) |
| osd_stats_energy_unit | MAH | Unit used for the drawn energy in the OSD stats [MAH/WH] (milliAmpere hour/ Watt hour) |
| osd_stats_min_voltage_unit | BATTERY | Display minimum voltage of the whole `BATTERY` or the average per `CELL` in the OSD stats. |
| osd_temp_label_align | LEFT | Allows to chose between left and right alignment for the OSD temperature sensor labels. Valid values are `LEFT` and `RIGHT` |
| osd_time_alarm | 10 | Value above which to make the OSD flight time indicator blink (minutes) |
| osd_units | METRIC | IMPERIAL, METRIC, UK |
Expand Down
9 changes: 9 additions & 0 deletions src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ tables:
- name: osd_stats_energy_unit
values: ["MAH", "WH"]
enum: osd_stats_energy_unit_e
- name: osd_stats_min_voltage_unit
values: ["BATTERY", "CELL"]
enum: osd_stats_min_voltage_unit_e
- name: osd_video_system
values: ["AUTO", "PAL", "NTSC"]
enum: videoSystem_e
Expand Down Expand Up @@ -2695,6 +2698,12 @@ groups:
field: stats_energy_unit
table: osd_stats_energy_unit
type: uint8_t
- name: osd_stats_min_voltage_unit
description: "Display minimum voltage of the whole `BATTERY` or the average per `CELL` in the OSD stats."
default_value: "BATTERY"
field: stats_min_voltage_unit
table: osd_stats_min_voltage_unit
type: uint8_t

- name: osd_rssi_alarm
description: "Value below which to make the OSD RSSI indicator blink"
Expand Down
57 changes: 41 additions & 16 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static bool osdDisplayHasCanvas;

#define AH_MAX_PITCH_DEFAULT 20 // Specify default maximum AHI pitch value displayed (degrees)

PG_REGISTER_WITH_RESET_TEMPLATE(osdConfig_t, osdConfig, PG_OSD_CONFIG, 14);
PG_REGISTER_WITH_RESET_TEMPLATE(osdConfig_t, osdConfig, PG_OSD_CONFIG, 15);
PG_REGISTER_WITH_RESET_FN(osdLayoutsConfig_t, osdLayoutsConfig, PG_OSD_LAYOUTS_CONFIG, 0);

static int digitCount(int32_t value)
Expand Down Expand Up @@ -2938,7 +2938,7 @@ static void osdShowStats(void)
const char * disarmReasonStr[DISARM_REASON_COUNT] = { "UNKNOWN", "TIMEOUT", "STICKS", "SWITCH", "SWITCH", "KILLSW", "FAILSAFE", "NAV SYS" };
uint8_t top = 1; /* first fully visible line */
const uint8_t statNameX = 1;
const uint8_t statValuesX = 20;
const uint8_t statValuesX = 19;
char buff[10];

displayBeginTransaction(osdDisplayPort, DISPLAY_TRANSACTION_OPT_RESET_DRAWING);
Expand All @@ -2965,27 +2965,52 @@ static void osdShowStats(void)
osdFormatAltitudeStr(buff, stats.max_altitude);
displayWrite(osdDisplayPort, statValuesX, top++, buff);

displayWrite(osdDisplayPort, statNameX, top, "MIN BATTERY VOLT :");
osdFormatCentiNumber(buff, stats.min_voltage, 0, osdConfig()->main_voltage_decimals, 0, osdConfig()->main_voltage_decimals + 2);
strcat(buff, "V");
osdLeftAlignString(buff);
displayWrite(osdDisplayPort, statValuesX, top++, buff);

if (osdConfig()->stats_min_voltage_unit == OSD_STATS_MIN_VOLTAGE_UNIT_BATTERY){
displayWrite(osdDisplayPort, statNameX, top, "MIN BATTERY VOLT :");
osdFormatCentiNumber(buff, stats.min_voltage, 0, osdConfig()->main_voltage_decimals, 0, osdConfig()->main_voltage_decimals + 2);
strcat(buff, "V(");
osdLeftAlignString(buff);
int8_t lengthValues = strlen(buff);
displayWrite(osdDisplayPort, statValuesX, top, buff);
osdFormatCentiNumber(buff, getBatteryRawVoltage(), 0, osdConfig()->main_voltage_decimals, 0, osdConfig()->main_voltage_decimals + 2);
strcat(buff, "V)");
osdLeftAlignString(buff);
displayWrite(osdDisplayPort, statValuesX + lengthValues, top++, buff);
} else {
displayWrite(osdDisplayPort, statNameX, top, "MIN CELL VOLT :");
osdFormatCentiNumber(buff, stats.min_voltage / getBatteryCellCount(), 0, 2, 0, 3);
strcat(buff, "V(");
osdLeftAlignString(buff);
int8_t lengthValues = strlen(buff);
displayWrite(osdDisplayPort, statValuesX, top, buff);
osdFormatCentiNumber(buff, getBatteryRawAverageCellVoltage(), 0, 2, 0, 3);
strcat(buff, "V)");
osdLeftAlignString(buff);
displayWrite(osdDisplayPort, statValuesX + lengthValues, top++, buff);
}

displayWrite(osdDisplayPort, statNameX, top, "MIN RSSI :");
itoa(stats.min_rssi, buff, 10);
strcat(buff, "%");
displayWrite(osdDisplayPort, statValuesX, top++, buff);

if (feature(FEATURE_CURRENT_METER)) {
displayWrite(osdDisplayPort, statNameX, top, "MAX CURRENT :");
itoa(stats.max_current, buff, 10);
strcat(buff, "A");
displayWrite(osdDisplayPort, statValuesX, top++, buff);

displayWrite(osdDisplayPort, statNameX, top, "MAX POWER :");
itoa(stats.max_power, buff, 10);
displayWrite(osdDisplayPort, statNameX, top, "MAX CURRENT/POWER:");
int8_t currentDigits = 1;
if (stats.max_current >= 100){
currentDigits = 3;
} else if (stats.max_current >= 10){
currentDigits = 2;
}
osdFormatCentiNumber(buff, stats.max_current * 100, 0, 0, 0, currentDigits);
strcat(buff, "A/");
osdLeftAlignString(buff);
int8_t lengthValues = strlen(buff);
displayWrite(osdDisplayPort, statValuesX, top, buff);
osdFormatCentiNumber(buff, stats.max_power * 100, 0, 0, 0, 4);
strcat(buff, "W");
displayWrite(osdDisplayPort, statValuesX, top++, buff);
osdLeftAlignString(buff);
displayWrite(osdDisplayPort, statValuesX + lengthValues, top++, buff);

if (osdConfig()->stats_energy_unit == OSD_STATS_ENERGY_UNIT_MAH) {
displayWrite(osdDisplayPort, statNameX, top, "USED MAH :");
Expand Down
7 changes: 7 additions & 0 deletions src/main/io/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ typedef enum {
OSD_STATS_ENERGY_UNIT_WH,
} osd_stats_energy_unit_e;

typedef enum {
OSD_STATS_MIN_VOLTAGE_UNIT_BATTERY,
OSD_STATS_MIN_VOLTAGE_UNIT_CELL,
} osd_stats_min_voltage_unit_e;

typedef enum {
OSD_CROSSHAIRS_STYLE_DEFAULT,
OSD_CROSSHAIRS_STYLE_AIRCRAFT,
Expand Down Expand Up @@ -308,6 +313,7 @@ typedef struct osdConfig_s {

// Preferences
uint8_t main_voltage_decimals;

uint8_t ahi_reverse_roll;
uint8_t ahi_max_pitch;
uint8_t crosshairs_style; // from osd_crosshairs_style_e
Expand All @@ -331,6 +337,7 @@ typedef struct osdConfig_s {

uint8_t units; // from osd_unit_e
uint8_t stats_energy_unit; // from osd_stats_energy_unit_e
uint8_t stats_min_voltage_unit; // from osd_stats_min_voltage_unit_e

bool estimations_wind_compensation; // use wind compensation for estimated remaining flight/distance
uint8_t coordinate_digits;
Expand Down