1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 16:55:36 +03:00

Use a function in gps.c to initate the posHold activity on new GPS data

This commit is contained in:
ctzsnooze 2024-10-18 23:50:24 +11:00
parent 4c9fa613ff
commit 9a80b75abe
3 changed files with 11 additions and 14 deletions

View file

@ -78,13 +78,10 @@ void posHoldUpdateTargetLocation(void)
}
}
void posHoldUpdate(timeUs_t currentTimeUs) {
UNUSED(currentTimeUs);
// check for enabling Alt Hold, otherwise do as little as possible while inactive
posHoldProcessTransitions();
void posHoldNewGpsData(void) {
if (posHold.isPosHoldRequested) {
posHoldUpdateTargetLocation();
if (getIsNewDataForPosHold() && posHold.posHoldIsOK) {
if (posHold.posHoldIsOK) {
posHold.posHoldIsOK = positionControl(posHold.useStickAdjustment, posHold.deadband);
}
} else {
@ -93,6 +90,12 @@ void posHoldUpdate(timeUs_t currentTimeUs) {
}
}
void posHoldUpdate(timeUs_t currentTimeUs) {
UNUSED(currentTimeUs);
// check for enabling Alt Hold, otherwise do as little as possible while inactive
posHoldProcessTransitions();
}
bool posHoldFailure(void) {
return (posHold.isPosHoldRequested && !posHold.posHoldIsOK);
}

View file

@ -93,7 +93,6 @@ GPS_svinfo_t GPS_svinfo[GPS_SV_MAXSATS_M8N];
static serialPort_t *gpsPort;
static float gpsDataIntervalSeconds;
static bool newDataForPosHold = false;
typedef struct gpsInitData_s {
uint8_t index;
@ -2613,13 +2612,9 @@ void onGpsNewData(void)
gpsLapTimerNewGpsData();
#endif // USE_GPS_LAP_TIMER
newDataForPosHold = true;
}
bool getIsNewDataForPosHold(void) {
bool currentState = newDataForPosHold; // true only when new data arrives
newDataForPosHold = false; // clear flag once new data has been handled
return currentState;
#ifdef USE_POS_HOLD
posHoldNewGpsData();
#endif
}
void gpsSetFixState(bool state)

View file

@ -392,6 +392,5 @@ void GPS_distance_cm_bearing(const gpsLocation_t *from, const gpsLocation_t *to,
void gpsSetFixState(bool state);
float getGpsDataIntervalSeconds(void); // sends GPS Nav Data interval to GPS Rescue
bool getIsNewDataForPosHold(void);
baudRate_e getGpsPortActualBaudRateIndex(void);