From 8462adb579ac40b1191a9683805bf8e7da6f21a9 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Wed, 7 May 2014 20:20:19 +0200 Subject: [PATCH 1/4] 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) && From 45efaffcf19277ed883f995583688a8fdf23723d Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Sun, 11 May 2014 11:38:08 +0200 Subject: [PATCH 2/4] OP-1330 fix namings/uncrustify --- flight/modules/GPS/GPS.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/flight/modules/GPS/GPS.c b/flight/modules/GPS/GPS.c index 402c1d55e..b20aba170 100644 --- a/flight/modules/GPS/GPS.c +++ b/flight/modules/GPS/GPS.c @@ -63,24 +63,24 @@ static float GravityAccel(float latitude, float longitude, float altitude); // **************** // Private constants -#define GPS_TIMEOUT_MS 500 +#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 +#define GPS_HOMELOCATION_SET_DELAY 5000 #ifdef PIOS_GPS_SETS_HOMELOCATION // Unfortunately need a good size stack for the WMM calculation - #define STACK_SIZE_BYTES 1024 + #define STACK_SIZE_BYTES 1024 #else #if defined(PIOS_GPS_MINIMAL) - #define STACK_SIZE_BYTES 500 + #define STACK_SIZE_BYTES 500 #else - #define STACK_SIZE_BYTES 650 + #define STACK_SIZE_BYTES 650 #endif // PIOS_GPS_MINIMAL #endif // PIOS_GPS_SETS_HOMELOCATION -#define TASK_PRIORITY (tskIDLE_PRIORITY + 1) +#define TASK_PRIORITY (tskIDLE_PRIORITY + 1) // **************** // Private variables @@ -263,13 +263,13 @@ static void gpsTask(__attribute__((unused)) void *parameters) HomeLocationGet(&home); if (home.Set == HOMELOCATION_SET_FALSE) { - if(homelocationSetDelay == 0){ - homelocationSetDelay = xTaskGetTickCount(); - } - if(xTaskGetTickCount() - homelocationSetDelay > HOMELOCATIONSETDELAY){ - setHomeLocation(&gpspositionsensor); - homelocationSetDelay = 0; - } + if (homelocationSetDelay == 0) { + homelocationSetDelay = xTaskGetTickCount(); + } + if (xTaskGetTickCount() - homelocationSetDelay > GPS_HOMELOCATION_SET_DELAY) { + setHomeLocation(&gpspositionsensor); + homelocationSetDelay = 0; + } } #endif } else if ((gpspositionsensor.Status == GPSPOSITIONSENSOR_STATUS_FIX3D) && From 953b7cc2a7039834f6118ca310e7c0a6124fef37 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Sun, 11 May 2014 12:37:20 +0200 Subject: [PATCH 3/4] OP-1330 Fix a compilation issue with CC/CC3D --- flight/modules/GPS/GPS.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flight/modules/GPS/GPS.c b/flight/modules/GPS/GPS.c index b20aba170..0a2dbc3b0 100644 --- a/flight/modules/GPS/GPS.c +++ b/flight/modules/GPS/GPS.c @@ -202,7 +202,9 @@ static void gpsTask(__attribute__((unused)) void *parameters) { portTickType xDelay = 100 / portTICK_RATE_MS; uint32_t timeNowMs = xTaskGetTickCount() * portTICK_RATE_MS; +#ifdef PIOS_GPS_SETS_HOMELOCATION portTickType homelocationSetDelay = 0; +#endif GPSPositionSensorData gpspositionsensor; GPSSettingsData gpsSettings; From 47976312c29720a02e391d7554e1b6daff30f5d7 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Mon, 12 May 2014 22:56:28 +0200 Subject: [PATCH 4/4] OP-1330 reset Home Set delay timer if Set==true --- flight/modules/GPS/GPS.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flight/modules/GPS/GPS.c b/flight/modules/GPS/GPS.c index 0a2dbc3b0..bdbad1f69 100644 --- a/flight/modules/GPS/GPS.c +++ b/flight/modules/GPS/GPS.c @@ -202,6 +202,7 @@ static void gpsTask(__attribute__((unused)) void *parameters) { portTickType xDelay = 100 / portTICK_RATE_MS; uint32_t timeNowMs = xTaskGetTickCount() * portTICK_RATE_MS; + #ifdef PIOS_GPS_SETS_HOMELOCATION portTickType homelocationSetDelay = 0; #endif @@ -272,6 +273,8 @@ static void gpsTask(__attribute__((unused)) void *parameters) setHomeLocation(&gpspositionsensor); homelocationSetDelay = 0; } + } else { + homelocationSetDelay = 0; } #endif } else if ((gpspositionsensor.Status == GPSPOSITIONSENSOR_STATUS_FIX3D) &&