altoslib: Set all 3 axes of accel cal data when present
authorKeith Packard <keithp@keithp.com>
Fri, 23 Oct 2020 23:02:07 +0000 (16:02 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 23 Oct 2020 23:06:48 +0000 (16:06 -0700)
Use the new accel cal function in altos to set all three axes

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

index 38c4182cfef5da2b5fe9cb997722473e0e471b7a..e8859b27aec7c7ddbff9b73a6d16be44f99d961d 100644 (file)
@@ -181,8 +181,16 @@ public class AltosAccelCal implements Runnable {
                                                  plus, minus);
                                if (config_data.pad_orientation != AltosLib.MISSING)
                                        link.printf("c o %d\n", config_data.pad_orientation);
-                               if (plus != AltosLib.MISSING && minus != AltosLib.MISSING)
-                                       link.printf("c a %d %d\n", plus, minus);
+                               if (plus != AltosLib.MISSING && minus != AltosLib.MISSING && plus != 0) {
+                                       if (config_data.accel_zero_along != AltosLib.MISSING)
+                                               link.printf("c a %d %d %d %d %d\n",
+                                                           plus, minus,
+                                                           config_data.accel_zero_along,
+                                                           config_data.accel_zero_across,
+                                                           config_data.accel_zero_through);
+                                       else
+                                               link.printf("c a %d %d\n", plus, minus);
+                               }
                                link.flush_output();
                                stop_link();
                        }
index 83f3ca07a55dfd35b3541dc70e6c239ae0203ec3..5634ff410229f9fa77386c805e4f3b88c41446e2 100644 (file)
@@ -205,8 +205,11 @@ public class AltosConfigData {
                case AltosLib.AO_LOG_FORMAT_TELEMEGA_4:
                        return 4095 - value;
                case AltosLib.AO_LOG_FORMAT_EASYMEGA_2:
+               case AltosLib.AO_LOG_FORMAT_EASYMOTOR:
                        return -value;
                default:
+                       if (product.startsWith("EasyTimer-"))
+                               return -value;
                        return AltosLib.MISSING;
                }
        }
@@ -356,8 +359,7 @@ public class AltosConfigData {
                if (!accel_cal_adjusted &&
                    pad_orientation != AltosLib.MISSING &&
                    accel_cal_plus != AltosLib.MISSING &&
-                   accel_cal_minus != AltosLib.MISSING &&
-                   log_format != AltosLib.AO_LOG_FORMAT_UNKNOWN)
+                   accel_cal_minus != AltosLib.MISSING)
                {
                        switch (pad_orientation) {
                        case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP:
@@ -636,6 +638,8 @@ public class AltosConfigData {
                                return true;
                        if (product.startsWith("TeleMega-v4"))
                                return true;
+                       if (product.startsWith("EasyMotor-v2"))
+                               return true;
                }
                throw new AltosUnknownProduct(product);
        }
@@ -648,6 +652,9 @@ public class AltosConfigData {
                                return AltosAdxl375.X_AXIS;
                        if (product.startsWith("TeleMega-v4"))
                                return AltosAdxl375.X_AXIS;
+                       if (product.startsWith("EasyMotor-v2"))
+                               return AltosAdxl375.X_AXIS;
+
                }
                throw new AltosUnknownProduct(product);
        }
@@ -831,8 +838,18 @@ public class AltosConfigData {
                        link.printf("c o %d\n", pad_orientation);
                int plus = accel_cal_plus(pad_orientation);
                int minus = accel_cal_minus(pad_orientation);
-               if (plus != AltosLib.MISSING && minus != AltosLib.MISSING)
-                       link.printf("c a %d %d\n", plus, minus);
+               if (plus != AltosLib.MISSING && minus != AltosLib.MISSING) {
+                       if (accel_zero_along != AltosLib.MISSING &&
+                           accel_zero_across != AltosLib.MISSING &&
+                           accel_zero_through != AltosLib.MISSING)
+                               link.printf("c a %d %d %d %d %d\n",
+                                           plus, minus,
+                                           accel_zero_along,
+                                           accel_zero_across,
+                                           accel_zero_through);
+                       else
+                               link.printf("c a %d %d\n", plus, minus);
+               }
 
                /* HAS_LOG */
                if (flight_log_max != 0 && flight_log_max != AltosLib.MISSING)