micropeak: Make reported 'max height' value show filtered max height
authorKeith Packard <keithp@keithp.com>
Thu, 5 Apr 2018 23:41:20 +0000 (16:41 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 27 Apr 2018 02:24:21 +0000 (19:24 -0700)
MicroPeak tries to filter out bogus pressure data so that the value
reported on the LED is reasonable. We want to report that same value
in the UI, which means replacing the normal mechanism for computing
max height from the time series of height data with the value computed
from the saved minimum pressure value recorded in the device.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosFlightSeries.java
altoslib/AltosFlightStats.java
micropeak/MicroData.java

index d130d3adcfa6ae6ca41f38da645c060fbf046b41..182bdd19bd511fdcc8533147719c346ffe566c1a 100644 (file)
@@ -257,6 +257,15 @@ public class AltosFlightSeries extends AltosDataListener {
 
        public AltosTimeSeries height_series;
 
+       public double max_height = AltosLib.MISSING;
+
+       public  void set_min_pressure(double pa) {
+               double ground_altitude = cal_data().ground_altitude;
+               if (ground_altitude != AltosLib.MISSING)
+                       max_height = AltosConvert.pressure_to_altitude(pa) -
+                               ground_altitude;
+       }
+
        public static final String height_name = "Height";
 
        public  void set_pressure(double pa) {
index 6bb835810b6183b8d885d95629e782b6ce8c10c8..2760321d0940685ca20a5ea910db20efa9455f95 100644 (file)
@@ -266,8 +266,8 @@ public class AltosFlightStats {
                        }
                }
 
-               max_height = AltosLib.MISSING;
-               if (series.height_series != null)
+               max_height = series.max_height;
+               if (max_height == AltosLib.MISSING && series.height_series != null)
                        max_height = series.height_series.max().value;
                max_gps_height = AltosLib.MISSING;
                if (series.gps_height != null) {
index 70492a07abbebf5e95eaf4ac128ba1f03227590c..6a9adf3ff32a5427b6a10c43ab18646a52d45433 100644 (file)
@@ -345,6 +345,8 @@ public class MicroData {
                        flight_series.set_time(cal_data.time());
                        flight_series.set_state(AltosLib.ao_flight_landed);
 
+                       flight_series.set_min_pressure(min_pressure);
+
                        flight_series.finish();
 
                        flight_stats = new AltosFlightStats(flight_series);