* Track flight state from telemetry or eeprom data stream
*/
-package org.altusmetrum.altoslib_7;
+package org.altusmetrum.altoslib_9;
import java.io.*;
public int set;
+ static final double filter_len = 2.0;
static final double ascent_filter_len = 0.5;
- static final double descent_filter_len = 0.5;
+ static final double descent_filter_len = 5.0;
/* derived data */
}
void set_filtered(double new_value, double time) {
- if (prev_value != AltosLib.MISSING)
- new_value = (prev_value * 15.0 + new_value) / 16.0;
+ if (prev_value != AltosLib.MISSING) {
+ double f = 1/Math.exp((time - prev_set_time) / filter_len);
+ new_value = f * new_value + (1-f) * prev_value;
+ }
set(new_value, time);
}
}
}
- public int state;
+ private int state;
public int flight;
public int serial;
public int altitude_32;
return AltosLib.state_name(state);
}
+ public void set_product(String product) {
+ this.product = product;
+ }
+
public void set_state(int state) {
if (state != AltosLib.ao_flight_invalid) {
this.state = state;
}
}
+ public int state() {
+ return state;
+ }
+
public void set_device_type(int device_type) {
this.device_type = device_type;
switch (device_type) {
}
}
- public void make_companion (int nchannels) {
- if (companion == null)
- companion = new AltosCompanion(nchannels);
- }
-
public void set_companion(AltosCompanion companion) {
this.companion = companion;
}