Browse Source

Merge pull request #7868 from iNavFlight/MrD_Add-precision-to-mAh-used-for-9999mAh

Enhance mAh Used OSD Element
master
Paweł Spychalski 3 years ago
committed by GitHub
parent
commit
5ce41e508d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      docs/Settings.md
  2. 2
      src/main/drivers/osd_symbols.h
  3. 7
      src/main/fc/settings.yaml
  4. 16
      src/main/io/osd.c
  5. 1
      src/main/io/osd.h

10
docs/Settings.md

@ -4452,6 +4452,16 @@ LQ % indicator blinks below this value. For Crossfire use 70%, for Tracer use 50
---
### osd_mah_used_precision
Number of digits used to display mAh used.
| Default | Min | Max |
| --- | --- | --- |
| 4 | 4 | 6 |
---
### osd_main_voltage_decimals
Number of decimals for the battery voltages displayed in the OSD [1-2].

2
src/main/drivers/osd_symbols.h

@ -164,7 +164,7 @@
#define SYM_SWITCH_INDICATOR_LOW 0xD0 // 208 Switch High
#define SYM_SWITCH_INDICATOR_MID 0xD1 // 209 Switch Mid
#define SYM_SWITCH_INDICATOR_HIGH 0xD2 // 210 Switch Low
#define SYM_AH 0xD3 // 211 Amphours symbol
#define SYM_LOGO_START 0x101 // 257 to 280, INAV logo
#define SYM_LOGO_WIDTH 6

7
src/main/fc/settings.yaml

@ -3519,6 +3519,13 @@ groups:
max: 6
default_value: 3
- name: osd_mah_used_precision
description: Number of digits used to display mAh used.
field: mAh_used_precision
min: 4
max: 6
default_value: 4
- name: osd_switch_indicator_zero_name
description: "Character to use for OSD switch incicator 0."
field: osd_switch_indicator0_name

16
src/main/io/osd.c

@ -1580,13 +1580,18 @@ static bool osdDrawSingleElement(uint8_t item)
}
break;
case OSD_MAH_DRAWN:
tfp_sprintf(buff, "%4d", (int)getMAhDrawn());
buff[4] = SYM_MAH;
buff[5] = '\0';
case OSD_MAH_DRAWN: {
if (osdFormatCentiNumber(buff, getMAhDrawn() * 100, 1000, 0, (osdConfig()->mAh_used_precision - 2), osdConfig()->mAh_used_precision)) {
// Shown in mAh
buff[osdConfig()->mAh_used_precision] = SYM_AH;
} else {
// Shown in Ah
buff[osdConfig()->mAh_used_precision] = SYM_MAH;
}
buff[(osdConfig()->mAh_used_precision + 1)] = '\0';
osdUpdateBatteryCapacityOrVoltageTextAttributes(&elemAttr);
break;
}
case OSD_WH_DRAWN:
osdFormatCentiNumber(buff, getMWhDrawn() / 10, 0, 2, 0, 3);
osdUpdateBatteryCapacityOrVoltageTextAttributes(&elemAttr);
@ -3266,6 +3271,7 @@ PG_RESET_TEMPLATE(osdConfig_t, osdConfig,
.pan_servo_index = SETTING_OSD_PAN_SERVO_INDEX_DEFAULT,
.pan_servo_pwm2centideg = SETTING_OSD_PAN_SERVO_PWM2CENTIDEG_DEFAULT,
.esc_rpm_precision = SETTING_OSD_ESC_RPM_PRECISION_DEFAULT,
.mAh_used_precision = SETTING_OSD_MAH_USED_PRECISION_DEFAULT,
.osd_switch_indicator0_name = SETTING_OSD_SWITCH_INDICATOR_ZERO_NAME_DEFAULT,
.osd_switch_indicator0_channnel = SETTING_OSD_SWITCH_INDICATOR_ZERO_CHANNNEL_DEFAULT,
.osd_switch_indicator1_name = SETTING_OSD_SWITCH_INDICATOR_ONE_NAME_DEFAULT,

1
src/main/io/osd.h

@ -415,6 +415,7 @@ typedef struct osdConfig_s {
uint8_t telemetry; // use telemetry on displayed pixel line 0
uint8_t esc_rpm_precision; // Number of characters used for the RPM numbers.
uint16_t system_msg_display_time; // system message display time for multiple messages (ms)
uint8_t mAh_used_precision; // Number of numbers used for mAh drawn. Plently of packs now are > 9999 mAh
char osd_switch_indicator0_name[OSD_SWITCH_INDICATOR_NAME_LENGTH + 1]; // Name to use for switch indicator 0.
uint8_t osd_switch_indicator0_channnel; // RC Channel to use for switch indicator 0.
char osd_switch_indicator1_name[OSD_SWITCH_INDICATOR_NAME_LENGTH + 1]; // Name to use for switch indicator 1.

Loading…
Cancel
Save