From fb9587b2ec718448be9e6480c7b76da94d4152a4 Mon Sep 17 00:00:00 2001 From: Steve Evans Date: Sun, 6 Aug 2023 09:06:50 +0100 Subject: [PATCH] Use coloured fonts if supported (#13005) --- src/main/osd/osd_elements.c | 17 +++++++++++++++-- src/main/osd/osd_warnings.c | 8 ++++---- src/main/pg/displayport_profiles.c | 9 ++++++++- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/main/osd/osd_elements.c b/src/main/osd/osd_elements.c index 555399308..6e2abd8b2 100644 --- a/src/main/osd/osd_elements.c +++ b/src/main/osd/osd_elements.c @@ -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) { + 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 @@ -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); diff --git a/src/main/osd/osd_warnings.c b/src/main/osd/osd_warnings.c index 4feba9b8f..2de7a86e6 100644 --- a/src/main/osd/osd_warnings.c +++ b/src/main/osd/osd_warnings.c @@ -173,7 +173,7 @@ 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; } @@ -181,7 +181,7 @@ void renderOsdWarning(char *warningText, bool *blinking, uint8_t *displayAttr) // 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; } @@ -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; } @@ -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; } diff --git a/src/main/pg/displayport_profiles.c b/src/main/pg/displayport_profiles.c index 6009c42a5..3d275d25e 100644 --- a/src/main/pg/displayport_profiles.c +++ b/src/main/pg/displayport_profiles.c @@ -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 -- 2.11.4.GIT