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;
|
break;
|
||||||
|
|
||||||
case OSD_ALTITUDE:
|
case OSD_ALTITUDE:
|
||||||
|
{
|
||||||
|
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());
|
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;
|
break;
|
||||||
|
|
||||||
case OSD_ITEM_TIMER_1:
|
case OSD_ITEM_TIMER_1:
|
||||||
|
@ -1169,9 +1188,25 @@ static bool osdDrawSingleElement(uint8_t item)
|
||||||
#ifdef USE_VARIO
|
#ifdef USE_VARIO
|
||||||
case OSD_NUMERICAL_VARIO:
|
case OSD_NUMERICAL_VARIO:
|
||||||
{
|
{
|
||||||
|
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 int verticalSpeed = osdGetMetersToSelectedUnit(getEstimatedVario());
|
||||||
const char directionSymbol = verticalSpeed < 0 ? SYM_ARROW_SOUTH : SYM_ARROW_NORTH;
|
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));
|
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;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -464,6 +464,7 @@ TEST(OsdTest, TestAlarms)
|
||||||
// given
|
// given
|
||||||
// default state is set
|
// default state is set
|
||||||
setDefaultSimulationState();
|
setDefaultSimulationState();
|
||||||
|
sensorsSet(SENSOR_GPS);
|
||||||
|
|
||||||
// and
|
// and
|
||||||
// the following OSD elements are visible
|
// the following OSD elements are visible
|
||||||
|
@ -740,12 +741,21 @@ TEST(OsdTest, TestElementAltitude)
|
||||||
|
|
||||||
// and
|
// and
|
||||||
osdConfigMutable()->units = OSD_UNIT_METRIC;
|
osdConfigMutable()->units = OSD_UNIT_METRIC;
|
||||||
|
sensorsClear(SENSOR_GPS);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
simulationAltitude = 0;
|
simulationAltitude = 0;
|
||||||
displayClearScreen(&testDisplayPort);
|
displayClearScreen(&testDisplayPort);
|
||||||
osdRefresh(simulationTime);
|
osdRefresh(simulationTime);
|
||||||
|
|
||||||
|
// then
|
||||||
|
displayPortTestBufferSubstring(23, 7, "- ");
|
||||||
|
|
||||||
|
// when
|
||||||
|
sensorsSet(SENSOR_GPS);
|
||||||
|
displayClearScreen(&testDisplayPort);
|
||||||
|
osdRefresh(simulationTime);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
displayPortTestBufferSubstring(23, 7, " .0%c", SYM_M);
|
displayPortTestBufferSubstring(23, 7, " .0%c", SYM_M);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue