altoslib: Support TeleBT v3.0 battery voltage conversion
authorKeith Packard <keithp@keithp.com>
Fri, 26 Jun 2015 01:31:29 +0000 (18:31 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 26 Jun 2015 01:43:13 +0000 (18:43 -0700)
TeleBT v3.0 uses an STM32 instead of a cc1111, so it needs a different
voltage computation from the raw ADC value.

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

index 5750afad42338f5d24819eb28e7b4b4b7af11342..3e0f0e1ac99170caa03b1a626575fd936bae1873 100644 (file)
@@ -230,6 +230,12 @@ public class AltosConvert {
                return sensor / 32767.0 * supply * (5.6 + 10.0) / 10.0;
        }
 
+       static double tele_bt_3_battery(int raw) {
+               if (raw == AltosLib.MISSING)
+                       return AltosLib.MISSING;
+               return 3.3 * mega_adc(raw) * (5.1 + 10.0) / 10.0;
+       }
+
        static double easy_mini_voltage(int sensor, int serial) {
                double  supply = 3.3;
                double  diode_offset = 0.0;
index 4f3a1ed24a1d3db89b4393a5771d8b8c050c6857..e33f7c77b27e32e2e1af70fdfde23334f85eac61 100644 (file)
@@ -553,7 +553,15 @@ public abstract class AltosLink implements Runnable {
                }
                if (monitor_batt == AltosLib.MISSING)
                        return AltosLib.MISSING;
-               return AltosConvert.cc_battery_to_voltage(monitor_batt);
+
+               double  volts = AltosLib.MISSING;
+               if (config_data.product.startsWith("TeleBT-v3")) {
+                       volts = AltosConvert.tele_bt_3_battery(monitor_batt);
+               } else {
+                       volts = AltosConvert.cc_battery_to_voltage(monitor_batt);
+               }
+
+               return volts;
        }
 
        public AltosLink() {