2 * Copyright © 2017 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
15 package org.altusmetrum.altoslib_13;
17 public class AltosEepromRecordTiny extends AltosEepromRecord implements AltosDataProvider {
18 public static final int record_length = 2;
21 return eeprom.data16(start);
24 public boolean valid(int s) {
25 return eeprom.data16(s) != 0xffff;
30 return AltosLib.AO_LOG_FLIGHT;
31 if ((value() & 0x8000) != 0)
32 return AltosLib.AO_LOG_STATE;
33 return AltosLib.AO_LOG_SENSOR;
39 for (int i = 2; i < start; i += 2)
41 int v = eeprom.data16(i);
43 if ((v & 0x8000) != 0) {
44 if ((v & 0x7fff) >= AltosLib.ao_flight_drogue)
53 public void provide_data(AltosDataListener listener) {
54 int value = data16(-header_length);
56 listener.set_tick(tick());
58 case AltosLib.AO_LOG_FLIGHT:
59 listener.set_state(AltosLib.ao_flight_pad);
60 listener.cal_data().set_flight(value);
61 listener.cal_data().set_boost_tick();
63 case AltosLib.AO_LOG_STATE:
64 listener.set_state(value & 0x7fff);
66 case AltosLib.AO_LOG_SENSOR:
67 listener.set_pressure(AltosConvert.barometer_to_pressure(value));
72 public AltosEepromRecord next() {
76 return new AltosEepromRecordTiny(eeprom, s);
79 public AltosEepromRecordTiny(AltosEeprom eeprom, int start) {
80 super(eeprom, start, record_length);
83 public AltosEepromRecordTiny(AltosEeprom eeprom) {