Adjusted sensitivity of auto announcement for GPS data. Now only announce for altitude changes of at least 5m, speed changes of at least 1 KM/h and direction changes of at least 1 degree.
This commit is contained in:
parent
7cc0c6455c
commit
8c9f034b93
|
|
@ -63,6 +63,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <math.h>
|
||||||
#include <ui.h>
|
#include <ui.h>
|
||||||
#include <rtx.h>
|
#include <rtx.h>
|
||||||
#include <interfaces/platform.h>
|
#include <interfaces/platform.h>
|
||||||
|
|
@ -1140,29 +1141,51 @@ static uint32_t vpGPSLastUpdate = 0;
|
||||||
|
|
||||||
static vpGPSInfoFlags_t GetGPSDirectionOrSpeedChanged()
|
static vpGPSInfoFlags_t GetGPSDirectionOrSpeedChanged()
|
||||||
{
|
{
|
||||||
uint32_t now = getTick();
|
|
||||||
if (now - vpGPSLastUpdate < 10000)
|
|
||||||
return vpGPSNone;
|
|
||||||
vpGPSLastUpdate=now;
|
|
||||||
|
|
||||||
if (!state.settings.gps_enabled)
|
if (!state.settings.gps_enabled)
|
||||||
return vpGPSNone;
|
return vpGPSNone;
|
||||||
if (state.gps_data.fix_quality == 0 || state.gps_data.fix_quality >= 6)
|
if (state.gps_data.fix_quality == 0 || state.gps_data.fix_quality >= 6)
|
||||||
return vpGPSNone;
|
return vpGPSNone;
|
||||||
|
|
||||||
|
uint32_t now = getTick();
|
||||||
|
if (now - vpGPSLastUpdate < 10000)
|
||||||
|
return vpGPSNone;
|
||||||
|
|
||||||
|
vpGPSLastUpdate=now;
|
||||||
|
|
||||||
vpGPSInfoFlags_t whatChanged= vpGPSNone;
|
vpGPSInfoFlags_t whatChanged= vpGPSNone;
|
||||||
if (state.gps_data.speed != priorGPSSpeed)
|
|
||||||
|
if (state.gps_data.fix_quality != priorGPSFixQuality)
|
||||||
|
{
|
||||||
|
whatChanged |= vpGPSFixQuality;
|
||||||
|
priorGPSFixQuality= state.gps_data.fix_quality;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.gps_data.fix_type != priorGPSFixType)
|
||||||
|
{
|
||||||
|
whatChanged |= vpGPSFixType;
|
||||||
|
priorGPSFixType = state.gps_data.fix_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
float speedDiff=fabs(state.gps_data.speed - priorGPSSpeed);
|
||||||
|
if (speedDiff >= 1)
|
||||||
|
{
|
||||||
whatChanged |= vpGPSSpeed;
|
whatChanged |= vpGPSSpeed;
|
||||||
|
priorGPSSpeed = state.gps_data.speed;
|
||||||
|
}
|
||||||
|
|
||||||
if (state.gps_data.altitude != priorGPSAltitude)
|
float altitudeDiff = fabs(state.gps_data.altitude - priorGPSAltitude);
|
||||||
whatChanged |= vpGPSAltitude;
|
if (altitudeDiff >= 5)
|
||||||
|
{
|
||||||
if (state.gps_data.tmg_true != priorGPSDirection)
|
whatChanged |= vpGPSAltitude;
|
||||||
|
priorGPSAltitude = state.gps_data.altitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
float degreeDiff = fabs(state.gps_data.tmg_true - priorGPSDirection);
|
||||||
|
if (degreeDiff >= 1)
|
||||||
|
{
|
||||||
whatChanged |= vpGPSDirection;
|
whatChanged |= vpGPSDirection;
|
||||||
|
priorGPSDirection = state.gps_data.tmg_true;
|
||||||
priorGPSSpeed = state.gps_data.speed;
|
}
|
||||||
priorGPSAltitude = state.gps_data.altitude;
|
|
||||||
priorGPSDirection = state.gps_data.tmg_true;
|
|
||||||
|
|
||||||
return whatChanged;
|
return whatChanged;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue