From 38c940c11e2294b6d9a92ac6e1cec29677ad534a Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Wed, 7 Nov 2018 18:35:32 -0500 Subject: [PATCH] Improve behavior of OSD warnings element blinking Previously the logic to blink the warnings element was based on whether batteryState was either BATTERY_WARNING or BATTERY_CRITICAL. The problem is that the warning element might be displaying a higher priority message that shouldn't blink. Changes the logic to have the blinking based on the actual warning message displayed. In addition to the battery warning/critical cases, added blinking for some other critical warnings like failsafe, CPU core temp warning, ESC sensor warnings, HEADFREE mode active, and RC smoothing not initialized. --- src/main/io/osd.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 7e57f72680..c08f51a5cd 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -817,6 +817,8 @@ static bool osdDrawSingleElement(uint8_t item) static timeUs_t armingDisabledUpdateTimeUs; static unsigned armingDisabledDisplayIndex; + CLR_BLINK(OSD_WARNINGS); + // Cycle through the arming disabled reasons if (osdWarnGetState(OSD_WARNING_ARMING_DISABLE)) { if (IS_RC_MODE_ACTIVE(BOXARM) && isArmingDisabled()) { @@ -868,17 +870,20 @@ static bool osdDrawSingleElement(uint8_t item) #endif if (osdWarnGetState(OSD_WARNING_FAIL_SAFE) && failsafeIsActive()) { osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, "FAIL SAFE"); + SET_BLINK(OSD_WARNINGS); break; } if (osdWarnGetState(OSD_WARNING_BATTERY_CRITICAL) && batteryState == BATTERY_CRITICAL) { osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, " LAND NOW"); + SET_BLINK(OSD_WARNINGS); break; } // Show warning if in HEADFREE flight mode if (FLIGHT_MODE(HEADFREE_MODE)) { osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, "HEADFREE"); + SET_BLINK(OSD_WARNINGS); break; } @@ -889,7 +894,7 @@ static bool osdDrawSingleElement(uint8_t item) tfp_sprintf(coreTemperatureWarningMsg, "CORE: %3d%c", osdConvertTemperatureToSelectedUnit(coreTemperature), osdGetTemperatureSymbolForSelectedUnit()); osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, coreTemperatureWarningMsg); - + SET_BLINK(OSD_WARNINGS); break; } #endif @@ -940,6 +945,7 @@ static bool osdDrawSingleElement(uint8_t item) if (escWarningCount > 0) { osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, escWarningMsg); + SET_BLINK(OSD_WARNINGS); break; } } @@ -968,6 +974,7 @@ static bool osdDrawSingleElement(uint8_t item) if (osdWarnGetState(OSD_WARNING_BATTERY_WARNING) && batteryState == BATTERY_WARNING) { osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, "LOW BATTERY"); + SET_BLINK(OSD_WARNINGS); break; } @@ -975,6 +982,7 @@ static bool osdDrawSingleElement(uint8_t item) // Show warning if rc smoothing hasn't initialized the filters if (osdWarnGetState(OSD_WARNING_RC_SMOOTHING) && ARMING_FLAG(ARMED) && !rcSmoothingInitializationComplete()) { osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, "RCSMOOTHING"); + SET_BLINK(OSD_WARNINGS); break; } #endif @@ -1293,18 +1301,6 @@ void osdUpdateAlarms(void) CLR_BLINK(OSD_RSSI_VALUE); } - // Determine if the OSD_WARNINGS should blink - if (getBatteryState() != BATTERY_OK - && (osdWarnGetState(OSD_WARNING_BATTERY_CRITICAL) || osdWarnGetState(OSD_WARNING_BATTERY_WARNING)) -#ifdef USE_DSHOT - && (!isTryingToArm()) -#endif - ) { - SET_BLINK(OSD_WARNINGS); - } else { - CLR_BLINK(OSD_WARNINGS); - } - if (getBatteryState() == BATTERY_OK) { CLR_BLINK(OSD_MAIN_BATT_VOLTAGE); CLR_BLINK(OSD_AVG_CELL_VOLTAGE);