altoslib: Reset transient AltosCalData values before processing data
[fw/altos] / altoslib / AltosCalData.java
index 408d8d7e5f78738e7298fda27c06543f9cdef4a1..cb58e4929c3056ada5af4db3b6249d53a9e16932 100644 (file)
@@ -65,8 +65,11 @@ public class AltosCalData {
        public int              device_type = AltosLib.MISSING;
 
        public void set_device_type(int device_type) {
-               if (device_type != AltosLib.MISSING)
+               if (device_type != AltosLib.MISSING) {
                        this.device_type = device_type;
+                       if (product == null)
+                               set_product(AltosLib.product_name(device_type));
+               }
        }
 
        public int              config_major = AltosLib.MISSING;
@@ -179,6 +182,18 @@ public class AltosCalData {
                }
        }
 
+       /* Reset all values which change during flight
+        */
+       public void reset() {
+               state = AltosLib.MISSING;
+               tick = AltosLib.MISSING;
+               prev_tick = AltosLib.MISSING;
+               temp_gps = null;
+               prev_gps = null;
+               temp_gps_sat_tick = AltosLib.MISSING;
+               accel = AltosLib.MISSING;
+       }
+
        public int              boost_tick = AltosLib.MISSING;
 
        public void set_boost_tick() {