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_11;
17 public class AltosEepromRecordTiny extends AltosEepromRecord {
18 public static final int record_length = 2;
21 return eeprom.data16(start);
26 return AltosLib.AO_LOG_FLIGHT;
27 if ((value() & 0x8000) != 0)
28 return AltosLib.AO_LOG_STATE;
29 return AltosLib.AO_LOG_SENSOR;
35 for (int i = 2; i < start; i += 2)
37 int v = eeprom.data16(i);
39 if ((v & 0x8000) != 0) {
40 if ((v & 0x7fff) >= AltosLib.ao_flight_drogue)
49 public void update_state(AltosState state) {
50 int value = data16(-header_length);
52 state.set_tick(tick());
54 case AltosLib.AO_LOG_FLIGHT:
55 state.set_state(AltosLib.ao_flight_pad);
56 state.set_flight(value);
57 state.set_boost_tick(0);
59 case AltosLib.AO_LOG_STATE:
60 state.set_state(value & 0x7fff);
62 case AltosLib.AO_LOG_SENSOR:
63 state.set_pressure(AltosConvert.barometer_to_pressure(value));
68 public AltosEepromRecord next() {
69 if (start + record_length * 2 < eeprom.data.size())
70 return new AltosEepromRecordTiny(eeprom, start + record_length);
74 public AltosEepromRecordTiny(AltosEepromNew eeprom, int start) {
75 super(eeprom, start, record_length);
78 public AltosEepromRecordTiny(AltosEepromNew eeprom) {