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

Send a (non-zero) fake location when GPS isn't present to enable display of compass heading on OpenTX

This commit is contained in:
Sam Cook 2015-05-08 18:12:29 +01:00
parent 834347f1a7
commit 6776f9c02d

View file

@ -302,12 +302,18 @@ static void sendLatLong(int32_t coord[2])
serialize16(coord[LON] < 0 ? 'W' : 'E'); serialize16(coord[LON] < 0 ? 'W' : 'E');
} }
static void sendFakeLatLong(bool useGpsNoFixValues)
static void sendFakeLatLong(void)
{ {
// Heading is only displayed on OpenTX if non-zero lat/long is also sent
int32_t coord[2] = {0,0}; int32_t coord[2] = {0,0};
coord[LAT] = (telemetryConfig->gpsNoFixLatitude * GPS_DEGREES_DIVIDER);
coord[LON] = (telemetryConfig->gpsNoFixLongitude * GPS_DEGREES_DIVIDER); if (useGpsNoFixValues) {
coord[LAT] = (telemetryConfig->gpsNoFixLatitude * GPS_DEGREES_DIVIDER);
coord[LON] = (telemetryConfig->gpsNoFixLongitude * GPS_DEGREES_DIVIDER);
} else {
coord[LAT] = (1 * GPS_DEGREES_DIVIDER);
coord[LON] = (1 * GPS_DEGREES_DIVIDER);
}
sendLatLong(coord); sendLatLong(coord);
} }
@ -315,17 +321,15 @@ static void sendFakeLatLong(void)
#ifdef GPS #ifdef GPS
static void sendGPSLatLong(void) static void sendGPSLatLong(void)
{ {
// Don't set dummy GPS data, if we already had a GPS fix
// it can be usefull to keep last valid coordinates
static uint8_t gpsFixOccured = 0; static uint8_t gpsFixOccured = 0;
//Dummy data if no 3D fix, this way we can display heading in Taranis
if (STATE(GPS_FIX) || gpsFixOccured == 1) { if (STATE(GPS_FIX) || gpsFixOccured == 1) {
// If we have ever had a fix, send the last known lat/long
gpsFixOccured = 1; gpsFixOccured = 1;
sendLatLong(GPS_coord); sendLatLong(GPS_coord);
} else { } else {
// Send dummy GPS Data in order to display compass value // otherwise send fake lat/long in order to display compass value
sendFakeLatLong(); sendFakeLatLong(true);
} }
} }
#endif #endif
@ -521,14 +525,11 @@ void handleFrSkyTelemetry(rxConfig_t *rxConfig, uint16_t deadband3d_throttle)
sendSatalliteSignalQualityAsTemperature2(); sendSatalliteSignalQualityAsTemperature2();
sendGPSLatLong(); sendGPSLatLong();
} }
else if (telemetryConfig->gpsNoFixLatitude != 0 && telemetryConfig->gpsNoFixLongitude != 0) { else {
sendFakeLatLong(); sendFakeLatLong(false);
} }
#else #else
// Send GPS information to display compass information sendFakeLatLong(false);
if (telemetryConfig->gpsNoFixLatitude != 0 && telemetryConfig->gpsNoFixLongitude != 0) {
sendFakeLatLong();
}
#endif #endif
sendTelemetryTail(); sendTelemetryTail();