+ public static double acceleration_from_sensor(double sensor, double plus_g, double minus_g, double ground) {
+
+ if (sensor == AltosLib.MISSING)
+ return AltosLib.MISSING;
+
+ if (plus_g == AltosLib.MISSING || minus_g == AltosLib.MISSING)
+ return AltosLib.MISSING;
+
+ if (ground == AltosLib.MISSING)
+ ground = plus_g;
+
+ double counts_per_g = (plus_g - minus_g) / 2.0;
+ double counts_per_mss = counts_per_g / gravity;
+
+ if (counts_per_mss == 0)
+ return AltosLib.MISSING;
+
+ return (sensor - ground) / counts_per_mss;
+ }
+