X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosEepromRecordTiny.java;h=428a9fc59a8709fd8b1a06fa5a506d8a58bd59de;hp=6c04bfee16c8bf4bff6245fd49243f7c85cd9b59;hb=6023ff81f1bbd240169b9548209133d3b02d475f;hpb=e67a5c6ffa7174d66e985483fab4bf52ccaea5ca diff --git a/altoslib/AltosEepromRecordTiny.java b/altoslib/AltosEepromRecordTiny.java index 6c04bfee..428a9fc5 100644 --- a/altoslib/AltosEepromRecordTiny.java +++ b/altoslib/AltosEepromRecordTiny.java @@ -12,15 +12,19 @@ * General Public License for more details. */ -package org.altusmetrum.altoslib_11; +package org.altusmetrum.altoslib_13; -public class AltosEepromRecordTiny extends AltosEepromRecord { +public class AltosEepromRecordTiny extends AltosEepromRecord implements AltosDataProvider { public static final int record_length = 2; private int value() { return eeprom.data16(start); } + public boolean valid(int s) { + return eeprom.data16(s) != 0xffff; + } + public int cmd() { if (start == 0) return AltosLib.AO_LOG_FLIGHT; @@ -46,36 +50,37 @@ public class AltosEepromRecordTiny extends AltosEepromRecord { return tick; } - public void update_state(AltosState state) { + public void provide_data(AltosDataListener listener) { int value = data16(-header_length); - state.set_tick(tick()); + listener.set_tick(tick()); switch (cmd()) { case AltosLib.AO_LOG_FLIGHT: - state.set_state(AltosLib.ao_flight_pad); - state.set_flight(value); - state.set_boost_tick(0); + listener.set_state(AltosLib.ao_flight_pad); + listener.cal_data().set_flight(value); + listener.cal_data().set_boost_tick(); break; case AltosLib.AO_LOG_STATE: - state.set_state(value & 0x7fff); + listener.set_state(value & 0x7fff); break; case AltosLib.AO_LOG_SENSOR: - state.set_pressure(AltosConvert.barometer_to_pressure(value)); + listener.set_pressure(AltosConvert.barometer_to_pressure(value)); break; } } public AltosEepromRecord next() { - if (start + record_length * 2 < eeprom.data.size()) - return new AltosEepromRecordTiny(eeprom, start + record_length); - return null; + int s = next_start(); + if (s < 0) + return null; + return new AltosEepromRecordTiny(eeprom, s); } - public AltosEepromRecordTiny(AltosEepromNew eeprom, int start) { + public AltosEepromRecordTiny(AltosEeprom eeprom, int start) { super(eeprom, start, record_length); } - public AltosEepromRecordTiny(AltosEepromNew eeprom) { + public AltosEepromRecordTiny(AltosEeprom eeprom) { this(eeprom, 0); } }