From 505ef49a041740fe7cbb5c537b68d22e5fb6c0be Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 10 Jan 2013 21:37:18 -0800 Subject: [PATCH] micropeak: Report recorded apogee instead of searching flight data This makes sure we report the true apogee value instead of looking for the maximum height value in the flight data, in case the flight recording ended before the apogee was reached. Signed-off-by: Keith Packard --- micropeak/MicroData.java | 12 ++++++++++++ micropeak/MicroStats.java | 11 ++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/micropeak/MicroData.java b/micropeak/MicroData.java index f1204e11..71919ddb 100644 --- a/micropeak/MicroData.java +++ b/micropeak/MicroData.java @@ -229,6 +229,18 @@ public class MicroData { return altitude(i) - ground_altitude; } + public double apogee_pressure() { + return min_pressure; + } + + public double apogee_altitude() { + return AltosConvert.pressure_to_altitude(apogee_pressure()); + } + + public double apogee_height() { + return apogee_altitude() - ground_altitude; + } + static final int speed_avg = 3; static final int accel_avg = 5; diff --git a/micropeak/MicroStats.java b/micropeak/MicroStats.java index 056fac7d..90e9dd1f 100644 --- a/micropeak/MicroStats.java +++ b/micropeak/MicroStats.java @@ -58,12 +58,17 @@ public class MicroStats { } void find_apogee() { - apogee_height = 0; + apogee_height = data.apogee_height(); + double searched_apogee = 0; apogee_time = 0; + /* This just finds the apogee time -- we've recorded the + * peak altitude separately in eeprom, and that could + * have occurred after the eeprom was full. + */ for (MicroDataPoint point : data.points()) { - if (point.height > apogee_height) { - apogee_height = point.height; + if (point.height > searched_apogee) { + searched_apogee = point.height; apogee_time = point.time; } } -- 2.30.2