X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosui%2FAltosTelemetryIterable.java;h=a1b253321fde593eb2f11238b1f7e420ca7f6f41;hb=da2c920b9f3378d5a18551e008c1da5dace1e0ef;hp=1a31b3652e23745c6b2b41a4068c613c6fdf4cd1;hpb=481577a29380afe6750ef7c4e928daff837cbc49;p=fw%2Faltos diff --git a/altosui/AltosTelemetryIterable.java b/altosui/AltosTelemetryIterable.java index 1a31b365..a1b25332 100644 --- a/altosui/AltosTelemetryIterable.java +++ b/altosui/AltosTelemetryIterable.java @@ -22,7 +22,7 @@ import java.util.*; import java.text.*; public class AltosTelemetryIterable extends AltosRecordIterable { - LinkedList records; + TreeSet records; public Iterator iterator () { return records.iterator(); @@ -41,7 +41,7 @@ public class AltosTelemetryIterable extends AltosRecordIterable { int boost_tick = 0; AltosRecord previous = null; - records = new LinkedList (); + records = new TreeSet (); try { for (;;) { @@ -56,8 +56,8 @@ public class AltosTelemetryIterable extends AltosRecordIterable { if (records.isEmpty()) { current_tick = record.tick; } else { - int tick = record.tick | (current_tick & ~ 0xffff); - if (tick < current_tick - 0x1000) + int tick = record.tick; + while (tick < current_tick - 0x1000) tick += 0x10000; current_tick = tick; record.tick = current_tick; @@ -88,6 +88,15 @@ public class AltosTelemetryIterable extends AltosRecordIterable { if (previous != null) records.add(previous); + /* Adjust all tick counts to match expected eeprom values, + * which starts with a 16-bit tick count 16 samples before boost + */ + + int tick_adjust = (boost_tick - 16) & 0xffff0000; + for (AltosRecord r : this) + r.tick -= tick_adjust; + boost_tick -= tick_adjust; + /* adjust all tick counts to be relative to boost time */ for (AltosRecord r : this) r.time = (r.tick - boost_tick) / 100.0;