From 8c9f034b9363361df99a6804ae949929e6a79cdf Mon Sep 17 00:00:00 2001 From: vk7js <58905135+vk7js@users.noreply.github.com> Date: Tue, 13 Sep 2022 22:59:08 +1000 Subject: [PATCH] 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. --- openrtx/src/ui/ui.c | 51 ++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/openrtx/src/ui/ui.c b/openrtx/src/ui/ui.c index af0a0f04..6f15f2f1 100644 --- a/openrtx/src/ui/ui.c +++ b/openrtx/src/ui/ui.c @@ -63,6 +63,7 @@ #include #include +#include #include #include #include @@ -1140,29 +1141,51 @@ static uint32_t vpGPSLastUpdate = 0; static vpGPSInfoFlags_t GetGPSDirectionOrSpeedChanged() { - uint32_t now = getTick(); - if (now - vpGPSLastUpdate < 10000) - return vpGPSNone; - vpGPSLastUpdate=now; - if (!state.settings.gps_enabled) return vpGPSNone; if (state.gps_data.fix_quality == 0 || state.gps_data.fix_quality >= 6) return vpGPSNone; + + uint32_t now = getTick(); + if (now - vpGPSLastUpdate < 10000) + return vpGPSNone; + + vpGPSLastUpdate=now; 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; + priorGPSSpeed = state.gps_data.speed; + } - if (state.gps_data.altitude != priorGPSAltitude) - whatChanged |= vpGPSAltitude; - - if (state.gps_data.tmg_true != priorGPSDirection) + float altitudeDiff = fabs(state.gps_data.altitude - priorGPSAltitude); + if (altitudeDiff >= 5) + { + whatChanged |= vpGPSAltitude; + priorGPSAltitude = state.gps_data.altitude; + } + + float degreeDiff = fabs(state.gps_data.tmg_true - priorGPSDirection); + if (degreeDiff >= 1) + { whatChanged |= vpGPSDirection; - - priorGPSSpeed = state.gps_data.speed; - priorGPSAltitude = state.gps_data.altitude; - priorGPSDirection = state.gps_data.tmg_true; + priorGPSDirection = state.gps_data.tmg_true; + } return whatChanged; }