altoslib: Fix accel value flipping for TM v3.0
authorKeith Packard <keithp@keithp.com>
Wed, 19 May 2021 05:37:01 +0000 (22:37 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 19 May 2021 05:53:51 +0000 (22:53 -0700)
TM v3.0 uses the same log file format value as TM v2.0 but has a
different accelerometer, which requires a different function for
inverting the raw values. Detect v2.0 devices and use the old function
for them while using the new function for all others.

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

index ea7b63fa5813e963eabc60786258135c785ae8e0..7b78f760cbf43646fd5923f2fbce0aa7a695a0f6 100644 (file)
@@ -199,10 +199,18 @@ public class AltosConfigData {
                case AltosLib.AO_LOG_FORMAT_FULL:
                        return 0x7fff - value;
                case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD:
-               case AltosLib.AO_LOG_FORMAT_TELEMETRUM:
                case AltosLib.AO_LOG_FORMAT_TELEMEGA:
                case AltosLib.AO_LOG_FORMAT_TELEMEGA_3:
                        return 4095 - value;
+               case AltosLib.AO_LOG_FORMAT_TELEMETRUM:
+                       /*
+                        * TeleMetrum v2 and later use the same log format, but
+                        * have different accelerometers. This is the only place
+                        * it matters in altoslib.
+                        */
+                       if (product.startsWith("TeleMetrum-v2"))
+                               return 4095 - value;
+                       /* fall through */
                case AltosLib.AO_LOG_FORMAT_TELEMEGA_4:
                case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
                case AltosLib.AO_LOG_FORMAT_EASYMOTOR: