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_12;
17 public class AltosEepromRecordFull extends AltosEepromRecord {
18 public static final int record_length = 8;
20 public static final int max_sat = 12;
22 public static final int two_g_default = 16294 - 15758;
24 public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
26 super.provide_data(listener, cal_data);
30 case AltosLib.AO_LOG_FLIGHT:
31 listener.set_state(AltosLib.ao_flight_pad);
32 cal_data.set_ground_accel(data16(0));
33 cal_data.set_flight(data16(2));
34 if (cal_data.accel_plus_g == AltosLib.MISSING)
35 cal_data.set_accel_plus_minus(data16(0), data16(0) + two_g_default);
37 case AltosLib.AO_LOG_SENSOR:
38 listener.set_acceleration(cal_data.acceleration(data16(0)));
39 listener.set_pressure(AltosConvert.barometer_to_pressure(data16(2)));
41 case AltosLib.AO_LOG_PRESSURE:
42 listener.set_pressure(AltosConvert.barometer_to_pressure(data16(2)));
44 case AltosLib.AO_LOG_TEMP_VOLT:
45 listener.set_temperature(AltosConvert.thermometer_to_temperature(data16(0)));
46 listener.set_battery_voltage(AltosConvert.cc_battery_to_voltage(data16(2)));
48 case AltosLib.AO_LOG_DEPLOY:
49 listener.set_apogee_voltage(AltosConvert.cc_igniter_to_voltage(data16(0)));
50 listener.set_main_voltage(AltosConvert.cc_igniter_to_voltage(data16(2)));
52 case AltosLib.AO_LOG_STATE:
53 listener.set_state(data16(0));
55 case AltosLib.AO_LOG_GPS_TIME:
56 gps = listener.make_temp_gps(false);
59 gps.minute = data8(1);
60 gps.second = data8(2);
64 gps.connected = (flags & AltosLib.AO_GPS_RUNNING) != 0;
65 gps.locked = (flags & AltosLib.AO_GPS_VALID) != 0;
66 gps.nsat = (flags & AltosLib.AO_GPS_NUM_SAT_MASK) >>
67 AltosLib.AO_GPS_NUM_SAT_SHIFT;
69 case AltosLib.AO_LOG_GPS_LAT:
70 gps = listener.make_temp_gps(false);
72 int lat32 = data32(0);
73 gps.lat = (double) lat32 / 1e7;
75 case AltosLib.AO_LOG_GPS_LON:
76 gps = listener.make_temp_gps(false);
78 int lon32 = data32(0);
79 gps.lon = (double) lon32 / 1e7;
81 case AltosLib.AO_LOG_GPS_ALT:
82 gps = listener.make_temp_gps(false);
85 case AltosLib.AO_LOG_GPS_SAT:
86 gps = listener.make_temp_gps(true);
89 gps.add_sat(svid, c_n0);
91 case AltosLib.AO_LOG_GPS_DATE:
92 gps = listener.make_temp_gps(false);
93 gps.year = data8(0) + 2000;
100 public AltosEepromRecord next() {
101 int s = next_start();
104 return new AltosEepromRecordFull(eeprom, s);
107 public AltosEepromRecordFull(AltosEeprom eeprom, int start) {
108 super(eeprom, start, record_length);
111 public AltosEepromRecordFull(AltosEeprom eeprom) {