altoslib: Fix 8 to 12 bit conversion for Mega pyro voltage data
authorKeith Packard <keithp@keithp.com>
Sun, 10 Dec 2017 00:57:35 +0000 (16:57 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 10 Dec 2017 00:57:35 +0000 (16:57 -0800)
The conversion was losing the replicated top four bits by shifting by
the wrong amount.

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

index 7ef9c63759fd0e00ff70823903837c9e162973f0..f5961c8c03c87443c946fdf94615ba4b7e7cc701 100644 (file)
@@ -24,7 +24,9 @@ public class AltosTelemetryMegaData extends AltosTelemetryStandard {
 
        int     v_batt() { return int16(6); }
        int     v_pyro() { return int16(8); }
-       int     sense(int i) { int v = uint8(10+i); return v << 4 | v >> 8; }
+
+       /* pyro sense values are sent in 8 bits, expand to 12 bits */
+       int     sense(int i) { int v = uint8(10+i); return (v << 4) | (v >> 4); }
 
        int     ground_pres() { return int32(16); }
        int     ground_accel() { return int16(20); }