* Track flight state from telemetry or eeprom data stream
*/
-package org.altusmetrum.altoslib_4;
+package org.altusmetrum.altoslib_5;
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? */
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();
}
speak_altitude = AltosLib.MISSING;
callsign = null;
+ firmware_version = null;
accel_plus_g = AltosLib.MISSING;
accel_minus_g = AltosLib.MISSING;
product = null;
serial = AltosLib.MISSING;
receiver_serial = AltosLib.MISSING;
+ altitude_32 = AltosLib.MISSING;
baro = null;
companion = null;
speak_altitude = old.speak_altitude;
callsign = old.callsign;
+ firmware_version = old.firmware_version;
accel_plus_g = old.accel_plus_g;
accel_minus_g = old.accel_minus_g;
product = old.product;
serial = old.serial;
receiver_serial = old.receiver_serial;
+ altitude_32 = old.altitude_32;
baro = old.baro;
companion = old.companion;
}
void update_gps() {
- elevation = 0;
- range = -1;
+ elevation = AltosLib.MISSING;
+ range = AltosLib.MISSING;
if (gps == null)
return;
firmware_version = version;
}
+ public int compare_version(String other_version) {
+ if (firmware_version == null)
+ return AltosLib.MISSING;
+ return AltosLib.compare_version(firmware_version, other_version);
+ }
+
+ private void re_init() {
+ int bt = boost_tick;
+ int rs = receiver_serial;
+ init();
+ boost_tick = bt;
+ receiver_serial = rs;
+ }
+
public void set_flight(int flight) {
/* When the flight changes, reset the state */
- if (flight != AltosLib.MISSING && flight != 0) {
+ if (flight != AltosLib.MISSING) {
if (this.flight != AltosLib.MISSING &&
this.flight != flight) {
- int bt = boost_tick;
- init();
- boost_tick = bt;
+ re_init();
}
this.flight = flight;
}
if (serial != AltosLib.MISSING) {
if (this.serial != AltosLib.MISSING &&
this.serial != serial) {
- int bt = boost_tick;
- init();
- boost_tick = bt;
+ re_init();
}
this.serial = serial;
}
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;