altoslib: Prefer averaged ground pres for ground alt computation
authorKeith Packard <keithp@keithp.com>
Thu, 19 Sep 2013 05:26:24 +0000 (00:26 -0500)
committerKeith Packard <keithp@keithp.com>
Thu, 19 Sep 2013 05:26:24 +0000 (00:26 -0500)
If ground pressure is recorded (as from an eeprom file), then prefer
that value to the average of the pre-boost ground pressures when
computing the ground altitude.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosState.java

index 5a805fc6bf6864b75a146b64a411746583084c48..a9bb1e70833392321b01097da560eb6819304f42 100644 (file)
@@ -301,7 +301,8 @@ public class AltosState implements Cloneable {
        class AltosGroundPressure extends AltosCValue {
                void set_filtered(double p, double time) {
                        computed.set_filtered(p, time);
-                       ground_altitude.set_computed(pressure_to_altitude(computed.value()), time);
+                       if (!is_measured())
+                               ground_altitude.set_computed(pressure_to_altitude(computed.value()), time);
                }
 
                void set_measured(double p, double time) {
@@ -657,6 +658,7 @@ public class AltosState implements Cloneable {
                
                set = 0;
 
+               ground_pressure.copy(old.ground_pressure);
                ground_altitude.copy(old.ground_altitude);
                altitude.copy(old.altitude);
                pressure.copy(old.pressure);