Merge pull request #7368 from TonyBlit/osd_gps_no_fix
Hide OSD Altitude and Numeric Vario when no GPS fix
This commit is contained in:
commit
f9e12337d5
|
@ -700,7 +700,26 @@ static bool osdDrawSingleElement(uint8_t item)
|
|||
break;
|
||||
|
||||
case OSD_ALTITUDE:
|
||||
osdFormatAltitudeString(buff, getEstimatedAltitudeCm());
|
||||
{
|
||||
bool haveBaro = false;
|
||||
bool haveGps = false;
|
||||
#ifdef USE_BARO
|
||||
haveBaro = sensors(SENSOR_BARO);
|
||||
#endif
|
||||
#ifdef USE_GPS
|
||||
haveGps = sensors(SENSOR_GPS) && STATE(GPS_FIX);
|
||||
#endif
|
||||
if (haveBaro || haveGps) {
|
||||
osdFormatAltitudeString(buff, getEstimatedAltitudeCm());
|
||||
} else {
|
||||
// We use this symbol when we don't have a valid measure
|
||||
buff[0] = SYM_COLON;
|
||||
// overwrite any previous altitude with blanks
|
||||
memset(buff + 1, SYM_BLANK, 6);
|
||||
buff[7] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OSD_ITEM_TIMER_1:
|
||||
|
@ -1169,9 +1188,25 @@ static bool osdDrawSingleElement(uint8_t item)
|
|||
#ifdef USE_VARIO
|
||||
case OSD_NUMERICAL_VARIO:
|
||||
{
|
||||
const int verticalSpeed = osdGetMetersToSelectedUnit(getEstimatedVario());
|
||||
const char directionSymbol = verticalSpeed < 0 ? SYM_ARROW_SOUTH : SYM_ARROW_NORTH;
|
||||
tfp_sprintf(buff, "%c%01d.%01d", directionSymbol, abs(verticalSpeed / 100), abs((verticalSpeed % 100) / 10));
|
||||
bool haveBaro = false;
|
||||
bool haveGps = false;
|
||||
#ifdef USE_BARO
|
||||
haveBaro = sensors(SENSOR_BARO);
|
||||
#endif
|
||||
#ifdef USE_GPS
|
||||
haveGps = sensors(SENSOR_GPS) && STATE(GPS_FIX);
|
||||
#endif
|
||||
if (haveBaro || haveGps) {
|
||||
const int verticalSpeed = osdGetMetersToSelectedUnit(getEstimatedVario());
|
||||
const char directionSymbol = verticalSpeed < 0 ? SYM_ARROW_SOUTH : SYM_ARROW_NORTH;
|
||||
tfp_sprintf(buff, "%c%01d.%01d", directionSymbol, abs(verticalSpeed / 100), abs((verticalSpeed % 100) / 10));
|
||||
} else {
|
||||
// We use this symbol when we don't have a valid measure
|
||||
buff[0] = SYM_COLON;
|
||||
// overwrite any previous vertical speed with blanks
|
||||
memset(buff + 1, SYM_BLANK, 6);
|
||||
buff[7] = '\0';
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -464,6 +464,7 @@ TEST(OsdTest, TestAlarms)
|
|||
// given
|
||||
// default state is set
|
||||
setDefaultSimulationState();
|
||||
sensorsSet(SENSOR_GPS);
|
||||
|
||||
// and
|
||||
// the following OSD elements are visible
|
||||
|
@ -740,12 +741,21 @@ TEST(OsdTest, TestElementAltitude)
|
|||
|
||||
// and
|
||||
osdConfigMutable()->units = OSD_UNIT_METRIC;
|
||||
sensorsClear(SENSOR_GPS);
|
||||
|
||||
// when
|
||||
simulationAltitude = 0;
|
||||
displayClearScreen(&testDisplayPort);
|
||||
osdRefresh(simulationTime);
|
||||
|
||||
// then
|
||||
displayPortTestBufferSubstring(23, 7, "- ");
|
||||
|
||||
// when
|
||||
sensorsSet(SENSOR_GPS);
|
||||
displayClearScreen(&testDisplayPort);
|
||||
osdRefresh(simulationTime);
|
||||
|
||||
// then
|
||||
displayPortTestBufferSubstring(23, 7, " .0%c", SYM_M);
|
||||
|
||||
|
|
Loading…
Reference in New Issue