Prevent crashing when OSD timers are configured incorrectly.
This commit is contained in:
parent
eb7e6c0b39
commit
0e5b9cdd5c
|
@ -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;
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Reference in New Issue