1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 22:35:23 +03:00

Parameter for updating GPS Home point once

This commit is contained in:
Tony Cabello 2019-01-11 04:38:11 +01:00
parent d8e8d8374d
commit 75a014eb1e
3 changed files with 14 additions and 9 deletions

View file

@ -829,6 +829,7 @@ const clivalue_t valueTable[] = {
{ "gps_auto_config", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_GPS_CONFIG, offsetof(gpsConfig_t, autoConfig) },
{ "gps_auto_baud", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_GPS_CONFIG, offsetof(gpsConfig_t, autoBaud) },
{ "gps_ublox_use_galileo", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_GPS_CONFIG, offsetof(gpsConfig_t, gps_ublox_use_galileo) },
{ "gps_set_home_point_once", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_GPS_CONFIG, offsetof(gpsConfig_t, gps_set_home_point_once) },
#ifdef USE_GPS_RESCUE
// PG_GPS_RESCUE

View file

@ -244,7 +244,8 @@ PG_RESET_TEMPLATE(gpsConfig_t, gpsConfig,
.sbasMode = SBAS_AUTO,
.autoConfig = GPS_AUTOCONFIG_ON,
.autoBaud = GPS_AUTOBAUD_OFF,
.gps_ublox_use_galileo = false
.gps_ublox_use_galileo = false,
.gps_set_home_point_once = false
);
static void shiftPacketLog(void)
@ -547,7 +548,7 @@ void gpsUpdate(timeUs_t currentTimeUs)
if (sensors(SENSOR_GPS)) {
updateGpsIndicator(currentTimeUs);
}
if (!ARMING_FLAG(ARMED)) {
if (!ARMING_FLAG(ARMED) && !gpsConfig()->gps_set_home_point_once) {
DISABLE_STATE(GPS_FIX_HOME);
}
#if defined(USE_GPS_RESCUE)
@ -1286,7 +1287,7 @@ static void GPS_calculateDistanceFlownVerticalSpeed(bool initialize)
GPS_distanceFlownInCm = 0;
GPS_verticalSpeedInCmS = 0;
} else {
if (STATE(GPS_FIX_HOME)) {
if (STATE(GPS_FIX_HOME) && ARMING_FLAG(ARMED)) {
// Only add up movement when speed is faster than minimum threshold
if (gpsSol.groundSpeed > GPS_DISTANCE_FLOWN_MIN_GROUND_SPEED_THRESHOLD_CM_S) {
uint32_t dist;
@ -1307,12 +1308,14 @@ static void GPS_calculateDistanceFlownVerticalSpeed(bool initialize)
void GPS_reset_home_position(void)
{
if (STATE(GPS_FIX) && gpsSol.numSat >= 5) {
GPS_home[LAT] = gpsSol.llh.lat;
GPS_home[LON] = gpsSol.llh.lon;
GPS_calc_longitude_scaling(gpsSol.llh.lat); // need an initial value for distance and bearing calc
// Set ground altitude
ENABLE_STATE(GPS_FIX_HOME);
if (!STATE(GPS_FIX_HOME) || !gpsConfig()->gps_set_home_point_once) {
if (STATE(GPS_FIX) && gpsSol.numSat >= 5) {
GPS_home[LAT] = gpsSol.llh.lat;
GPS_home[LON] = gpsSol.llh.lon;
GPS_calc_longitude_scaling(gpsSol.llh.lat); // need an initial value for distance and bearing calc
// Set ground altitude
ENABLE_STATE(GPS_FIX_HOME);
}
}
GPS_calculateDistanceFlownVerticalSpeed(true); //Initialize
}

View file

@ -74,6 +74,7 @@ typedef struct gpsConfig_s {
gpsAutoConfig_e autoConfig;
gpsAutoBaud_e autoBaud;
uint8_t gps_ublox_use_galileo;
uint8_t gps_set_home_point_once;
} gpsConfig_t;
PG_DECLARE(gpsConfig_t, gpsConfig);