diff --git a/src/main/fc/config.c b/src/main/fc/config.c index cf72a214e8..6ce074f836 100644 --- a/src/main/fc/config.c +++ b/src/main/fc/config.c @@ -52,6 +52,8 @@ #include "io/serial.h" #include "io/gps.h" +#include "osd/osd.h" + #include "pg/beeper.h" #include "pg/beeper_dev.h" #include "pg/rx.h" @@ -463,6 +465,16 @@ static void validateAndFixConfig(void) } #endif +#if defined(USE_OSD) + for (int i = 0; i < OSD_TIMER_COUNT; i++) { + const uint16_t t = osdConfig()->timers[i]; + if (OSD_TIMER_SRC(t) >= OSD_TIMER_SRC_COUNT || + OSD_TIMER_PRECISION(t) >= OSD_TIMER_PREC_COUNT) { + osdConfigMutable()->timers[i] = osdTimerDefault[i]; + } + } +#endif + #if defined(TARGET_VALIDATECONFIG) targetValidateConfiguration(); #endif diff --git a/src/main/osd/osd.c b/src/main/osd/osd.c index b5143f700d..cfc4a7c4a1 100644 --- a/src/main/osd/osd.c +++ b/src/main/osd/osd.c @@ -198,6 +198,11 @@ static void osdDrawElements(timeUs_t currentTimeUs) osdDrawActiveElements(osdDisplayPort, currentTimeUs); } +const uint16_t osdTimerDefault[OSD_TIMER_COUNT] = { + OSD_TIMER(OSD_TIMER_SRC_ON, OSD_TIMER_PREC_SECOND, 10), + OSD_TIMER(OSD_TIMER_SRC_TOTAL_ARMED, OSD_TIMER_PREC_SECOND, 10) +}; + void pgResetFn_osdConfig(osdConfig_t *osdConfig) { // Position elements near centre of screen and disabled by default @@ -238,8 +243,8 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig) osdWarnSetState(OSD_WARNING_RSSI, false); osdWarnSetState(OSD_WARNING_LINK_QUALITY, false); - osdConfig->timers[OSD_TIMER_1] = OSD_TIMER(OSD_TIMER_SRC_ON, OSD_TIMER_PREC_SECOND, 10); - osdConfig->timers[OSD_TIMER_2] = OSD_TIMER(OSD_TIMER_SRC_TOTAL_ARMED, OSD_TIMER_PREC_SECOND, 10); + osdConfig->timers[OSD_TIMER_1] = osdTimerDefault[OSD_TIMER_1]; + osdConfig->timers[OSD_TIMER_2] = osdTimerDefault[OSD_TIMER_2]; osdConfig->overlay_radio_mode = 2; diff --git a/src/main/osd/osd.h b/src/main/osd/osd.h index fe9607a6b1..9c0cce8a29 100644 --- a/src/main/osd/osd.h +++ b/src/main/osd/osd.h @@ -218,6 +218,8 @@ STATIC_ASSERT(OSD_WARNING_COUNT <= 32, osdwarnings_overflow); #define OSD_GPS_RESCUE_DISABLED_WARNING_DURATION_US 3000000 // 3 seconds +extern const uint16_t osdTimerDefault[OSD_TIMER_COUNT]; + typedef struct osdConfig_s { uint16_t item_pos[OSD_ITEM_COUNT];