If the tick count wraps just as boost is detected, there may be some
data records on the device with large tick values which are recorded
after the AO_FLIGHT record. Check for these in two places which manage
16-bit tick values by wrapping tick values to negative numbers in
those cases.
Signed-off-by: Keith Packard <keithp@keithp.com>
public void set_tick(int tick) {
if (tick != AltosLib.MISSING) {
if (prev_tick != AltosLib.MISSING) {
- while (tick < prev_tick - 1000) {
+ while (tick < prev_tick - 32767) {
tick += 65536;
}
+ while (tick > prev_tick + 32767) {
+ tick -= 65536;
+ }
}
if (first_tick == AltosLib.MISSING)
first_tick = tick;
} else {
while (t < tick - 32767)
t += 65536;
+ while (t > tick + 32767)
+ t -= 65536;
tick = t;
}
record.wide_tick = tick;