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_1;
20 public class AltosRecordMM extends AltosRecord {
31 public int ground_accel;
32 public int ground_pres;
33 public int accel_plus_g;
34 public int accel_minus_g;
36 public int flight_accel;
37 public int flight_vel;
38 public int flight_pres;
40 public final static int num_sense = 6;
45 static double adc(int raw) {
49 public double pressure() {
55 public double ground_pressure() {
56 if (ground_pres != MISSING)
61 public double battery_voltage() {
62 if (v_batt != MISSING)
63 return 3.3 * adc(v_batt) * (15.0 + 27.0) / 27.0;
67 static double pyro(int raw) {
69 return 3.3 * adc(raw) * (100.0 + 27.0) / 27.0;
73 public double main_voltage() {
74 return pyro(sense[1]);
77 public double drogue_voltage() {
78 return pyro(sense[0]);
81 public double temperature() {
87 public AltosIMU imu() { return imu; }
89 public AltosMag mag() { return mag; }
91 double accel_counts_per_mss() {
92 double counts_per_g = Math.abs(accel_minus_g - accel_plus_g) / 2;
94 return counts_per_g / 9.80665;
97 public double acceleration() {
98 if (ground_accel == MISSING || accel == MISSING)
101 if (accel_minus_g == MISSING || accel_plus_g == MISSING)
104 return (ground_accel - accel) / accel_counts_per_mss();
107 public void copy (AltosRecordMM old) {
116 sense = new int[num_sense];
118 for (int i = 0; i < num_sense; i++)
119 sense[i] = old.sense[i];
121 ground_accel = old.ground_accel;
122 ground_pres = old.ground_pres;
123 accel_plus_g = old.accel_plus_g;
124 accel_minus_g = old.accel_minus_g;
126 flight_accel = old.flight_accel;
127 flight_vel = old.flight_vel;
128 flight_pres = old.flight_pres;
136 public AltosRecordMM clone() {
137 return new AltosRecordMM(this);
140 void make_missing() {
148 sense = new int[num_sense];
149 for (int i = 0; i < num_sense; i++)
152 ground_accel = MISSING;
153 ground_pres = MISSING;
154 accel_plus_g = MISSING;
155 accel_minus_g = MISSING;
161 imu = new AltosIMU();
162 mag = new AltosMag();
165 public AltosRecordMM(AltosRecord old) {
170 public AltosRecordMM(AltosRecordMM old) {
174 public AltosRecordMM() {