summaryrefslogtreecommitdiff
path: root/altoslib/AltosEepromIterable.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-06-11 18:48:11 -0700
committerKeith Packard <keithp@keithp.com>2014-06-11 18:48:11 -0700
commita8325483adb8d9ffda62d3f4900cf52bde70ff62 (patch)
treec567d87873a137cad9feecfc5b86cdda964062f8 /altoslib/AltosEepromIterable.java
parentdb2443fdbf65b65703217174303027c439124a83 (diff)
altoslib: Use GPS seconds as an additional sort key for TeleGPS eeprom
Long idle periods with TeleGPS can easily overflow 16 bits of tick count. Using the GPS seconds provides an additional sort which will span the tick wrap-around. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosEepromIterable.java')
-rw-r--r--altoslib/AltosEepromIterable.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/altoslib/AltosEepromIterable.java b/altoslib/AltosEepromIterable.java
index 415c5b62..d6832c1b 100644
--- a/altoslib/AltosEepromIterable.java
+++ b/altoslib/AltosEepromIterable.java
@@ -38,6 +38,13 @@ class AltosEepromOrdered implements Comparable<AltosEepromOrdered> {
if (cmd_diff != 0)
return cmd_diff;
+ if (eeprom.has_seconds() && o.eeprom.has_seconds()) {
+ int seconds_diff = eeprom.seconds() - o.eeprom.seconds();
+
+ if (seconds_diff != 0)
+ return seconds_diff;
+ }
+
int tick_diff = tick - o.tick;
if (tick_diff != 0)
@@ -116,4 +123,4 @@ public class AltosEepromIterable implements Iterable<AltosEeprom> {
eeproms = new LinkedList<AltosEeprom>();
return new AltosEepromOrderedIterator(eeproms);
}
-} \ No newline at end of file
+}