altoslib: Check for valid pad alt before computing GPS height series
[fw/altos] / altosuilib / AltosGraph.java
index d7739228585997b8cfe11aab5230e438b5949c77..987c461e5836ee7afe074f259574786c77c9a97f 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package org.altusmetrum.altosuilib_6;
+package org.altusmetrum.altosuilib_11;
 
 import java.io.*;
 import java.util.ArrayList;
 
 import java.awt.*;
 import javax.swing.*;
-import org.altusmetrum.altoslib_6.*;
+import org.altusmetrum.altoslib_11.*;
 
 import org.jfree.ui.*;
 import org.jfree.chart.*;
@@ -34,29 +35,6 @@ import org.jfree.chart.labels.*;
 import org.jfree.data.xy.*;
 import org.jfree.data.*;
 
-class AltosVoltage extends AltosUnits {
-
-       public double value(double v, boolean imperial_units) {
-               return v;
-       }
-
-       public double inverse(double v, boolean imperial_units) {
-               return v;
-       }
-
-       public String show_units(boolean imperial_units) {
-               return "V";
-       }
-
-       public String say_units(boolean imperial_units) {
-               return "volts";
-       }
-
-       public int show_fraction(int width, boolean imperial_units) {
-               return width / 2;
-       }
-}
-
 class AltosNsat extends AltosUnits {
 
        public double value(double v, boolean imperial_units) {
@@ -80,29 +58,6 @@ class AltosNsat extends AltosUnits {
        }
 }
 
-class AltosPressure extends AltosUnits {
-
-       public double value(double p, boolean imperial_units) {
-               return p;
-       }
-
-       public double inverse(double p, boolean imperial_units) {
-               return p;
-       }
-
-       public String show_units(boolean imperial_units) {
-               return "Pa";
-       }
-
-       public String say_units(boolean imperial_units) {
-               return "pascals";
-       }
-
-       public int show_fraction(int width, boolean imperial_units) {
-               return 0;
-       }
-}
-
 class AltosDbm extends AltosUnits {
 
        public double value(double d, boolean imperial_units) {
@@ -126,29 +81,6 @@ class AltosDbm extends AltosUnits {
        }
 }
 
-class AltosGyroUnits extends AltosUnits {
-
-       public double value(double p, boolean imperial_units) {
-               return p;
-       }
-
-       public double inverse(double p, boolean imperial_units) {
-               return p;
-       }
-
-       public String show_units(boolean imperial_units) {
-               return "°/sec";
-       }
-
-       public String say_units(boolean imperial_units) {
-               return "degrees per second";
-       }
-
-       public int show_fraction(int width, boolean imperial_units) {
-               return 1;
-       }
-}
-
 class AltosMagUnits extends AltosUnits {
 
        public double value(double p, boolean imperial_units) {
@@ -231,11 +163,9 @@ public class AltosGraph extends AltosUIGraph {
        static final private Color mag_z_color = new Color(0, 0, 128);
        static final private Color orient_color = new Color(31, 31, 31);
 
-       static AltosVoltage voltage_units = new AltosVoltage();
-       static AltosPressure pressure_units = new AltosPressure();
        static AltosNsat nsat_units = new AltosNsat();
        static AltosDbm dbm_units = new AltosDbm();
-       static AltosGyroUnits gyro_units = new AltosGyroUnits();
+       static AltosRotationRate gyro_units = new AltosRotationRate();
        static AltosOrient orient_units = new AltosOrient();
        static AltosMagUnits mag_units = new AltosMagUnits();
        static AltosDopUnits dop_units = new AltosDopUnits();
@@ -249,10 +179,10 @@ public class AltosGraph extends AltosUIGraph {
                super(enable);
 
                height_axis = newAxis("Height", AltosConvert.height, height_color);
-               pressure_axis = newAxis("Pressure", pressure_units, pressure_color, 0);
+               pressure_axis = newAxis("Pressure", AltosConvert.pressure, pressure_color, 0);
                speed_axis = newAxis("Speed", AltosConvert.speed, speed_color);
                accel_axis = newAxis("Acceleration", AltosConvert.accel, accel_color);
-               voltage_axis = newAxis("Voltage", voltage_units, voltage_color);
+               voltage_axis = newAxis("Voltage", AltosConvert.voltage, voltage_color);
                temperature_axis = newAxis("Temperature", AltosConvert.temperature, temperature_color, 0);
                nsat_axis = newAxis("Satellites", nsat_units, gps_nsat_color,
                                    AltosUIAxis.axis_include_zero | AltosUIAxis.axis_integer);
@@ -276,7 +206,7 @@ public class AltosGraph extends AltosUIGraph {
                                  height_axis);
                        addSeries("Pressure",
                                  AltosGraphDataPoint.data_pressure,
-                                 pressure_units,
+                                 AltosConvert.pressure,
                                  pressure_color,
                                  false,
                                  pressure_axis);
@@ -389,7 +319,7 @@ public class AltosGraph extends AltosUIGraph {
                if (stats.has_battery)
                        addSeries("Battery Voltage",
                                  AltosGraphDataPoint.data_battery_voltage,
-                                 voltage_units,
+                                 AltosConvert.voltage,
                                  battery_voltage_color,
                                  false,
                                  voltage_axis);
@@ -403,13 +333,13 @@ public class AltosGraph extends AltosUIGraph {
                                  temperature_axis);
                        addSeries("Drogue Voltage",
                                  AltosGraphDataPoint.data_drogue_voltage,
-                                 voltage_units,
+                                 AltosConvert.voltage,
                                  drogue_voltage_color,
                                  false,
                                  voltage_axis);
                        addSeries("Main Voltage",
                                  AltosGraphDataPoint.data_main_voltage,
-                                 voltage_units,
+                                 AltosConvert.voltage,
                                  main_voltage_color,
                                  false,
                                  voltage_axis);
@@ -484,7 +414,7 @@ public class AltosGraph extends AltosUIGraph {
                        for (int i = 0; i < stats.num_ignitor; i++)
                                addSeries(AltosLib.ignitor_name(i),
                                          AltosGraphDataPoint.data_ignitor_0 + i,
-                                         voltage_units,
+                                         AltosConvert.voltage,
                                          main_voltage_color,
                                          false,
                                          voltage_axis);