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 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);
29 /* Flush any pending GPS changes */
30 if (cal_data.gps_pending()) {
32 case AltosLib.AO_LOG_GPS_LAT:
33 case AltosLib.AO_LOG_GPS_LON:
34 case AltosLib.AO_LOG_GPS_ALT:
35 case AltosLib.AO_LOG_GPS_SAT:
36 case AltosLib.AO_LOG_GPS_DATE:
39 listener.set_gps(cal_data.temp_gps());
40 cal_data.reset_temp_gps();
46 case AltosLib.AO_LOG_FLIGHT:
47 listener.set_state(AltosLib.ao_flight_pad);
48 cal_data.set_ground_accel(data16(0));
49 cal_data.set_flight(data16(2));
50 if (cal_data.accel_plus_g == AltosLib.MISSING)
51 cal_data.set_accel_plus_minus(data16(0), data16(0) + two_g_default);
53 case AltosLib.AO_LOG_SENSOR:
54 listener.set_acceleration(cal_data.acceleration(data16(0)));
55 listener.set_pressure(AltosConvert.barometer_to_pressure(data16(2)));
57 case AltosLib.AO_LOG_PRESSURE:
58 listener.set_pressure(AltosConvert.barometer_to_pressure(data16(2)));
60 case AltosLib.AO_LOG_TEMP_VOLT:
61 listener.set_temperature(AltosConvert.thermometer_to_temperature(data16(0)));
62 listener.set_battery_voltage(AltosConvert.cc_battery_to_voltage(data16(2)));
64 case AltosLib.AO_LOG_DEPLOY:
65 listener.set_apogee_voltage(AltosConvert.cc_ignitor_to_voltage(data16(0)));
66 listener.set_main_voltage(AltosConvert.cc_ignitor_to_voltage(data16(2)));
68 case AltosLib.AO_LOG_STATE:
69 listener.set_state(data16(0));
71 case AltosLib.AO_LOG_GPS_TIME:
72 gps = cal_data.make_temp_gps(tick(),false);
75 gps.minute = data8(1);
76 gps.second = data8(2);
80 gps.connected = (flags & AltosLib.AO_GPS_RUNNING) != 0;
81 gps.locked = (flags & AltosLib.AO_GPS_VALID) != 0;
82 gps.nsat = (flags & AltosLib.AO_GPS_NUM_SAT_MASK) >>
83 AltosLib.AO_GPS_NUM_SAT_SHIFT;
85 case AltosLib.AO_LOG_GPS_LAT:
86 gps = cal_data.make_temp_gps(tick(),false);
88 int lat32 = data32(0);
89 gps.lat = (double) lat32 / 1e7;
91 case AltosLib.AO_LOG_GPS_LON:
92 gps = cal_data.make_temp_gps(tick(),false);
94 int lon32 = data32(0);
95 gps.lon = (double) lon32 / 1e7;
97 case AltosLib.AO_LOG_GPS_ALT:
98 gps = cal_data.make_temp_gps(tick(),false);
101 case AltosLib.AO_LOG_GPS_SAT:
102 gps = cal_data.make_temp_gps(tick(),true);
103 int svid = data16(0);
104 int c_n0 = data16(3);
105 gps.add_sat(svid, c_n0);
107 case AltosLib.AO_LOG_GPS_DATE:
108 gps = cal_data.make_temp_gps(tick(),false);
109 gps.year = data8(0) + 2000;
110 gps.month = data8(1);
116 public AltosEepromRecord next() {
117 int s = next_start();
120 return new AltosEepromRecordFull(eeprom, s);
123 public AltosEepromRecordFull(AltosEepromNew eeprom, int start) {
124 super(eeprom, start, record_length);
127 public AltosEepromRecordFull(AltosEepromNew eeprom) {