void hottPrepareGPSResponse(HOTT_GPS_MSG_t *hottGPSMessage) { hottGPSMessage->gps_satelites = GPS_numSat; if (!STATE(GPS_FIX)) { hottGPSMessage->gps_fix_char = GPS_FIX_CHAR_NONE; return; } if (GPS_numSat >= 5) { hottGPSMessage->gps_fix_char = GPS_FIX_CHAR_3D; } else { hottGPSMessage->gps_fix_char = GPS_FIX_CHAR_2D; } addGPSCoordinates(hottGPSMessage, GPS_coord[LAT], GPS_coord[LON]); // GPS Speed in km/h uint16_t speed = (GPS_speed * 36) / 100; // 0->1m/s * 0->36 = km/h hottGPSMessage->gps_speed_L = speed & 0x00FF; hottGPSMessage->gps_speed_H = speed >> 8; hottGPSMessage->home_distance_L = GPS_distanceToHome & 0x00FF; hottGPSMessage->home_distance_H = GPS_distanceToHome >> 8; uint16_t hottGpsAltitude = (GPS_altitude / 10) + HOTT_GPS_ALTITUDE_OFFSET; // 1 / 0.1f == 10, GPS_altitude of 1 == 0.1m hottGPSMessage->altitude_L = hottGpsAltitude & 0x00FF; hottGPSMessage->altitude_H = hottGpsAltitude >> 8; hottGPSMessage->home_direction = GPS_directionToHome; }
void hottPrepareGPSResponse(HOTT_GPS_MSG_t *hottGPSMessage) { hottGPSMessage->gps_satelites = GPS_numSat; if (!STATE(GPS_FIX)) { hottGPSMessage->gps_fix_char = GPS_FIX_CHAR_NONE; return; } if (GPS_numSat >= 5) { hottGPSMessage->gps_fix_char = GPS_FIX_CHAR_3D; } else { hottGPSMessage->gps_fix_char = GPS_FIX_CHAR_2D; } addGPSCoordinates(hottGPSMessage, GPS_coord[LAT], GPS_coord[LON]); // GPS Speed is returned in cm/s (from io/gps.c) and must be sent in km/h (Hott requirement) uint16_t speed = (GPS_speed * 36) / 1000; hottGPSMessage->gps_speed_L = speed & 0x00FF; hottGPSMessage->gps_speed_H = speed >> 8; hottGPSMessage->home_distance_L = GPS_distanceToHome & 0x00FF; hottGPSMessage->home_distance_H = GPS_distanceToHome >> 8; uint16_t hottGpsAltitude = GPS_altitude + HOTT_GPS_ALTITUDE_OFFSET; // GPS_altitude in m ; offset = 500 -> O m hottGPSMessage->altitude_L = hottGpsAltitude & 0x00FF; hottGPSMessage->altitude_H = hottGpsAltitude >> 8; hottGPSMessage->home_direction = GPS_directionToHome; }
void hottPrepareGPSResponse(HOTT_GPS_MSG_t *hottGPSMessage) { hottGPSMessage->gps_satelites = gpsSol.numSat; // Report climb rate regardless of GPS fix const int32_t climbrate = MAX(0, getEstimatedActualVelocity(Z) + 30000); hottGPSMessage->climbrate_L = climbrate & 0xFF; hottGPSMessage->climbrate_H = climbrate >> 8; const int32_t climbrate3s = MAX(0, 3.0f * getEstimatedActualVelocity(Z) / 100 + 120); hottGPSMessage->climbrate3s = climbrate3s & 0xFF; if (!STATE(GPS_FIX)) { hottGPSMessage->gps_fix_char = GPS_FIX_CHAR_NONE; return; } if (gpsSol.fixType == GPS_FIX_3D) { hottGPSMessage->gps_fix_char = GPS_FIX_CHAR_3D; } else { hottGPSMessage->gps_fix_char = GPS_FIX_CHAR_2D; } addGPSCoordinates(hottGPSMessage, gpsSol.llh.lat, gpsSol.llh.lon); // GPS Speed is returned in cm/s (from io/gps.c) and must be sent in km/h (Hott requirement) const uint16_t speed = (gpsSol.groundSpeed * 36) / 1000; hottGPSMessage->gps_speed_L = speed & 0x00FF; hottGPSMessage->gps_speed_H = speed >> 8; hottGPSMessage->home_distance_L = GPS_distanceToHome & 0x00FF; hottGPSMessage->home_distance_H = GPS_distanceToHome >> 8; const uint16_t hottGpsAltitude = (gpsSol.llh.alt / 100) + HOTT_GPS_ALTITUDE_OFFSET; // meters hottGPSMessage->altitude_L = hottGpsAltitude & 0x00FF; hottGPSMessage->altitude_H = hottGpsAltitude >> 8; hottGPSMessage->home_direction = GPS_directionToHome; }