Prevent crashing when OSD timers are configured incorrectly.

This commit is contained in:
Krzysztof Matula 2019-04-15 00:25:28 +02:00
parent eb7e6c0b39
commit 0e5b9cdd5c
2 changed files with 14 additions and 4 deletions

View File

@ -205,6 +205,10 @@ static long menuTimersOnEnter(void)
timerSource[i] = OSD_TIMER_SRC(timer);
timerPrecision[i] = OSD_TIMER_PRECISION(timer);
timerAlarm[i] = OSD_TIMER_ALARM(timer);
if ((int)timerSource[i] >= (int)OSD_TIMER_SRC_COUNT)
timerSource[i] = OSD_TIMER_SRC_ON;
if ((int)timerPrecision[i] >= (int)OSD_TIMER_PREC_COUNT)
timerPrecision[i] = OSD_TIMER_PREC_SECOND;
}
return 0;

View File

@ -483,13 +483,19 @@ static void osdShowStats(uint16_t endBatteryVoltage)
}
if (osdStatGetState(OSD_STAT_TIMER_1)) {
osdFormatTimer(buff, false, (OSD_TIMER_SRC(osdConfig()->timers[OSD_TIMER_1]) == OSD_TIMER_SRC_ON ? false : true), OSD_TIMER_1);
osdDisplayStatisticLabel(top++, osdTimerSourceNames[OSD_TIMER_SRC(osdConfig()->timers[OSD_TIMER_1])], buff);
int src = OSD_TIMER_SRC(osdConfig()->timers[OSD_TIMER_1]);
if (src >= OSD_TIMER_SRC_COUNT)
src = 0;
osdFormatTimer(buff, false, (src == OSD_TIMER_SRC_ON ? false : true), OSD_TIMER_1);
osdDisplayStatisticLabel(top++, osdTimerSourceNames[src], buff);
}
if (osdStatGetState(OSD_STAT_TIMER_2)) {
osdFormatTimer(buff, false, (OSD_TIMER_SRC(osdConfig()->timers[OSD_TIMER_2]) == OSD_TIMER_SRC_ON ? false : true), OSD_TIMER_2);
osdDisplayStatisticLabel(top++, osdTimerSourceNames[OSD_TIMER_SRC(osdConfig()->timers[OSD_TIMER_2])], buff);
int src = OSD_TIMER_SRC(osdConfig()->timers[OSD_TIMER_2]);
if (src >= OSD_TIMER_SRC_COUNT)
src = 0;
osdFormatTimer(buff, false, (src == OSD_TIMER_SRC_ON ? false : true), OSD_TIMER_2);
osdDisplayStatisticLabel(top++, osdTimerSourceNames[src], buff);
}
if (osdStatGetState(OSD_STAT_MAX_ALTITUDE)) {