altoslib: Handle EasyMini v2.0 ADC values
authorKeith Packard <keithp@keithp.com>
Mon, 12 Jun 2017 05:46:01 +0000 (22:46 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 12 Jun 2017 05:54:22 +0000 (22:54 -0700)
Different from EasyMini v1.0

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosConvert.java
altoslib/AltosEepromRecordMini.java
altoslib/AltosEepromRecordSet.java
altoslib/AltosLib.java

index 0d25c6d76d0eb50061a4938c4f5d9ed418a83524..9eb8d16a4dafa6fe47c1c4d0482ba022264ec98a 100644 (file)
@@ -270,7 +270,15 @@ public class AltosConvert {
                return 3.3 * mega_adc(raw) * (5.1 + 10.0) / 10.0;
        }
 
-       static double easy_mini_voltage(int sensor, int serial) {
+       static double easy_mini_2_adc(int raw) {
+               return raw / 4095.0;
+       }
+
+       static double easy_mini_1_adc(int raw) {
+               return raw / 32767.0;
+       }
+
+       static double easy_mini_1_voltage(int sensor, int serial) {
                double  supply = 3.3;
                double  diode_offset = 0.0;
 
@@ -284,7 +292,13 @@ public class AltosConvert {
                if (serial < 1665)
                        diode_offset = 0.150;
 
-               return sensor / 32767.0 * supply * 127/27 + diode_offset;
+               return easy_mini_1_adc(sensor) * supply * 127/27 + diode_offset;
+       }
+
+       static double easy_mini_2_voltage(int sensor) {
+               double  supply = 3.3;
+
+               return easy_mini_2_adc(sensor) * supply * 127/27;
        }
 
        public static double radio_to_frequency(int freq, int setting, int cal, int channel) {
index 4b3a564e2eeaa17e85872d44910643eb542ac8d6..22bd073a59789d5ac280ba56274fc9df25904d15 100644 (file)
@@ -42,8 +42,10 @@ public class AltosEepromRecordMini extends AltosEepromRecord {
 
        private double battery_voltage(int sensor) {
                int log_format = log_format();
-               if (log_format == AltosLib.AO_LOG_FORMAT_EASYMINI)
-                       return AltosConvert.easy_mini_voltage(sensor, eeprom.config_data().serial);
+               if (log_format == AltosLib.AO_LOG_FORMAT_EASYMINI1)
+                       return AltosConvert.easy_mini_1_voltage(sensor, eeprom.config_data().serial);
+               if (log_format == AltosLib.AO_LOG_FORMAT_EASYMINI2)
+                       return AltosConvert.easy_mini_2_voltage(sensor);
                if (log_format == AltosLib.AO_LOG_FORMAT_TELEMINI2)
                        return AltosConvert.tele_mini_2_voltage(sensor);
                if (log_format == AltosLib.AO_LOG_FORMAT_TELEMINI3)
@@ -53,8 +55,10 @@ public class AltosEepromRecordMini extends AltosEepromRecord {
 
        private double pyro_voltage(int sensor) {
                int log_format = log_format();
-               if (log_format == AltosLib.AO_LOG_FORMAT_EASYMINI)
-                       return AltosConvert.easy_mini_voltage(sensor, eeprom.config_data().serial);
+               if (log_format == AltosLib.AO_LOG_FORMAT_EASYMINI1)
+                       return AltosConvert.easy_mini_1_voltage(sensor, eeprom.config_data().serial);
+               if (log_format == AltosLib.AO_LOG_FORMAT_EASYMINI2)
+                       return AltosConvert.easy_mini_2_voltage(sensor);
                if (log_format == AltosLib.AO_LOG_FORMAT_TELEMINI2)
                        return AltosConvert.tele_mini_2_voltage(sensor);
                if (log_format == AltosLib.AO_LOG_FORMAT_TELEMINI3)
index 7b111ed3d18d9d0cfa86df3eeb21d1321eba6001..1f10e677ee29540d9731c55749d73778eaf26d8d 100644 (file)
@@ -75,7 +75,8 @@ public class AltosEepromRecordSet implements AltosRecordSet {
                        break;
                case AltosLib.AO_LOG_FORMAT_TELEMINI2:
                case AltosLib.AO_LOG_FORMAT_TELEMINI3:
-               case AltosLib.AO_LOG_FORMAT_EASYMINI:
+               case AltosLib.AO_LOG_FORMAT_EASYMINI1:
+               case AltosLib.AO_LOG_FORMAT_EASYMINI2:
                        record = new AltosEepromRecordMini(eeprom);
                        break;
                case AltosLib.AO_LOG_FORMAT_TELEGPS:
index 6c1729dfc03a32a51f64f3d8fbf2eabf092ec652..6cf875a9dec9b6f0bd98c559bf354ff7c12c02a7 100644 (file)
@@ -354,7 +354,7 @@ public class AltosLib {
        public static final int AO_LOG_FORMAT_TELEMETRY = 3;
        public static final int AO_LOG_FORMAT_TELESCIENCE = 4;
        public static final int AO_LOG_FORMAT_TELEMEGA_OLD = 5;
-       public static final int AO_LOG_FORMAT_EASYMINI = 6;
+       public static final int AO_LOG_FORMAT_EASYMINI1 = 6;
        public static final int AO_LOG_FORMAT_TELEMETRUM = 7;
        public static final int AO_LOG_FORMAT_TELEMINI2 = 8;
        public static final int AO_LOG_FORMAT_TELEGPS = 9;
@@ -362,6 +362,7 @@ public class AltosLib {
        public static final int AO_LOG_FORMAT_DETHERM = 11;
        public static final int AO_LOG_FORMAT_TELEMINI3 = 12;
        public static final int AO_LOG_FORMAT_TELEFIRETWO = 13;
+       public static final int AO_LOG_FORMAT_EASYMINI2 = 14;
        public static final int AO_LOG_FORMAT_NONE = 127;
 
        public static boolean isspace(int c) {