altos: re-write a bit of GPS parsing code to reduce size
authorKeith Packard <keithp@keithp.com>
Sun, 14 Aug 2011 01:28:38 +0000 (18:28 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 14 Aug 2011 01:44:26 +0000 (18:44 -0700)
Use a local variable while computing hdop.
Place the next incoming character in data instead of pdata.

Saved a surprising amount of memory.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao_gps_skytraq.c

index e7d1d2ef63d152da2ac55d37108317af5a2a7cbd..7ac269469d31c2bc90c42c6d92c0c9b5adb4b95e 100644 (file)
@@ -24,7 +24,7 @@
 static __code char ao_gps_header[] = "GP";
 
 __xdata uint8_t ao_gps_mutex;
-static __pdata char ao_gps_char;
+static __data char ao_gps_char;
 static __pdata uint8_t ao_gps_cksum;
 static __pdata uint8_t ao_gps_error;
 
@@ -238,14 +238,14 @@ ao_nmea_gga()
        ao_gps_next.flags |= i;
 
        ao_gps_lexchar();
-       ao_gps_next.hdop = ao_gps_decimal(0xff);
-       if (ao_gps_next.hdop <= 50) {
-               ao_gps_next.hdop = (uint8_t) 5 * ao_gps_next.hdop;
+       i = ao_gps_decimal(0xff);
+       if (i <= 50) {
+               i = (uint8_t) 5 * i;
                if (ao_gps_char == '.')
-                       ao_gps_next.hdop = (ao_gps_next.hdop +
-                                           ((uint8_t) ao_gps_decimal(1) >> 1));
+                       i = (i + ((uint8_t) ao_gps_decimal(1) >> 1));
        } else
-               ao_gps_next.hdop = 255;
+               i = 255;
+       ao_gps_next.hdop = i;
        ao_gps_skip_field();
 
        ao_gps_next.altitude = ao_gps_decimal(0xff);