+public class AltosIMU implements Cloneable {
+ public int accel_x = AltosLib.MISSING;
+ public int accel_y = AltosLib.MISSING;
+ public int accel_z = AltosLib.MISSING;
+
+ public int accel_along = AltosLib.MISSING;
+ public int accel_across = AltosLib.MISSING;
+ public int accel_through = AltosLib.MISSING;
+
+ public int gyro_x = AltosLib.MISSING;
+ public int gyro_y = AltosLib.MISSING;
+ public int gyro_z = AltosLib.MISSING;
+
+ public int gyro_roll = AltosLib.MISSING;
+ public int gyro_pitch = AltosLib.MISSING;
+ public int gyro_yaw = AltosLib.MISSING;
+
+ public int mag_x = AltosLib.MISSING;
+ public int mag_y = AltosLib.MISSING;
+ public int mag_z = AltosLib.MISSING;
+
+ public int mag_along = AltosLib.MISSING;
+ public int mag_across = AltosLib.MISSING;
+ public int mag_through = AltosLib.MISSING;
+
+ public int imu_model = AltosLib.MISSING;
+ public int mag_model = AltosLib.MISSING;
+
+ public static final double counts_per_g_mpu = 2048.0;
+ public static final double counts_per_g_bmx = 2048.0;
+ public static final double counts_per_g_adxl = 20.5;
+
+ private static double counts_per_g(int imu_type, int imu_model) {
+ switch (imu_model) {
+ case AltosLib.model_mpu6000:
+ case AltosLib.model_mpu9250:
+ return counts_per_g_mpu;
+ case AltosLib.model_adxl375:
+ return counts_per_g_adxl;
+ case AltosLib.model_bmx160:
+ return counts_per_g_bmx;
+ }
+
+ switch (imu_type) {
+ case imu_type_telemega_v1_v2:
+ case imu_type_telemega_v3:
+ case imu_type_easymega_v1:
+ case imu_type_easymega_v2:
+ return counts_per_g_mpu;
+ case imu_type_telemega_v4:
+ case imu_type_easytimer_v1:
+ return counts_per_g_bmx;
+ case imu_type_easymotor_v2:
+ return counts_per_g_adxl;
+ }
+
+ return AltosLib.MISSING;
+ }