altosui: Report baro ground alt for 'Pad Altitude' when GPS missing
authorKeith Packard <keithp@keithp.com>
Thu, 26 Mar 2020 17:01:48 +0000 (10:01 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 26 Mar 2020 17:01:48 +0000 (10:01 -0700)
The 'Pad Altitude' field in the pad tab of AltosUI was originally one
of three fields designed to report the GPS position of the pad. When
TeleMini was added, the code was updated to separate the lat/lon from
altitude display, but the pad_alt field in AltosState used for that
was still only computed from GPS data.

This fix gets rid of the confusing 'pad_alt' field in AltosState and
has the 'Pad Altitude' data select either GPS ground altitude or baro
ground altitude, depending on whether GPS data is available.

signed-off-by: Keith Packard <keithp@keithp.com>

altoslib/AltosState.java
altosui/AltosPad.java
altosuilib/AltosInfoTable.java

index e3ea0524e90b8bd3d873aeb50d7ba722e6a80340..fc9727481201162bf636e6c4324b2d3140458310 100644 (file)
@@ -307,13 +307,12 @@ public class AltosState extends AltosDataListener {
        class AltosGpsGroundAltitude extends AltosValue {
                void set(double a, double t) {
                        super.set(a, t);
-                       pad_alt = value();
+
                        gps_altitude.set_gps_height();
                }
 
                void set_filtered(double a, double t) {
                        super.set_filtered(a, t);
-                       pad_alt = value();
                        gps_altitude.set_gps_height();
                }
 
@@ -693,7 +692,7 @@ public class AltosState extends AltosDataListener {
 
        public double   gps_height;
 
-       public double pad_lat, pad_lon, pad_alt;
+       public double pad_lat, pad_lon;
 
        public int      speak_tick;
        public double   speak_altitude;
@@ -775,7 +774,6 @@ public class AltosState extends AltosDataListener {
 
                pad_lat = AltosLib.MISSING;
                pad_lon = AltosLib.MISSING;
-               pad_alt = AltosLib.MISSING;
 
                gps_altitude = new AltosGpsAltitude();
                gps_ground_altitude = new AltosGpsGroundAltitude();
index 004bd5344619f30702c9db30a6c6f731d228abc4..e9bb4e41c2802f1003f50ab0c6570c0ce64d2fe3 100644 (file)
@@ -214,9 +214,13 @@ public class AltosPad extends AltosUIFlightTab {
        class PadAlt extends AltosUIUnitsIndicator {
 
                public double value(AltosState state, int i) {
-                       if (report_pad(state))
-                               return state.pad_alt;
-                       else if (state.gps != null)
+                       if (report_pad(state)) {
+                               double alt = state.gps_ground_altitude();
+                               if (alt == AltosLib.MISSING)
+                                       alt = state.ground_altitude();
+                               return alt;
+                       }
+                       else if (state.gps != null && state.gps.alt != AltosLib.MISSING)
                                return state.gps.alt;
                        else
                                return state.altitude();
index e20a516c573e278de42696b0cfdba7fb4e84a2c6..226f112f9542dff7c328b91514704bb4931a9bb8 100644 (file)
@@ -242,7 +242,7 @@ public class AltosInfoTable extends JTable implements AltosFlightDisplay, Hierar
                                        }
                                        info_add_deg(1, "Pad latitude", state.pad_lat, 'N', 'S');
                                        info_add_deg(1, "Pad longitude", state.pad_lon, 'E', 'W');
-                                       info_add_row(1, "Pad GPS alt", "%6.0f m", state.pad_alt);
+                                       info_add_row(1, "Pad GPS alt", "%6.0f m", state.gps_ground_altitude());
                                }
                                if (state.gps.year != AltosLib.MISSING)
                                        info_add_row(2, "GPS date", "%04d-%02d-%02d",