From 2bf7ea227101284ce58e1c916ab1205c554ff8aa Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sat, 23 Apr 2011 16:49:07 +0200 Subject: [PATCH] Modules/GPS: Make code to deal with home location optional to allow a sleeker GPS module for RAM challenged systems --- flight/Modules/GPS/GPS.c | 21 ++++++++++++++++++--- flight/OpenPilot/System/inc/pios_config.h | 3 +++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/flight/Modules/GPS/GPS.c b/flight/Modules/GPS/GPS.c index 7878e90dd..d649de994 100644 --- a/flight/Modules/GPS/GPS.c +++ b/flight/Modules/GPS/GPS.c @@ -53,8 +53,11 @@ // Private functions static void gpsTask(void *parameters); + +#ifdef PIOS_GPS_SETS_HOMELOCATION static void setHomeLocation(GPSPositionData * gpsData); static float GravityAccel(float latitude, float longitude, float altitude); +#endif // **************** // Private constants @@ -65,11 +68,19 @@ static float GravityAccel(float latitude, float longitude, float altitude); #define GPS_TIMEOUT_MS 500 #define GPS_COMMAND_RESEND_TIMEOUT_MS 2000 +#ifdef PIOS_GPS_SETS_HOMELOCATION // Unfortunately need a good size stack for the WMM calculation -#ifdef ENABLE_GPS_BINARY_GTOP - #define STACK_SIZE_BYTES 800 + #ifdef ENABLE_GPS_BINARY_GTOP + #define STACK_SIZE_BYTES 800 + #else + #define STACK_SIZE_BYTES 800 + #endif #else - #define STACK_SIZE_BYTES 800 + #ifdef ENABLE_GPS_BINARY_GTOP + #define STACK_SIZE_BYTES 440 + #else + #define STACK_SIZE_BYTES 440 + #endif #endif #define TASK_PRIORITY (tskIDLE_PRIORITY + 1) @@ -311,12 +322,14 @@ static void gpsTask(void *parameters) else { // we appear to be receiving GPS sentences OK, we've had an update +#ifdef PIOS_GPS_SETS_HOMELOCATION HomeLocationData home; HomeLocationGet(&home); GPSPositionGet(&GpsData); if ((GpsData.Status == GPSPOSITION_STATUS_FIX3D) && (home.Set == HOMELOCATION_SET_FALSE)) setHomeLocation(&GpsData); +#endif //criteria for GPS-OK taken from this post... //http://forums.openpilot.org/topic/1523-professors-insgps-in-svn/page__view__findpost__p__5220 @@ -334,6 +347,7 @@ static void gpsTask(void *parameters) } } +#ifdef PIOS_GPS_SETS_HOMELOCATION /* * Estimate the acceleration due to gravity for a particular location in LLA */ @@ -389,6 +403,7 @@ static void setHomeLocation(GPSPositionData * gpsData) } } } +#endif // **************** diff --git a/flight/OpenPilot/System/inc/pios_config.h b/flight/OpenPilot/System/inc/pios_config.h index 3f4b1e706..454da36d7 100644 --- a/flight/OpenPilot/System/inc/pios_config.h +++ b/flight/OpenPilot/System/inc/pios_config.h @@ -89,6 +89,9 @@ /* Stabilization options */ #define PIOS_QUATERNION_STABILIZATION +/* GPS options */ +#define PIOS_GPS_SETS_HOMELOCATION + #endif /* PIOS_CONFIG_H */ /**