altoslib: Replace EasyMotor v2 code with v3
authorKeith Packard <keithp@keithp.com>
Mon, 5 Sep 2022 04:04:28 +0000 (21:04 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 5 Sep 2022 04:04:28 +0000 (21:04 -0700)
No v2 boards remain in usable condition and we didn't create a new log
format value for v3, so just replace the v2 code with v3.

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

index 099ea04859337bb14e0799df62d607eabc97f9d8..3e1796b2c194bfbeb212a9adbe675a0917642201 100644 (file)
@@ -323,6 +323,16 @@ public class AltosConvert {
                return (voltage - base) / (max - base) * full_scale_pressure;
        }
 
+       static double easy_motor_3_adc(double raw) {
+               return raw / 32767.0;
+       }
+
+       static double easy_motor_3_voltage(int sensor) {
+               double  supply = 3.3;
+
+               return easy_motor_3_adc(sensor) * supply * 15.6 / 10.0;
+       }
+
        static double easy_motor_2_motor_pressure(int sensor, double ground_sensor) {
                double  supply = 3.3;
                double  ground_voltage = easy_mini_2_adc(ground_sensor) * supply * 15.6 / 10.0;
@@ -331,6 +341,14 @@ public class AltosConvert {
                return motor_pressure(voltage) - motor_pressure(ground_voltage);
        }
 
+       static double easy_motor_3_motor_pressure(int sensor, double ground_sensor) {
+               double  supply = 3.3;
+               double  ground_voltage = easy_motor_3_adc(ground_sensor) * supply * 15.6 / 10.0;
+               double  voltage = easy_motor_3_adc(sensor) * supply * 15.6 / 10.0;
+
+               return motor_pressure(voltage) - motor_pressure(ground_voltage);
+       }
+
        public static double radio_to_frequency(int freq, int setting, int cal, int channel) {
                double  f;
 
index a8f35db476c58f0a214f038c2f007dcdecde03c3..d5068b08d3f9d10b2222ff7b4137c42f9c0e3ff2 100644 (file)
@@ -68,8 +68,8 @@ public class AltosEepromRecordMotor extends AltosEepromRecord {
                case AltosLib.AO_LOG_SENSOR:
                        AltosConfigData config_data = eeprom.config_data();
 
-                       listener.set_battery_voltage(AltosConvert.easy_mini_2_voltage(v_batt()));
-                       double pa = AltosConvert.easy_motor_2_motor_pressure(motor_pres(), cal_data.ground_motor_pressure);
+                       listener.set_battery_voltage(AltosConvert.easy_motor_3_voltage(v_batt()));
+                       double pa = AltosConvert.easy_motor_3_motor_pressure(motor_pres(), cal_data.ground_motor_pressure);
                        listener.set_motor_pressure(pa);
 
                        int     accel_along = accel_along();