diff options
author | Keith Packard <keithp@keithp.com> | 2014-04-02 22:04:18 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2014-04-02 22:04:18 -0700 |
commit | 21d584b9bf93b96a05ab374105493c0e17df320f (patch) | |
tree | 92118f82b30eb2b0fbfd8396cadb15d71c63ac39 /altoslib/AltosConvert.java | |
parent | adddad0dd45f67d01487c8dd75b040ca3ab50fe2 (diff) |
altoslib: Fix EasyMini voltage computations
Early Em prototypes had a 3.0V regulator.
Early v1.0 boards measured power past the blocking diode.
Deal with both conditions to try and report more accurate voltages for
EasyMini data.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosConvert.java')
-rw-r--r-- | altoslib/AltosConvert.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 8f214c8b..35923ec3 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -224,10 +224,21 @@ public class AltosConvert { return sensor / 32767.0 * supply * 127/27; } - static double easy_mini_voltage(int sensor) { - double supply = 3.0; + static double easy_mini_voltage(int sensor, int serial) { + double supply = 3.3; + double diode_offset = 0.0; - return sensor / 32767.0 * supply * 127/27; + /* early prototypes had a 3.0V regulator */ + if (serial < 1000) + supply = 3.0; + + /* Purple v1.0 boards had the sensor after the + * blocking diode, which drops about 150mV + */ + if (serial < 1665) + diode_offset = 0.150; + + return sensor / 32767.0 * supply * 127/27 + diode_offset; } public static double radio_to_frequency(int freq, int setting, int cal, int channel) { |