1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-21 15:25:29 +03:00

Merge pull request #167 from iNavFlight/ltm-send-gframe-without-gps

Allow LTM to send G-frame even when there's no GPS
This commit is contained in:
Konstantin Sharlaimov 2016-04-24 21:15:49 +10:00
commit aea68f51a1

View file

@ -130,28 +130,31 @@ static void ltm_finalise(void)
static void ltm_gframe(void) static void ltm_gframe(void)
{ {
uint8_t gps_fix_type = 0; uint8_t gps_fix_type = 0;
int32_t ltm_alt; int32_t ltm_lat = 0, ltm_lon = 0, ltm_alt = 0, ltm_gs = 0;
if (!sensors(SENSOR_GPS)) if (sensors(SENSOR_GPS)) {
return; if (gpsSol.fixType == GPS_NO_FIX)
gps_fix_type = 1;
else if (gpsSol.fixType == GPS_FIX_2D)
gps_fix_type = 2;
else if (gpsSol.fixType == GPS_FIX_3D)
gps_fix_type = 3;
if (gpsSol.fixType == GPS_NO_FIX) ltm_lat = gpsSol.llh.lat;
gps_fix_type = 1; ltm_lon = gpsSol.llh.lon;
else if (gpsSol.fixType == GPS_FIX_2D) ltm_gs = gpsSol.groundSpeed / 100;
gps_fix_type = 2; }
else if (gpsSol.fixType == GPS_FIX_3D)
gps_fix_type = 3;
ltm_initialise_packet('G');
ltm_serialise_32(gpsSol.llh.lat);
ltm_serialise_32(gpsSol.llh.lon);
ltm_serialise_8((uint8_t)(gpsSol.groundSpeed / 100));
#if defined(NAV) #if defined(NAV)
ltm_alt = (sensors(SENSOR_SONAR) || sensors(SENSOR_BARO)) ? getEstimatedActualPosition(Z) : gpsSol.llh.alt; // cm ltm_alt = getEstimatedActualPosition(Z); // cm
#else #else
ltm_alt = gpsSol.llh.alt; // cm ltm_alt = sensors(SENSOR_GPS) ? gpsSol.llh.alt : 0; // cm
#endif #endif
ltm_initialise_packet('G');
ltm_serialise_32(ltm_lat);
ltm_serialise_32(ltm_lon);
ltm_serialise_8((uint8_t)ltm_gs);
ltm_serialise_32(ltm_alt); ltm_serialise_32(ltm_alt);
ltm_serialise_8((gpsSol.numSat << 2) | gps_fix_type); ltm_serialise_8((gpsSol.numSat << 2) | gps_fix_type);
ltm_finalise(); ltm_finalise();