From: Keith Packard Date: Wed, 18 Jul 2012 03:43:31 +0000 (-0700) Subject: altoslib: Don't use MISSING values in max computations X-Git-Tag: 1.1~71^2~7 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=97c1cfee929a35dd1596dc02ce519b80132f3c5c altoslib: Don't use MISSING values in max computations Early telemetry state may be missing critical data, don't use MISSING values in computing max ranges. Signed-off-by: Keith Packard --- diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 68c7611f..e20ec9a7 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -160,7 +160,8 @@ public class AltosState { } ngps++; } - } + } else + pad_alt = ground_altitude; gps_waiting = MIN_PAD_SAMPLES - npad; if (gps_waiting < 0) @@ -173,14 +174,14 @@ public class AltosState { boost = (AltosLib.ao_flight_boost == state); /* Only look at accelerometer data under boost */ - if (boost && acceleration > max_acceleration) + if (boost && acceleration > max_acceleration && acceleration != AltosRecord.MISSING) max_acceleration = acceleration; - if (boost && speed > max_speed) + if (boost && speed > max_speed && speed != AltosRecord.MISSING) max_speed = speed; - if (boost && baro_speed > max_baro_speed) + if (boost && baro_speed > max_baro_speed && baro_speed != AltosRecord.MISSING) max_baro_speed = baro_speed; - if (height > max_height) + if (height > max_height && height != AltosRecord.MISSING) max_height = height; if (data.gps != null) { if (gps == null || !gps.locked || data.gps.locked)