2 * Copyright © 2012 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; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 package org.altusmetrum.AltosLib;
20 public class AltosRecordMM extends AltosRecord {
30 public int ground_accel;
31 public int ground_pres;
32 public int accel_plus_g;
33 public int accel_minus_g;
35 public int flight_accel;
36 public int flight_vel;
37 public int flight_pres;
39 public final static int num_sense = 6;
44 static double adc(int raw) {
48 public double raw_pressure() {
54 public double filtered_pressure() {
55 return raw_pressure();
58 public double ground_pressure() {
59 if (ground_pres != MISSING)
64 public double battery_voltage() {
65 if (v_batt != MISSING)
66 return 3.3 * adc(v_batt) * (15.0 + 27.0) / 27.0;
70 static double pyro(int raw) {
72 return 3.3 * adc(raw) * (100.0 + 27.0) / 27.0;
76 public double main_voltage() {
77 return pyro(sense[1]);
80 public double drogue_voltage() {
81 return pyro(sense[0]);
84 public double temperature() {
90 public AltosIMU imu() { return imu; }
92 public AltosMag mag() { return mag; }
94 double accel_counts_per_mss() {
95 double counts_per_g = Math.abs(accel_minus_g - accel_plus_g) / 2;
97 return counts_per_g / 9.80665;
100 public double acceleration() {
101 if (acceleration != MISSING)
104 if (ground_accel == MISSING || accel == MISSING)
107 if (accel_minus_g == MISSING || accel_plus_g == MISSING)
110 return (ground_accel - accel) / accel_counts_per_mss();
113 public double accel_speed() {
117 public void copy (AltosRecordMM old) {
126 sense = new int[num_sense];
128 for (int i = 0; i < num_sense; i++)
129 sense[i] = old.sense[i];
131 ground_accel = old.ground_accel;
132 ground_pres = old.ground_pres;
133 accel_plus_g = old.accel_plus_g;
134 accel_minus_g = old.accel_minus_g;
136 flight_accel = old.flight_accel;
137 flight_vel = old.flight_vel;
138 flight_pres = old.flight_pres;
144 public AltosRecordMM clone() {
145 AltosRecordMM n = (AltosRecordMM) super.clone();
150 void make_missing() {
158 sense = new int[num_sense];
159 for (int i = 0; i < num_sense; i++)
162 ground_accel = MISSING;
163 ground_pres = MISSING;
164 accel_plus_g = MISSING;
165 accel_minus_g = MISSING;
171 imu = new AltosIMU();
172 mag = new AltosMag();
175 public AltosRecordMM(AltosRecord old) {
180 public AltosRecordMM() {