mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Fix OSD active elements init logic to handle delayed items with delayed activation
Track the state of `sensors(SENSOR_GPS)` and rebuild the active OSD element list when it changes. The GPS sensor can have delayed activation or even deactivate if communication is lost with the module. Also move the `BOXBLACKBOX` check from the initialization to the runtime element drawing as it can also change in flight.
This commit is contained in:
parent
bdacbf80b9
commit
4a13c48adf
1 changed files with 22 additions and 12 deletions
|
@ -734,12 +734,14 @@ static void osdElementLinkQuality(osdElementParms_t *element)
|
|||
#ifdef USE_BLACKBOX
|
||||
static void osdElementLogStatus(osdElementParms_t *element)
|
||||
{
|
||||
if (!isBlackboxDeviceWorking()) {
|
||||
tfp_sprintf(element->buff, "L-");
|
||||
} else if (isBlackboxDeviceFull()) {
|
||||
tfp_sprintf(element->buff, "L>");
|
||||
} else {
|
||||
tfp_sprintf(element->buff, "L%d", blackboxGetLogNumber());
|
||||
if (IS_RC_MODE_ACTIVE(BOXBLACKBOX)) {
|
||||
if (!isBlackboxDeviceWorking()) {
|
||||
tfp_sprintf(element->buff, "L-");
|
||||
} else if (isBlackboxDeviceFull()) {
|
||||
tfp_sprintf(element->buff, "L>");
|
||||
} else {
|
||||
tfp_sprintf(element->buff, "L%d", blackboxGetLogNumber());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // USE_BLACKBOX
|
||||
|
@ -1211,6 +1213,9 @@ static const uint8_t osdElementDisplayOrder[] = {
|
|||
OSD_NUMERICAL_VARIO,
|
||||
OSD_COMPASS_BAR,
|
||||
OSD_ANTI_GRAVITY,
|
||||
#ifdef USE_BLACKBOX
|
||||
OSD_LOG_STATUS,
|
||||
#endif
|
||||
OSD_MOTOR_DIAG,
|
||||
#ifdef USE_ACC
|
||||
OSD_FLIP_ARROW,
|
||||
|
@ -1376,12 +1381,6 @@ void osdAnalyzeActiveElements(void)
|
|||
osdAddActiveElement(OSD_ESC_RPM);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_BLACKBOX
|
||||
if (IS_RC_MODE_ACTIVE(BOXBLACKBOX)) {
|
||||
osdAddActiveElement(OSD_LOG_STATUS);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool osdDrawSingleElement(displayPort_t *osdDisplayPort, uint8_t item)
|
||||
|
@ -1413,6 +1412,17 @@ static bool osdDrawSingleElement(displayPort_t *osdDisplayPort, uint8_t item)
|
|||
|
||||
void osdDrawActiveElements(displayPort_t *osdDisplayPort, timeUs_t currentTimeUs)
|
||||
{
|
||||
#ifdef USE_GPS
|
||||
static bool lastGpsSensorState;
|
||||
// Handle the case that the GPS_SENSOR may be delayed in activation
|
||||
// or deactivate if communication is lost with the module.
|
||||
const bool currentGpsSensorState = sensors(SENSOR_GPS);
|
||||
if (lastGpsSensorState != currentGpsSensorState) {
|
||||
lastGpsSensorState = currentGpsSensorState;
|
||||
osdAnalyzeActiveElements();
|
||||
}
|
||||
#endif // USE_GPS
|
||||
|
||||
blinkState = (currentTimeUs / 200000) % 2;
|
||||
|
||||
for (unsigned i = 0; i < activeOsdElementCount; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue