mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 22:35:23 +03:00
Merge pull request #7369 from TonyBlit/gps_set_home_once
Parameter for updating GPS Home point once
This commit is contained in:
commit
9b43b30b48
3 changed files with 14 additions and 9 deletions
|
@ -838,6 +838,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_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_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_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
|
#ifdef USE_GPS_RESCUE
|
||||||
// PG_GPS_RESCUE
|
// PG_GPS_RESCUE
|
||||||
|
|
|
@ -244,7 +244,8 @@ PG_RESET_TEMPLATE(gpsConfig_t, gpsConfig,
|
||||||
.sbasMode = SBAS_AUTO,
|
.sbasMode = SBAS_AUTO,
|
||||||
.autoConfig = GPS_AUTOCONFIG_ON,
|
.autoConfig = GPS_AUTOCONFIG_ON,
|
||||||
.autoBaud = GPS_AUTOBAUD_OFF,
|
.autoBaud = GPS_AUTOBAUD_OFF,
|
||||||
.gps_ublox_use_galileo = false
|
.gps_ublox_use_galileo = false,
|
||||||
|
.gps_set_home_point_once = false
|
||||||
);
|
);
|
||||||
|
|
||||||
static void shiftPacketLog(void)
|
static void shiftPacketLog(void)
|
||||||
|
@ -547,7 +548,7 @@ void gpsUpdate(timeUs_t currentTimeUs)
|
||||||
if (sensors(SENSOR_GPS)) {
|
if (sensors(SENSOR_GPS)) {
|
||||||
updateGpsIndicator(currentTimeUs);
|
updateGpsIndicator(currentTimeUs);
|
||||||
}
|
}
|
||||||
if (!ARMING_FLAG(ARMED)) {
|
if (!ARMING_FLAG(ARMED) && !gpsConfig()->gps_set_home_point_once) {
|
||||||
DISABLE_STATE(GPS_FIX_HOME);
|
DISABLE_STATE(GPS_FIX_HOME);
|
||||||
}
|
}
|
||||||
#if defined(USE_GPS_RESCUE)
|
#if defined(USE_GPS_RESCUE)
|
||||||
|
@ -1286,7 +1287,7 @@ static void GPS_calculateDistanceFlownVerticalSpeed(bool initialize)
|
||||||
GPS_distanceFlownInCm = 0;
|
GPS_distanceFlownInCm = 0;
|
||||||
GPS_verticalSpeedInCmS = 0;
|
GPS_verticalSpeedInCmS = 0;
|
||||||
} else {
|
} 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
|
// Only add up movement when speed is faster than minimum threshold
|
||||||
if (gpsSol.groundSpeed > GPS_DISTANCE_FLOWN_MIN_GROUND_SPEED_THRESHOLD_CM_S) {
|
if (gpsSol.groundSpeed > GPS_DISTANCE_FLOWN_MIN_GROUND_SPEED_THRESHOLD_CM_S) {
|
||||||
uint32_t dist;
|
uint32_t dist;
|
||||||
|
@ -1307,12 +1308,14 @@ static void GPS_calculateDistanceFlownVerticalSpeed(bool initialize)
|
||||||
|
|
||||||
void GPS_reset_home_position(void)
|
void GPS_reset_home_position(void)
|
||||||
{
|
{
|
||||||
if (STATE(GPS_FIX) && gpsSol.numSat >= 5) {
|
if (!STATE(GPS_FIX_HOME) || !gpsConfig()->gps_set_home_point_once) {
|
||||||
GPS_home[LAT] = gpsSol.llh.lat;
|
if (STATE(GPS_FIX) && gpsSol.numSat >= 5) {
|
||||||
GPS_home[LON] = gpsSol.llh.lon;
|
GPS_home[LAT] = gpsSol.llh.lat;
|
||||||
GPS_calc_longitude_scaling(gpsSol.llh.lat); // need an initial value for distance and bearing calc
|
GPS_home[LON] = gpsSol.llh.lon;
|
||||||
// Set ground altitude
|
GPS_calc_longitude_scaling(gpsSol.llh.lat); // need an initial value for distance and bearing calc
|
||||||
ENABLE_STATE(GPS_FIX_HOME);
|
// Set ground altitude
|
||||||
|
ENABLE_STATE(GPS_FIX_HOME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
GPS_calculateDistanceFlownVerticalSpeed(true); //Initialize
|
GPS_calculateDistanceFlownVerticalSpeed(true); //Initialize
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ typedef struct gpsConfig_s {
|
||||||
gpsAutoConfig_e autoConfig;
|
gpsAutoConfig_e autoConfig;
|
||||||
gpsAutoBaud_e autoBaud;
|
gpsAutoBaud_e autoBaud;
|
||||||
uint8_t gps_ublox_use_galileo;
|
uint8_t gps_ublox_use_galileo;
|
||||||
|
uint8_t gps_set_home_point_once;
|
||||||
} gpsConfig_t;
|
} gpsConfig_t;
|
||||||
|
|
||||||
PG_DECLARE(gpsConfig_t, gpsConfig);
|
PG_DECLARE(gpsConfig_t, gpsConfig);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue