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

Bugfix: Vario GPS and 3D Total Distance overflow

This commit is contained in:
Tony Cabello 2019-09-05 09:30:56 +02:00
parent 2553a4a1f9
commit 1406b068e2

View file

@ -1281,7 +1281,7 @@ void GPS_calc_longitude_scaling(int32_t lat)
static void GPS_calculateDistanceFlownVerticalSpeed(bool initialize)
{
static int32_t lastCoord[2] = { 0, 0 };
static int16_t lastAlt;
static int32_t lastAlt;
static int32_t lastMillis;
int currentMillis = millis();
@ -1303,9 +1303,8 @@ static void GPS_calculateDistanceFlownVerticalSpeed(bool initialize)
GPS_distanceFlownInCm += dist;
}
}
GPS_verticalSpeedInCmS = (gpsSol.llh.altCm - lastAlt) * 1000 / (currentMillis - lastMillis);
GPS_verticalSpeedInCmS = constrain(GPS_verticalSpeedInCmS, -1500.0f, 1500.0f);
GPS_verticalSpeedInCmS = constrain(GPS_verticalSpeedInCmS, -1500, 1500);
}
lastCoord[LON] = gpsSol.llh.lon;
lastCoord[LAT] = gpsSol.llh.lat;