Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/main/osd/osd_elements.c
Original file line number Diff line number Diff line change
Expand Up @@ -1498,13 +1498,18 @@ static void osdElementRtcTime(osdElementParms_t *element)
static void osdElementRssiDbm(osdElementParms_t *element)
{
const int8_t antenna = getActiveAntenna();
const int16_t osdRssiDbm = getRssiDbm();
static bool diversity = false;

if (osdRssiDbm < osdConfig()->rssi_dbm_alarm) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this runs in the loop, I would load the config value in the init function, as config calls are expensive correct?

There are couple of config calls, I think we should initialize the all in a local variable in init.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These setting can be changed on the fly outside of initialisation. Config access is considered low cost as it's held in RAM. osdConfig()-> appears in https://github.com/betaflight/betaflight/blob/321fd468fd2f3be78681d45e3e578cd768c3f26c/src/main/osd/osd_elements.c 53 times for such comparisons, or, for example, determining which unit symbols to display.

element->attr = DISPLAYPORT_SEVERITY_CRITICAL;
}

if (antenna || diversity) {
diversity = true;
tfp_sprintf(element->buff, "%c%3d:%d", SYM_RSSI, getRssiDbm(), antenna + 1);
tfp_sprintf(element->buff, "%c%3d:%d", SYM_RSSI, osdRssiDbm, antenna + 1);
} else {
tfp_sprintf(element->buff, "%c%3d", SYM_RSSI, getRssiDbm());
tfp_sprintf(element->buff, "%c%3d", SYM_RSSI, osdRssiDbm);
}
}
#endif // USE_RX_RSSI_DBM
Expand Down Expand Up @@ -2144,6 +2149,14 @@ void osdUpdateAlarms(void)
CLR_BLINK(OSD_RSSI_VALUE);
}

#ifdef USE_RX_RSSI_DBM
if (getRssiDbm() < osdConfig()->rssi_dbm_alarm) {
SET_BLINK(OSD_RSSI_DBM_VALUE);
} else {
CLR_BLINK(OSD_RSSI_DBM_VALUE);
}
#endif

#ifdef USE_RX_LINK_QUALITY_INFO
if (rxGetLinkQualityPercent() < osdConfig()->link_quality_alarm) {
SET_BLINK(OSD_LINK_QUALITY);
Expand Down
8 changes: 4 additions & 4 deletions src/main/osd/osd_warnings.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ void renderOsdWarning(char *warningText, bool *blinking, uint8_t *displayAttr)
// RSSI
if (osdWarnGetState(OSD_WARNING_RSSI) && (getRssiPercent() < osdConfig()->rssi_alarm)) {
tfp_sprintf(warningText, "RSSI LOW");
*displayAttr = DISPLAYPORT_SEVERITY_WARNING;
*displayAttr = DISPLAYPORT_SEVERITY_CRITICAL;
*blinking = true;
return;
}
#ifdef USE_RX_RSSI_DBM
// rssi dbm
if (osdWarnGetState(OSD_WARNING_RSSI_DBM) && (getRssiDbm() < osdConfig()->rssi_dbm_alarm)) {
tfp_sprintf(warningText, "RSSI DBM");
*displayAttr = DISPLAYPORT_SEVERITY_WARNING;
*displayAttr = DISPLAYPORT_SEVERITY_CRITICAL;
*blinking = true;
return;
}
Expand All @@ -190,7 +190,7 @@ void renderOsdWarning(char *warningText, bool *blinking, uint8_t *displayAttr)
// rsnr
if (osdWarnGetState(OSD_WARNING_RSNR) && (getRsnr() < osdConfig()->rsnr_alarm)) {
tfp_sprintf(warningText, "RSNR LOW");
*displayAttr = DISPLAYPORT_SEVERITY_WARNING;
*displayAttr = DISPLAYPORT_SEVERITY_CRITICAL;
*blinking = true;
return;
}
Expand All @@ -200,7 +200,7 @@ void renderOsdWarning(char *warningText, bool *blinking, uint8_t *displayAttr)
// Link Quality
if (osdWarnGetState(OSD_WARNING_LINK_QUALITY) && (rxGetLinkQualityPercent() < osdConfig()->link_quality_alarm)) {
tfp_sprintf(warningText, "LINK QUALITY");
*displayAttr = DISPLAYPORT_SEVERITY_WARNING;
*displayAttr = DISPLAYPORT_SEVERITY_CRITICAL;
*blinking = true;
return;
}
Expand Down
9 changes: 8 additions & 1 deletion src/main/pg/displayport_profiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@

#if defined(USE_MSP_DISPLAYPORT)

PG_REGISTER(displayPortProfile_t, displayPortProfileMsp, PG_DISPLAY_PORT_MSP_CONFIG, 1);
PG_REGISTER_WITH_RESET_FN(displayPortProfile_t, displayPortProfileMsp, PG_DISPLAY_PORT_MSP_CONFIG, 1);

void pgResetFn_displayPortProfileMsp(displayPortProfile_t *displayPortProfile)
{
for (uint8_t font = 0; font < DISPLAYPORT_SEVERITY_COUNT; font++) {
displayPortProfile->fontSelection[font] = font;
}
}

#endif

Expand Down