Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added selectable precision to the OSD RPM #7515

Merged
merged 1 commit into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -4122,6 +4122,16 @@ Value above which to make the OSD distance from home indicator blink (meters)

---

### osd_esc_rpm_precision

Number of characters used to display the RPM value.

| Default | Min | Max |
| --- | --- | --- |
| 3 | 3 | 6 |

---

### osd_esc_temp_alarm_max

Temperature above which the IMU temperature OSD element will start blinking (decidegrees centigrade)
Expand Down
8 changes: 7 additions & 1 deletion src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3340,7 +3340,6 @@ groups:
description: "How many navigation waypoints are displayed, set to 0 (zero) to disable. As sample, if set to 2, and you just passed the 3rd waypoint of the mission, you'll see markers for the 4th waypoint (marked 1) and the 5th waypoint (marked 2)"
default_value: 0
field: hud_wp_disp

min: 0
max: 3
- name: osd_left_sidebar_scroll
Expand Down Expand Up @@ -3476,6 +3475,13 @@ groups:
min: -36
max: 36

- name: osd_esc_rpm_precision
description: Number of characters used to display the RPM value.
field: esc_rpm_precision
min: 3
max: 6
default_value: 3

- name: PG_OSD_COMMON_CONFIG
type: osdCommonConfig_t
headers: ["io/osd_common.h"]
Expand Down
33 changes: 27 additions & 6 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,17 +1037,37 @@ static void osdFormatRpm(char *buff, uint32_t rpm)
{
buff[0] = SYM_RPM;
if (rpm) {
if (rpm >= 1000) {
osdFormatCentiNumber(buff + 1, rpm / 10, 0, 1, 1, 2);
buff[3] = 'K';
buff[4] = '\0';
if ( digitCount(rpm) > osdConfig()->esc_rpm_precision) {
uint8_t rpmMaxDecimals = (osdConfig()->esc_rpm_precision - 3);
osdFormatCentiNumber(buff + 1, rpm / 10, 0, rpmMaxDecimals, rpmMaxDecimals, osdConfig()->esc_rpm_precision-1);
buff[osdConfig()->esc_rpm_precision] = 'K';
buff[osdConfig()->esc_rpm_precision+1] = '\0';
}
else {
tfp_sprintf(buff + 1, "%3lu", rpm);
switch(osdConfig()->esc_rpm_precision) {
case 6:
tfp_sprintf(buff + 1, "%6lu", rpm);
break;
case 5:
tfp_sprintf(buff + 1, "%5lu", rpm);
break;
case 4:
tfp_sprintf(buff + 1, "%4lu", rpm);
break;
case 3:
default:
tfp_sprintf(buff + 1, "%3lu", rpm);
break;
}


}
}
else {
strcpy(buff + 1, "---");
uint8_t buffPos = 1;
while (buffPos <=( osdConfig()->esc_rpm_precision)) {
strcpy(buff + buffPos++, "-");
}
}
}
#endif
Expand Down Expand Up @@ -3148,6 +3168,7 @@ PG_RESET_TEMPLATE(osdConfig_t, osdConfig,
.osd_home_position_arm_screen = SETTING_OSD_HOME_POSITION_ARM_SCREEN_DEFAULT,
.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,

.units = SETTING_OSD_UNITS_DEFAULT,
.main_voltage_decimals = SETTING_OSD_MAIN_VOLTAGE_DECIMALS_DEFAULT,
Expand Down
1 change: 1 addition & 0 deletions src/main/io/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ typedef struct osdConfig_s {
uint8_t crsf_lq_format;
uint8_t sidebar_height; // sidebar height in rows, 0 turns off sidebars leaving only level indicator arrows
uint8_t telemetry; // use telemetry on displayed pixel line 0
uint8_t esc_rpm_precision; // Number of characters used for the RPM numbers.

} osdConfig_t;

Expand Down