mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Refactor sat count checks and GPS trust code
single minimum GPS satellite setting single required GPS satellite setting CLI Baro vs GPS trust user interface GPS trust refactoring allow arming with GPS_FIX even if not enough sats required sats must be present to arm set required sat count to 8 add blackbox headers
This commit is contained in:
parent
9dc2f127b8
commit
09ee27cd97
28 changed files with 180 additions and 120 deletions
|
@ -273,7 +273,7 @@ typedef enum {
|
|||
|
||||
gpsData_t gpsData;
|
||||
|
||||
PG_REGISTER_WITH_RESET_TEMPLATE(gpsConfig_t, gpsConfig, PG_GPS_CONFIG, 0);
|
||||
PG_REGISTER_WITH_RESET_TEMPLATE(gpsConfig_t, gpsConfig, PG_GPS_CONFIG, 1);
|
||||
|
||||
PG_RESET_TEMPLATE(gpsConfig_t, gpsConfig,
|
||||
.provider = GPS_UBLOX,
|
||||
|
@ -284,7 +284,9 @@ PG_RESET_TEMPLATE(gpsConfig_t, gpsConfig,
|
|||
.gps_ublox_mode = UBLOX_AIRBORNE,
|
||||
.gps_set_home_point_once = false,
|
||||
.gps_use_3d_speed = false,
|
||||
.sbas_integrity = false
|
||||
.sbas_integrity = false,
|
||||
.gpsRequiredSats = GPS_REQUIRED_SAT_COUNT,
|
||||
.gpsMinimumSats = GPS_MINIMUM_SAT_COUNT
|
||||
);
|
||||
|
||||
static void shiftPacketLog(void)
|
||||
|
@ -757,7 +759,7 @@ void gpsInitHardware(void)
|
|||
static void updateGpsIndicator(timeUs_t currentTimeUs)
|
||||
{
|
||||
static uint32_t GPSLEDTime;
|
||||
if ((int32_t)(currentTimeUs - GPSLEDTime) >= 0 && (gpsSol.numSat >= 5)) {
|
||||
if ((int32_t)(currentTimeUs - GPSLEDTime) >= 0 && STATE(GPS_FIX) && (gpsSol.numSat >= gpsConfig()->gpsRequiredSats)) {
|
||||
GPSLEDTime = currentTimeUs + 150000;
|
||||
LED1_TOGGLE;
|
||||
}
|
||||
|
@ -867,18 +869,15 @@ void gpsUpdate(timeUs_t currentTimeUs)
|
|||
DISABLE_STATE(GPS_FIX_HOME);
|
||||
}
|
||||
|
||||
uint8_t minSats = 5;
|
||||
|
||||
#if defined(USE_GPS_RESCUE)
|
||||
if (gpsRescueIsConfigured()) {
|
||||
updateGPSRescueState();
|
||||
minSats = gpsRescueConfig()->minSats;
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool hasFix = false;
|
||||
if (STATE(GPS_FIX)) {
|
||||
if (gpsIsHealthy() && gpsSol.numSat >= minSats && !hasFix) {
|
||||
if (STATE(GPS_FIX_HOME)) {
|
||||
if (gpsIsHealthy() && gpsSol.numSat >= gpsConfig()->gpsRequiredSats && !hasFix) {
|
||||
// ready beep sequence on fix or requirements for gps rescue met.
|
||||
beeper(BEEPER_READY_BEEP);
|
||||
hasFix = true;
|
||||
|
@ -1804,11 +1803,12 @@ static void GPS_calculateDistanceFlownVerticalSpeed(bool initialize)
|
|||
void GPS_reset_home_position(void)
|
||||
{
|
||||
if (!STATE(GPS_FIX_HOME) || !gpsConfig()->gps_set_home_point_once) {
|
||||
if (STATE(GPS_FIX) && gpsSol.numSat >= 5) {
|
||||
if (STATE(GPS_FIX) && gpsSol.numSat >= gpsConfig()->gpsRequiredSats) {
|
||||
// requires the full sat count to say we have a home fix
|
||||
GPS_home[GPS_LATITUDE] = gpsSol.llh.lat;
|
||||
GPS_home[GPS_LONGITUDE] = gpsSol.llh.lon;
|
||||
GPS_calc_longitude_scaling(gpsSol.llh.lat); // need an initial value for distance and bearing calc
|
||||
// Set ground altitude
|
||||
GPS_calc_longitude_scaling(gpsSol.llh.lat);
|
||||
// need an initial value for distance and bearing calcs, and to set ground altitude
|
||||
ENABLE_STATE(GPS_FIX_HOME);
|
||||
}
|
||||
}
|
||||
|
@ -1833,7 +1833,7 @@ void GPS_distance_cm_bearing(int32_t *currentLat1, int32_t *currentLon1, int32_t
|
|||
|
||||
void GPS_calculateDistanceAndDirectionToHome(void)
|
||||
{
|
||||
if (STATE(GPS_FIX_HOME)) { // If we don't have home set, do not display anything
|
||||
if (STATE(GPS_FIX_HOME)) {
|
||||
uint32_t dist;
|
||||
int32_t dir;
|
||||
GPS_distance_cm_bearing(&gpsSol.llh.lat, &gpsSol.llh.lon, &GPS_home[GPS_LATITUDE], &GPS_home[GPS_LONGITUDE], &dist, &dir);
|
||||
|
@ -1841,6 +1841,7 @@ void GPS_calculateDistanceAndDirectionToHome(void)
|
|||
GPS_distanceToHomeCm = dist; // cm/sec
|
||||
GPS_directionToHome = dir / 10; // degrees * 10 or decidegrees
|
||||
} else {
|
||||
// If we don't have home set, do not display anything
|
||||
GPS_distanceToHome = 0;
|
||||
GPS_distanceToHomeCm = 0;
|
||||
GPS_directionToHome = 0;
|
||||
|
@ -1849,7 +1850,8 @@ void GPS_calculateDistanceAndDirectionToHome(void)
|
|||
|
||||
void onGpsNewData(void)
|
||||
{
|
||||
if (!(STATE(GPS_FIX) && gpsSol.numSat >= 5)) {
|
||||
if (!(STATE(GPS_FIX) && gpsSol.numSat >= gpsConfig()->gpsMinimumSats)) {
|
||||
// if we don't have a 3D fix and the minimum sats, don't give data to GPS rescue
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue