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 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, AltosCalData cal_data) {
54 int value = data16(-header_length);
56 cal_data.set_tick(tick());
57 listener.set_time(cal_data.time());
59 case AltosLib.AO_LOG_FLIGHT:
60 listener.set_state(AltosLib.ao_flight_pad);
61 cal_data.set_flight(value);
62 cal_data.set_boost_tick();
64 case AltosLib.AO_LOG_STATE:
65 listener.set_state(value & 0x7fff);
67 case AltosLib.AO_LOG_SENSOR:
68 listener.set_pressure(AltosConvert.barometer_to_pressure(value));
73 public AltosEepromRecord next() {
77 return new AltosEepromRecordTiny(eeprom, s);
80 public AltosEepromRecordTiny(AltosEepromNew eeprom, int start) {
81 super(eeprom, start, record_length);
84 public AltosEepromRecordTiny(AltosEepromNew eeprom) {