altosui: Only update GPS data when new GPS information arrives
authorKeith Packard <keithp@keithp.com>
Thu, 27 Oct 2011 07:49:23 +0000 (00:49 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 27 Oct 2011 07:49:23 +0000 (00:49 -0700)
Track which telemetry packets are actually producing new GPS
information and only update the GPS average position and count of
stable GPS reports with new GPS info, instead of on every telemetry packet.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosEepromIterable.java
altosui/AltosRecord.java
altosui/AltosState.java
altosui/AltosTelemetryRecordLegacy.java
altosui/AltosTelemetryRecordLocation.java

index 812e5fc616ff03a2ac863b9dd01114fc1a12602f..d8205816b2674bffa20f7934b7a421505c6f8e8b 100644 (file)
@@ -177,6 +177,7 @@ public class AltosEepromIterable extends AltosRecordIterable {
                        state.gps.locked = (flags & Altos.AO_GPS_VALID) != 0;
                        state.gps.nsat = (flags & Altos.AO_GPS_NUM_SAT_MASK) >>
                                Altos.AO_GPS_NUM_SAT_SHIFT;
+                       state.new_gps = true;
                        has_gps = true;
                        break;
                case Altos.AO_LOG_GPS_LAT:
index 486c96b2e232d93e7f30fc29e210d02c4dd69a3f..4dfa98be41c70619163d92acba1c631b409ced3f 100644 (file)
@@ -65,6 +65,7 @@ public class AltosRecord implements Comparable <AltosRecord> {
        int     flight_pres;
 
        AltosGPS        gps;
+       boolean         new_gps;
 
        double  time;   /* seconds since boost */
 
@@ -274,6 +275,7 @@ public class AltosRecord implements Comparable <AltosRecord> {
                speed = old.speed;
                height = old.height;
                gps = new AltosGPS(old.gps);
+               new_gps = false;
                companion = old.companion;
        }
 
@@ -304,6 +306,7 @@ public class AltosRecord implements Comparable <AltosRecord> {
                speed = MISSING;
                height = MISSING;
                gps = new AltosGPS();
+               new_gps = false;
                companion = null;
        }
 }
index 3d8e5e120d184d178e8295d0049ef5c51607bc4a..da498bc1d3b12f7a46709547249e07808cf1357a 100644 (file)
@@ -135,7 +135,7 @@ public class AltosState {
 
                time = tick / 100.0;
 
-               if (state == Altos.ao_flight_pad || state == Altos.ao_flight_idle) {
+               if (cur.new_gps && (state == Altos.ao_flight_pad || state == Altos.ao_flight_idle)) {
 
                        /* Track consecutive 'good' gps reports, waiting for 10 of them */
                        if (data.gps != null && data.gps.locked && data.gps.nsat >= 4)
index f59027ab3ace0db644bbd34f50231d409d440af8..f2f633581922944a89a84fa8405f993ab6822d35 100644 (file)
@@ -265,8 +265,10 @@ public class AltosTelemetryRecordLegacy extends AltosRecord implements AltosTele
                flight_vel = map.get_int(AO_TELEM_ADHOC_SPEED, MISSING);
                flight_pres = map.get_int(AO_TELEM_ADHOC_BARO, MISSING);
 
-               if (map.has(AO_TELEM_GPS_STATE))
+               if (map.has(AO_TELEM_GPS_STATE)) {
                        gps = new AltosGPS(map);
+                       new_gps = true;
+               }
                else
                        gps = null;
        }
@@ -355,6 +357,7 @@ public class AltosTelemetryRecordLegacy extends AltosRecord implements AltosTele
                }
 
                gps = new AltosGPS(words, i, version);
+               new_gps = true;
        }
 
        public AltosTelemetryRecordLegacy(String line) throws ParseException, AltosCRCException {
@@ -467,6 +470,7 @@ public class AltosTelemetryRecordLegacy extends AltosRecord implements AltosTele
 
                if ((gps_flags & (AO_GPS_VALID|AO_GPS_RUNNING)) != 0) {
                        gps = new AltosGPS();
+                       new_gps = true;
 
                        seen |= seen_gps_time | seen_gps_lat | seen_gps_lon;
                        gps.nsat = (gps_flags & AO_GPS_NUM_SAT_MASK);
index 76bd106e330d07538be623847e206e25c5fa80c1..80db454de5af1357d8117373de7a160a188a90dc 100644 (file)
@@ -85,6 +85,7 @@ public class AltosTelemetryRecordLocation extends AltosTelemetryRecordRaw {
                        next.gps.hdop = hdop;
                        next.gps.vdop = vdop;
                        next.seen |= AltosRecord.seen_gps_time | AltosRecord.seen_gps_lat | AltosRecord.seen_gps_lon;
+                       next.new_gps = true;
                }
 
                return next;