summaryrefslogtreecommitdiff
path: root/altoslib/AltosEepromMetrum2.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-07-10 17:10:49 -0700
committerKeith Packard <keithp@keithp.com>2014-07-10 17:35:44 -0700
commited2a08c50d6b8ebcc8c1d2f15e73c1f2a1e25041 (patch)
tree201873b16557375d3204b2e9c79038ae899c3e7f /altoslib/AltosEepromMetrum2.java
parent34d5be68ca23e8beb05db9a480faef63ecc911d0 (diff)
altoslib: Handle wide GPS altitude values in eeprom and telemetry
Detect when the wider data is present and handle it correctly Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosEepromMetrum2.java')
-rw-r--r--altoslib/AltosEepromMetrum2.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/altoslib/AltosEepromMetrum2.java b/altoslib/AltosEepromMetrum2.java
index 2f43879e..d9a65989 100644
--- a/altoslib/AltosEepromMetrum2.java
+++ b/altoslib/AltosEepromMetrum2.java
@@ -49,7 +49,8 @@ public class AltosEepromMetrum2 extends AltosEeprom {
/* AO_LOG_GPS_POS elements */
public int latitude() { return data32(0); }
public int longitude() { return data32(4); }
- public int altitude() { return data16(8); }
+ public int altitude_low() { return data16(8); }
+ public int altitude_high() { return data16(10); }
/* AO_LOG_GPS_TIME elements */
public int hour() { return data8(0); }
@@ -118,7 +119,10 @@ public class AltosEepromMetrum2 extends AltosEeprom {
gps = state.make_temp_gps(false);
gps.lat = latitude() / 1e7;
gps.lon = longitude() / 1e7;
- gps.alt = altitude();
+ if (state.altitude_32())
+ gps.alt = (altitude_low() & 0xffff) | (altitude_high() << 16);
+ else
+ gps.alt = altitude_low();
break;
case AltosLib.AO_LOG_GPS_TIME:
gps = state.make_temp_gps(false);