X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=ao-tools%2Faltosui%2FAltosEepromIterable.java;h=f8e6d7e5a2e16126755d4d7568be479d42445074;hp=d4ac3f3e14bedb8b5043af8bb26ae4f6bbc86333;hb=357826aa9c7b42c59f5d52b8eb016d73b6da0c7f;hpb=c89a34d1eb25155405b0036baeadc7bbfeade1c2 diff --git a/ao-tools/altosui/AltosEepromIterable.java b/ao-tools/altosui/AltosEepromIterable.java index d4ac3f3e..f8e6d7e5 100644 --- a/ao-tools/altosui/AltosEepromIterable.java +++ b/ao-tools/altosui/AltosEepromIterable.java @@ -28,14 +28,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.AltosRecord; -import altosui.AltosState; -import altosui.AltosDeviceDialog; -import altosui.AltosPreferences; -import altosui.AltosLog; -import altosui.AltosVoice; -import altosui.AltosEepromMonitor; - /* * AltosRecords with an index field so they can be sorted by tick while preserving * the original ordering for elements with matching ticks @@ -44,15 +36,19 @@ class AltosOrderedRecord extends AltosEepromRecord implements Comparable 0x8000) - new_tick += 0x10000; + if (prev_tick_valid) { + tick |= (prev_tick & ~0xffff); + if (tick < prev_tick) { + if (prev_tick - tick > 0x8000) + tick += 0x10000; + } else { + if (tick - prev_tick > 0x8000) + tick -= 0x10000; + } } - tick = new_tick; index = in_index; } @@ -313,6 +309,12 @@ public class AltosEepromIterable extends AltosRecordIterable { int flags = (good.b >> 8); int seconds = hour * 3600 + minute * 60 + second; + /* Make sure this looks like a good GPS value */ + if ((flags & Altos.AO_GPS_NUM_SAT_MASK) >> Altos.AO_GPS_NUM_SAT_SHIFT < 4) + flags = (flags & ~Altos.AO_GPS_NUM_SAT_MASK) | (4 << Altos.AO_GPS_NUM_SAT_SHIFT); + flags |= Altos.AO_GPS_RUNNING; + flags |= Altos.AO_GPS_VALID; + int new_seconds = seconds + diff; if (new_seconds < 0) new_seconds += 24 * 3600; @@ -340,7 +342,7 @@ public class AltosEepromIterable extends AltosRecordIterable { int index = 0; int prev_tick = 0; - + boolean prev_tick_valid = false; boolean missing_time = false; try { @@ -348,12 +350,14 @@ public class AltosEepromIterable extends AltosRecordIterable { String line = AltosRecord.gets(input); if (line == null) break; - AltosOrderedRecord record = new AltosOrderedRecord(line, index++, prev_tick); + AltosOrderedRecord record = new AltosOrderedRecord(line, index++, prev_tick, prev_tick_valid); if (record == null) break; if (record.cmd == Altos.AO_LOG_INVALID) continue; prev_tick = record.tick; + if (record.cmd < Altos.AO_LOG_CONFIG_VERSION) + prev_tick_valid = true; if (record.cmd == Altos.AO_LOG_FLIGHT) { flight_record = record; continue;