From: Keith Packard Date: Mon, 5 Sep 2022 04:04:28 +0000 (-0700) Subject: altoslib: Replace EasyMotor v2 code with v3 X-Git-Tag: 1.9.12~1^2~28 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=41cf6f6f65681961ed98a59b9fc9da4fe5abef5a altoslib: Replace EasyMotor v2 code with v3 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 --- diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 099ea048..3e1796b2 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -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; diff --git a/altoslib/AltosEepromRecordMotor.java b/altoslib/AltosEepromRecordMotor.java index a8f35db4..d5068b08 100644 --- a/altoslib/AltosEepromRecordMotor.java +++ b/altoslib/AltosEepromRecordMotor.java @@ -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();