mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 22:35:23 +03:00
wait for altitude offset to be applied before updating idleTask data
This commit is contained in:
parent
babebe32f2
commit
911c8e406c
3 changed files with 12 additions and 1 deletions
|
@ -303,6 +303,11 @@ void idleTasks()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't update any rescue flight statistics if we haven't applied a proper altitude offset yet
|
||||||
|
if (!isAltitudeOffset()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gpsRescueAngle[AI_PITCH] = 0;
|
gpsRescueAngle[AI_PITCH] = 0;
|
||||||
gpsRescueAngle[AI_ROLL] = 0;
|
gpsRescueAngle[AI_ROLL] = 0;
|
||||||
|
|
||||||
|
|
|
@ -44,12 +44,13 @@ static int32_t estimatedAltitude = 0; // in cm
|
||||||
|
|
||||||
|
|
||||||
#if defined(USE_BARO) || defined(USE_GPS)
|
#if defined(USE_BARO) || defined(USE_GPS)
|
||||||
|
static bool altitudeOffsetSet = false;
|
||||||
|
|
||||||
void calculateEstimatedAltitude(timeUs_t currentTimeUs)
|
void calculateEstimatedAltitude(timeUs_t currentTimeUs)
|
||||||
{
|
{
|
||||||
static timeUs_t previousTimeUs = 0;
|
static timeUs_t previousTimeUs = 0;
|
||||||
static int32_t baroAltOffset = 0;
|
static int32_t baroAltOffset = 0;
|
||||||
static int32_t gpsAltOffset = 0;
|
static int32_t gpsAltOffset = 0;
|
||||||
static bool altitudeOffsetSet = false;
|
|
||||||
|
|
||||||
const uint32_t dTime = currentTimeUs - previousTimeUs;
|
const uint32_t dTime = currentTimeUs - previousTimeUs;
|
||||||
if (dTime < BARO_UPDATE_FREQUENCY_40HZ) {
|
if (dTime < BARO_UPDATE_FREQUENCY_40HZ) {
|
||||||
|
@ -111,6 +112,10 @@ if (sensors(SENSOR_GPS) && STATE(GPS_FIX)) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool isAltitudeOffset(void)
|
||||||
|
{
|
||||||
|
return altitudeOffsetSet;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t getEstimatedAltitude(void)
|
int32_t getEstimatedAltitude(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include "common/time.h"
|
#include "common/time.h"
|
||||||
|
|
||||||
|
bool isAltitudeOffset(void);
|
||||||
void calculateEstimatedAltitude(timeUs_t currentTimeUs);
|
void calculateEstimatedAltitude(timeUs_t currentTimeUs);
|
||||||
int32_t getEstimatedAltitude(void);
|
int32_t getEstimatedAltitude(void);
|
||||||
int16_t getEstimatedVario(void);
|
int16_t getEstimatedVario(void);
|
Loading…
Add table
Add a link
Reference in a new issue