From f0216d721ed13f4d3dc608bb6ad8f83732b27c0a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 25 May 2014 21:01:38 -0700 Subject: altoslib/altosuilib: Change versions to altoslib:4, altosuilib:2 API has changed for these libraries, time to bump the file versions Signed-off-by: Keith Packard --- altoslib/AltosEepromIterable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib/AltosEepromIterable.java') diff --git a/altoslib/AltosEepromIterable.java b/altoslib/AltosEepromIterable.java index 081721b3..415c5b62 100644 --- a/altoslib/AltosEepromIterable.java +++ b/altoslib/AltosEepromIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; -- cgit v1.2.3 From a8325483adb8d9ffda62d3f4900cf52bde70ff62 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 11 Jun 2014 18:48:11 -0700 Subject: 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 --- altoslib/AltosEeprom.java | 4 ++++ altoslib/AltosEepromGPS.java | 11 +++++++++++ altoslib/AltosEepromIterable.java | 9 ++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'altoslib/AltosEepromIterable.java') diff --git a/altoslib/AltosEeprom.java b/altoslib/AltosEeprom.java index be18ba24..020590eb 100644 --- a/altoslib/AltosEeprom.java +++ b/altoslib/AltosEeprom.java @@ -43,6 +43,10 @@ public abstract class AltosEeprom implements AltosStateUpdate { return data8[i] | (data8[i+1] << 8) | (data8[i+2] << 16) | (data8[i+3] << 24); } + public boolean has_seconds() { return false; } + + public int seconds() { return 0; } + public final static int header_length = 4; public abstract int record_length(); diff --git a/altoslib/AltosEepromGPS.java b/altoslib/AltosEepromGPS.java index 1820cd61..3c1852c0 100644 --- a/altoslib/AltosEepromGPS.java +++ b/altoslib/AltosEepromGPS.java @@ -53,6 +53,17 @@ public class AltosEepromGPS extends AltosEeprom { public int vdop() { return data8(24); } public int mode() { return data8(25); } + public boolean has_seconds() { return cmd == AltosLib.AO_LOG_GPS_TIME; } + + public int seconds() { + switch (cmd) { + case AltosLib.AO_LOG_GPS_TIME: + return second() + 60 * (minute() + 60 * (hour() + 24 * (day() + 31 * month()))); + default: + return 0; + } + } + public AltosEepromGPS (AltosEepromChunk chunk, int start) throws ParseException { parse_chunk(chunk, start); } 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 { 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 { eeproms = new LinkedList(); return new AltosEepromOrderedIterator(eeproms); } -} \ No newline at end of file +} -- cgit v1.2.3