+ public int mag_model = AltosLib.MISSING;
+
+ public static final double counts_per_gauss_hmc5883 = 1090;
+ public static final double counts_per_gauss_mmc5983 = 4096;
+
+ public static double counts_per_gauss(int imu_type, int mag_model) {
+ switch(mag_model) {
+ case AltosLib.model_hmc5883:
+ return counts_per_gauss_hmc5883;
+ case AltosLib.model_mmc5983:
+ return counts_per_gauss_mmc5983;
+ }
+ switch (imu_type) {
+ case AltosIMU.imu_type_telemega_v1_v2:
+ case AltosIMU.imu_type_easymega_v1:
+ return counts_per_gauss_hmc5883;
+ }
+
+ return AltosIMU.counts_per_gauss(imu_type, mag_model);
+ }
+
+ public static double convert_gauss(double counts, int imu_type, int mag_model) {
+ double cpg = counts_per_gauss(imu_type, mag_model);
+
+ if (cpg == AltosLib.MISSING)
+ return AltosLib.MISSING;
+
+ return counts / cpg;