altosui/telegps: Ship firmware for new hardware
[fw/altos] / altosui / AltosPad.java
index 5c33fd16630fc03578c51e809345b93d7672e132..4f55636db23c706f2ec7a4fafd3894811b6e30ab 100644 (file)
@@ -18,8 +18,8 @@
 package altosui;
 
 import java.util.*;
-import org.altusmetrum.altoslib_5.*;
-import org.altusmetrum.altosuilib_3.*;
+import org.altusmetrum.altoslib_10.*;
+import org.altusmetrum.altosuilib_10.*;
 
 public class AltosPad extends AltosUIFlightTab {
 
@@ -49,10 +49,10 @@ public class AltosPad extends AltosUIFlightTab {
                                hide();
                        } else {
                                if (state.flight != 0) {
-                                       if (state.state <= Altos.ao_flight_pad)
+                                       if (state.state() <= Altos.ao_flight_pad)
                                                show("Ready to record");
-                                       else if (state.state < Altos.ao_flight_landed ||
-                                                state.state == AltosLib.ao_flight_stateless)
+                                       else if (state.state() < Altos.ao_flight_landed ||
+                                                state.state() == AltosLib.ao_flight_stateless)
                                                show("Recording data");
                                        else
                                                show("Recorded data");
@@ -103,9 +103,12 @@ public class AltosPad extends AltosUIFlightTab {
 
                public double voltage(AltosState state) { return AltosLib.MISSING; }
 
-               public boolean hide(double v) { return v == AltosLib.MISSING; }
                public double good() { return AltosLib.ao_battery_good; }
 
+               public boolean hide(AltosState state, AltosListenerState listener_state, int i) {
+                       return value(state, listener_state, i) == AltosLib.MISSING;
+               }
+
                public double value(AltosState state, AltosListenerState listener_state, int i) {
                        if (listener_state == null)
                                return AltosLib.MISSING;
@@ -117,6 +120,17 @@ public class AltosPad extends AltosUIFlightTab {
                }
        }
 
+       boolean report_pad(AltosState state) {
+               if ((state.state() == AltosLib.ao_flight_stateless ||
+                    state.state() < AltosLib.ao_flight_pad) &&
+                   state.gps != null &&
+                   state.gps.lat != AltosLib.MISSING)
+               {
+                       return false;
+               }
+               return true;
+       }
+
        class PadLat extends AltosUIIndicator {
 
                double  last_lat = AltosLib.MISSING - 1;
@@ -126,12 +140,12 @@ public class AltosPad extends AltosUIFlightTab {
                        String label = null;
 
                        if (state != null) {
-                               if (state.state < AltosLib.ao_flight_pad && state.gps != null && state.gps.lat != AltosLib.MISSING) {
-                                       lat = state.gps.lat;
-                                       label = "Latitude";
-                               } else {
+                               if (report_pad(state)) {
                                        lat = state.pad_lat;
                                        label = "Pad Latitude";
+                               } else {
+                                       lat = state.gps.lat;
+                                       label = "Latitude";
                                }
                        }
                        if (lat != last_lat) {
@@ -163,12 +177,12 @@ public class AltosPad extends AltosUIFlightTab {
                        String label = null;
 
                        if (state != null) {
-                               if (state.state < AltosLib.ao_flight_pad && state.gps != null && state.gps.lon != AltosLib.MISSING) {
-                                       lon = state.gps.lon;
-                                       label = "Longitude";
-                               } else {
+                               if (report_pad(state)) {
                                        lon = state.pad_lon;
                                        label = "Pad Longitude";
+                               } else {
+                                       lon = state.gps.lon;
+                                       label = "Longitude";
                                }
                        }
                        if (lon != last_lon) {
@@ -200,12 +214,12 @@ public class AltosPad extends AltosUIFlightTab {
                        String label = null;
 
                        if (state != null) {
-                               if (state.state < AltosLib.ao_flight_pad && state.gps != null && state.gps.alt != AltosLib.MISSING) {
-                                       alt = state.gps.alt;
-                                       label = "Altitude";
-                               } else {
+                               if (report_pad(state)) {
                                        alt = state.pad_alt;
                                        label = "Pad Altitude";
+                               } else {
+                                       alt = state.gps.alt;
+                                       label = "Altitude";
                                }
                        }
                        if (alt != last_alt) {
@@ -232,12 +246,12 @@ public class AltosPad extends AltosUIFlightTab {
        public AltosPad() {
                int y = 0;
                add(new Battery(this, y++));
+               add(new ReceiverBattery(this, y++));
                add(new Apogee(this, y++));
                add(new Main(this, y++));
                add(new LoggingReady(this, y++));
                add(new GPSLocked(this, y++));
                add(new GPSReady(this, y++));
-               add(new ReceiverBattery(this, y++));
                add(new PadLat(this, y++));
                add(new PadLon(this, y++));
                add(new PadAlt(this, y++));