summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-10-27 00:49:23 -0700
committerKeith Packard <keithp@keithp.com>2011-10-27 00:49:23 -0700
commit0669f0d74fc24c4f1925a45a9975b7a49a65b692 (patch)
tree5b2bef044755a081f1edce5fd27f31edb2f8ab88
parentc7e14a2750d437e8b77d68a944a0711e7a0c882b (diff)
altosui: Only update GPS data when new GPS information arrives
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>
-rw-r--r--altosui/AltosEepromIterable.java1
-rw-r--r--altosui/AltosRecord.java3
-rw-r--r--altosui/AltosState.java2
-rw-r--r--altosui/AltosTelemetryRecordLegacy.java6
-rw-r--r--altosui/AltosTelemetryRecordLocation.java1
5 files changed, 11 insertions, 2 deletions
diff --git a/altosui/AltosEepromIterable.java b/altosui/AltosEepromIterable.java
index 812e5fc6..d8205816 100644
--- a/altosui/AltosEepromIterable.java
+++ b/altosui/AltosEepromIterable.java
@@ -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:
diff --git a/altosui/AltosRecord.java b/altosui/AltosRecord.java
index 486c96b2..4dfa98be 100644
--- a/altosui/AltosRecord.java
+++ b/altosui/AltosRecord.java
@@ -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;
}
}
diff --git a/altosui/AltosState.java b/altosui/AltosState.java
index 3d8e5e12..da498bc1 100644
--- a/altosui/AltosState.java
+++ b/altosui/AltosState.java
@@ -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)
diff --git a/altosui/AltosTelemetryRecordLegacy.java b/altosui/AltosTelemetryRecordLegacy.java
index f59027ab..f2f63358 100644
--- a/altosui/AltosTelemetryRecordLegacy.java
+++ b/altosui/AltosTelemetryRecordLegacy.java
@@ -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);
diff --git a/altosui/AltosTelemetryRecordLocation.java b/altosui/AltosTelemetryRecordLocation.java
index 76bd106e..80db454d 100644
--- a/altosui/AltosTelemetryRecordLocation.java
+++ b/altosui/AltosTelemetryRecordLocation.java
@@ -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;