From 8cff9a91fd3e590f9753e77d30522372c98e4bdf Mon Sep 17 00:00:00 2001 From: Richard Meadows Date: Wed, 22 Jul 2015 22:56:33 +0100 Subject: [PATCH] Pass lon/lat to geofence update functions as 100 nanodeg int32_t instead of float --- firmware/inc/location.h | 4 ++-- firmware/src/cron.c | 5 +---- firmware/src/location.c | 12 ++++++++++-- firmware/src/main.c | 5 +---- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/firmware/inc/location.h b/firmware/inc/location.h index fb46046..34741a7 100644 --- a/firmware/inc/location.h +++ b/firmware/inc/location.h @@ -29,11 +29,11 @@ #include "samd20.h" bool telemetry_location_tx_allow(void); -void telemetry_location_update(float lon, float lat); +void telemetry_location_update(int32_t lon_i, int32_t lat_i); bool latlon_in_aprs_zone(int32_t aprs_zone, int32_t aprs_zone_outline, float lon, float lat); bool aprs_location_tx_allow(void); int32_t aprs_location_frequency(void); -void aprs_location_update(float lon, float lat); +void aprs_location_update(int32_t lon_i, int32_t lat_i); #endif /* LOCATION_H */ diff --git a/firmware/src/cron.c b/firmware/src/cron.c index 075734f..6920cbe 100644 --- a/firmware/src/cron.c +++ b/firmware/src/cron.c @@ -158,10 +158,7 @@ void cron_telemetry(struct tracker_time* t, struct tracker_datapoint* dp) if (gps_is_locked()) { /* Don't bother with no GPS */ - float lat = (float)dp->latitude / 10000000.0; /* degrees */ - float lon = (float)dp->longitude / 10000000.0; /* degrees */ - - telemetry_location_update(lon, lat); + telemetry_location_update(dp->longitude, dp->latitude); } } } diff --git a/firmware/src/location.c b/firmware/src/location.c index 7afa8c3..8b79149 100644 --- a/firmware/src/location.c +++ b/firmware/src/location.c @@ -108,10 +108,14 @@ bool telemetry_location_tx_allow(void) } /** * Updates the current telemetry location based on the current lat/lon + * + * lat_i, lon_i in 100 nanodeg */ -void telemetry_location_update(float lon, float lat) +void telemetry_location_update(int32_t lon_i, int32_t lat_i) { uint32_t outline; + float lat = lat_i / 10000000.0; /* degrees */ + float lon = lon_i / 10000000.0; /* degrees */ /* Were we in a telemetry outline last time? */ if (current_no_telem_outline >= 0) { @@ -173,10 +177,14 @@ int32_t aprs_location_frequency(void) } /** * Updates the aprs location based on the current lat/lon + * + * lat_i, lon_i in 100 nanodeg */ -void aprs_location_update(float lon, float lat) +void aprs_location_update(int32_t lat_i, int32_t lon_i) { uint32_t z, outline; + float lat = lat_i / 10000000.0; /* degrees */ + float lon = lon_i / 10000000.0; /* degrees */ /* Were we in an aprs zone last time? */ if (current_aprs_zone >= 0 && current_aprs_zone_outline >= 0) { diff --git a/firmware/src/main.c b/firmware/src/main.c index 3c8fde1..a0b4afe 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -164,11 +164,8 @@ void aprs_telemetry(struct tracker_datapoint* dp) { if (!gps_is_locked()) return; /* Don't bother with no GPS */ - float lat = (float)dp->latitude / 10000000.0; /* degrees */ - float lon = (float)dp->longitude / 10000000.0; /* degrees */ - /* Update location */ - aprs_location_update(lon, lat); + aprs_location_update(dp->longitude, dp->latitude); #if APRS_USE_GEOFENCE /* aprs okay here? */