altoslib: Set measured acceleration for measured acceleration
[fw/altos] / altoslib / AltosState.java
index 726c3041f4587edc5c3533a701e3d0a242f2f57d..1c400bab2a57bece34d8627f1300bd62dbc4bd1d 100644 (file)
@@ -150,8 +150,12 @@ public class AltosState implements Cloneable {
                void set_integral(AltosValue in) {
                        double  change = in.integrate();
 
-                       if (change != AltosRecord.MISSING)
-                               set(prev_value + change, in.time());
+                       if (change != AltosRecord.MISSING) {
+                               double  prev = prev_value;
+                               if (prev == AltosRecord.MISSING)
+                                       prev = 0;
+                               set(prev + change, in.time());
+                       }
                }
 
                void copy(AltosValue old) {
@@ -460,7 +464,7 @@ public class AltosState implements Cloneable {
 
        public AltosGPS gps;
        public AltosGPS temp_gps;
-       public boolean  temp_gps_clear_sats_pending;
+       public int temp_gps_sat_tick;
        public boolean  gps_pending;
        public int gps_sequence;
 
@@ -554,7 +558,7 @@ public class AltosState implements Cloneable {
 
                gps = null;
                temp_gps = null;
-               temp_gps_clear_sats_pending = false;
+               temp_gps_sat_tick = 0;
                gps_sequence = 0;
                gps_pending = false;
 
@@ -649,7 +653,7 @@ public class AltosState implements Cloneable {
                        temp_gps = old.temp_gps.clone();
                else
                        temp_gps = null;
-               temp_gps_clear_sats_pending = old.temp_gps_clear_sats_pending;
+               temp_gps_sat_tick = old.temp_gps_sat_tick;
                gps_sequence = old.gps_sequence;
                gps_pending = old.gps_pending;
 
@@ -880,7 +884,7 @@ public class AltosState implements Cloneable {
 
                double counts_per_g = (accel_minus_g - accel_plus_g) / 2.0;
                double counts_per_mss = counts_per_g / 9.80665;
-               acceleration.set_computed((ground - accel) / counts_per_mss, time);
+               acceleration.set_measured((ground - accel) / counts_per_mss, time);
        }
 
        public void set_accel_g(double accel_plus_g, double accel_minus_g) {
@@ -969,11 +973,10 @@ public class AltosState implements Cloneable {
                        temp_gps = new AltosGPS(gps);
                }
                gps_pending = true;
-               if (!sats)
-                       temp_gps_clear_sats_pending = true;
-               else if (temp_gps_clear_sats_pending) {
-                       temp_gps.cc_gps_sat = null;
-                       temp_gps_clear_sats_pending = false;
+               if (sats) {
+                       if (tick != temp_gps_sat_tick)
+                               temp_gps.cc_gps_sat = null;
+                       temp_gps_sat_tick = tick;
                }
                return temp_gps;
        }