mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 00:35:39 +03:00
OSD timers safety - code review changes
This commit is contained in:
parent
078e7fc0a5
commit
b8b5b133dc
3 changed files with 13 additions and 11 deletions
|
@ -471,16 +471,11 @@ static void validateAndFixConfig(void)
|
|||
|
||||
#if defined(USE_OSD)
|
||||
for (int i = 0; i < OSD_TIMER_COUNT; i++) {
|
||||
const uint16_t timer = osdConfig()->timers[i];
|
||||
int src = OSD_TIMER_SRC(timer);
|
||||
int prc = OSD_TIMER_PRECISION(timer);
|
||||
if (src >= OSD_TIMER_SRC_COUNT) {
|
||||
src = 0;
|
||||
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];
|
||||
}
|
||||
if (prc >= OSD_TIMER_PREC_COUNT) {
|
||||
prc = 0;
|
||||
}
|
||||
osdConfigMutable()->timers[i] = OSD_TIMER(src, prc, OSD_TIMER_ALARM(timer));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -197,6 +197,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
|
||||
|
@ -234,8 +239,8 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
|||
osdWarnSetState(i, true);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -215,6 +215,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];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue