From: Keith Packard Date: Thu, 5 Apr 2018 23:41:20 +0000 (-0700) Subject: micropeak: Make reported 'max height' value show filtered max height X-Git-Tag: 1.8.6~1^2~108 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=110e4818b85781c33d683b7b7e7f2864a1223c5c;hp=20dc0e6c8e365c1f4188189d506163d589c3bade micropeak: Make reported 'max height' value show filtered max height 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 --- diff --git a/altoslib/AltosFlightSeries.java b/altoslib/AltosFlightSeries.java index d130d3ad..182bdd19 100644 --- a/altoslib/AltosFlightSeries.java +++ b/altoslib/AltosFlightSeries.java @@ -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) { diff --git a/altoslib/AltosFlightStats.java b/altoslib/AltosFlightStats.java index 6bb83581..2760321d 100644 --- a/altoslib/AltosFlightStats.java +++ b/altoslib/AltosFlightStats.java @@ -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) { diff --git a/micropeak/MicroData.java b/micropeak/MicroData.java index 70492a07..6a9adf3f 100644 --- a/micropeak/MicroData.java +++ b/micropeak/MicroData.java @@ -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);