summaryrefslogtreecommitdiff
path: root/altoslib/AltosState.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-07-10 17:27:43 -0700
committerKeith Packard <keithp@keithp.com>2014-07-10 17:35:44 -0700
commit59702e5ff8d0522b0aa9dcca863309eaafbcda09 (patch)
treec55a101785c8529f81cdb8463b738883a5b0e470 /altoslib/AltosState.java
parent6dc58c63d202e918f16d5fbe9b188d422edcdd9c (diff)
altoslib: Extend telemetry heights from 16 to 32 bits
Uses the GPS data and/or previous kalman data to compute the upper 16 bits of the truncated telemetry altitude value. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosState.java')
-rw-r--r--altoslib/AltosState.java28
1 files changed, 24 insertions, 4 deletions
diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java
index 2fc13b44..5fce15c4 100644
--- a/altoslib/AltosState.java
+++ b/altoslib/AltosState.java
@@ -271,6 +271,7 @@ public class AltosState implements Cloneable {
public int state;
public int flight;
public int serial;
+ public int altitude_32;
public int receiver_serial;
public boolean landed;
public boolean ascent; /* going up? */
@@ -472,15 +473,23 @@ public class AltosState implements Cloneable {
pressure.set(p, time);
}
+ public double baro_height() {
+ double a = altitude();
+ double g = ground_altitude();
+ if (a != AltosLib.MISSING && g != AltosLib.MISSING)
+ return a - g;
+ return AltosLib.MISSING;
+ }
+
public double height() {
double k = kalman_height.value();
if (k != AltosLib.MISSING)
return k;
- double a = altitude();
- double g = ground_altitude();
- if (a != AltosLib.MISSING && g != AltosLib.MISSING)
- return a - g;
+ double b = baro_height();
+ if (b != AltosLib.MISSING)
+ return b;
+
return gps_height();
}
@@ -762,6 +771,7 @@ public class AltosState implements Cloneable {
product = null;
serial = AltosLib.MISSING;
receiver_serial = AltosLib.MISSING;
+ altitude_32 = AltosLib.MISSING;
baro = null;
companion = null;
@@ -899,6 +909,7 @@ public class AltosState implements Cloneable {
product = old.product;
serial = old.serial;
receiver_serial = old.receiver_serial;
+ altitude_32 = old.altitude_32;
baro = old.baro;
companion = old.companion;
@@ -1066,6 +1077,15 @@ public class AltosState implements Cloneable {
receiver_serial = serial;
}
+ public boolean altitude_32() {
+ return altitude_32 == 1;
+ }
+
+ public void set_altitude_32(int altitude_32) {
+ if (altitude_32 != AltosLib.MISSING)
+ this.altitude_32 = altitude_32;
+ }
+
public int rssi() {
if (rssi == AltosLib.MISSING)
return 0;