altoslib: Handle eeprom tick wrapping
authorKeith Packard <keithp@keithp.com>
Sun, 28 May 2017 21:33:28 +0000 (14:33 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 28 May 2017 21:33:28 +0000 (14:33 -0700)
Need to deal with eeprom files with tick values that cross the 16-bit
barrier.
Use 'wide_tick' to order eeprom record.
Remeber 'prev_tick' to order cal data time sequence.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosCalData.java
altoslib/AltosEepromRecord.java
altoslib/AltosEepromRecordSet.java

index 960de30..54b7581 100644 (file)
@@ -172,6 +172,7 @@ public class AltosCalData {
                                        tick += 65536;
                                }
                        }
+                       prev_tick = tick;
                        this.tick = tick;
                }
        }
index 7a0cc8f..75fe538 100644 (file)
@@ -74,7 +74,7 @@ public abstract class AltosEepromRecord implements Comparable<AltosEepromRecord>
                if (cmd_diff != 0)
                        return cmd_diff;
 
-               int     tick_diff = tick() - o.tick();
+               int     tick_diff = wide_tick - o.wide_tick;
 
                if (tick_diff != 0)
                        return tick_diff;
index 0c60c1a..c019a09 100644 (file)
@@ -33,6 +33,7 @@ public class AltosEepromRecordSet implements AltosRecordSet {
                                if (record.cmd() == AltosLib.AO_LOG_FLIGHT) {
                                        cal_data.set_tick(record.tick());
                                        cal_data.set_boost_tick();
+                                       break;
                                }
                        }
                }