From 8462adb579ac40b1191a9683805bf8e7da6f21a9 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Wed, 7 May 2014 20:20:19 +0200 Subject: [PATCH] OP-1330 Delay SetHomeLocation call from GPS module to be able to save HomeLocation.Set=false --- flight/modules/GPS/GPS.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/flight/modules/GPS/GPS.c b/flight/modules/GPS/GPS.c index 420f9599c..402c1d55e 100644 --- a/flight/modules/GPS/GPS.c +++ b/flight/modules/GPS/GPS.c @@ -64,7 +64,10 @@ static float GravityAccel(float latitude, float longitude, float altitude); // Private constants #define GPS_TIMEOUT_MS 500 - +// delay from detecting HomeLocation.Set == False before setting new homelocation +// this prevent that a save with homelocation.Set = false triggered by gps ends saving +// the new location with Set = true. +#define HOMELOCATIONSETDELAY 5000 #ifdef PIOS_GPS_SETS_HOMELOCATION // Unfortunately need a good size stack for the WMM calculation @@ -199,7 +202,7 @@ static void gpsTask(__attribute__((unused)) void *parameters) { portTickType xDelay = 100 / portTICK_RATE_MS; uint32_t timeNowMs = xTaskGetTickCount() * portTICK_RATE_MS; - + portTickType homelocationSetDelay = 0; GPSPositionSensorData gpspositionsensor; GPSSettingsData gpsSettings; @@ -260,7 +263,13 @@ static void gpsTask(__attribute__((unused)) void *parameters) HomeLocationGet(&home); if (home.Set == HOMELOCATION_SET_FALSE) { - setHomeLocation(&gpspositionsensor); + if(homelocationSetDelay == 0){ + homelocationSetDelay = xTaskGetTickCount(); + } + if(xTaskGetTickCount() - homelocationSetDelay > HOMELOCATIONSETDELAY){ + setHomeLocation(&gpspositionsensor); + homelocationSetDelay = 0; + } } #endif } else if ((gpspositionsensor.Status == GPSPOSITIONSENSOR_STATUS_FIX3D) &&