1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 17:25:20 +03:00

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); timerSource[i] = OSD_TIMER_SRC(timer);
timerPrecision[i] = OSD_TIMER_PRECISION(timer); timerPrecision[i] = OSD_TIMER_PRECISION(timer);
timerAlarm[i] = OSD_TIMER_ALARM(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; return 0;

View file

@ -483,13 +483,19 @@ static void osdShowStats(uint16_t endBatteryVoltage)
} }
if (osdStatGetState(OSD_STAT_TIMER_1)) { 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); int src = OSD_TIMER_SRC(osdConfig()->timers[OSD_TIMER_1]);
osdDisplayStatisticLabel(top++, osdTimerSourceNames[OSD_TIMER_SRC(osdConfig()->timers[OSD_TIMER_1])], buff); 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)) { 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); int src = OSD_TIMER_SRC(osdConfig()->timers[OSD_TIMER_2]);
osdDisplayStatisticLabel(top++, osdTimerSourceNames[OSD_TIMER_SRC(osdConfig()->timers[OSD_TIMER_2])], buff); 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)) { if (osdStatGetState(OSD_STAT_MAX_ALTITUDE)) {