summaryrefslogtreecommitdiff
path: root/altoslib/AltosCalData.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2017-10-22 14:04:09 -0500
committerKeith Packard <keithp@keithp.com>2017-10-22 14:04:09 -0500
commit749400fd244eba38806c623d2a35722642230698 (patch)
tree39f95bc777544c6bd80f71ba824b81133edf6379 /altoslib/AltosCalData.java
parente98235e314ac764509af26c93da9e6d1de8184ea (diff)
altoslib: Move temp GPS API from cal_data to data_listener
This makes the API more consistent, and means that the listener is responsible for mangaing the temp gps state. In particular, the AltosDataListener set_gps API now calls the cal_data function. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosCalData.java')
-rw-r--r--altoslib/AltosCalData.java39
1 files changed, 16 insertions, 23 deletions
diff --git a/altoslib/AltosCalData.java b/altoslib/AltosCalData.java
index 7415d5ad..fdea5e21 100644
--- a/altoslib/AltosCalData.java
+++ b/altoslib/AltosCalData.java
@@ -199,7 +199,6 @@ public class AltosCalData {
tick = AltosLib.MISSING;
prev_tick = AltosLib.MISSING;
temp_gps = null;
- prev_gps = null;
temp_gps_sat_tick = AltosLib.MISSING;
accel = AltosLib.MISSING;
}
@@ -244,11 +243,14 @@ public class AltosCalData {
public double gps_pad_altitude = AltosLib.MISSING;
- public void set_gps(AltosGPS gps) {
- if ((state != AltosLib.MISSING && state < AltosLib.ao_flight_boost) || gps_pad == null)
- gps_pad = gps;
- if (gps_pad_altitude == AltosLib.MISSING && gps.alt != AltosLib.MISSING)
- gps_pad_altitude = gps.alt;
+ public void set_cal_gps(AltosGPS gps) {
+ if (gps.locked && gps.nsat >= 4) {
+ if ((state != AltosLib.MISSING && state < AltosLib.ao_flight_boost) || gps_pad == null)
+ gps_pad = gps;
+ if (gps_pad_altitude == AltosLib.MISSING && gps.alt != AltosLib.MISSING)
+ gps_pad_altitude = gps.alt;
+ }
+ temp_gps = null;
}
/*
@@ -256,33 +258,24 @@ public class AltosCalData {
* object and then deliver the result atomically to the listener
*/
AltosGPS temp_gps = null;
- AltosGPS prev_gps = null;
int temp_gps_sat_tick = AltosLib.MISSING;
- public AltosGPS temp_gps() {
+ public AltosGPS temp_cal_gps() {
return temp_gps;
}
- public void reset_temp_gps() {
- if (temp_gps != null) {
- if (temp_gps.locked && temp_gps.nsat >= 4)
- set_gps(temp_gps);
- prev_gps = temp_gps;
- temp_gps = null;
- }
+ public void reset_temp_cal_gps() {
+ if (temp_gps != null)
+ set_cal_gps(temp_gps);
}
- public boolean gps_pending() {
+ public boolean cal_gps_pending() {
return temp_gps != null;
}
- public AltosGPS make_temp_gps(int tick, boolean sats) {
- if (temp_gps == null) {
- if (prev_gps != null)
- temp_gps = prev_gps.clone();
- else
- temp_gps = new AltosGPS();
- }
+ public AltosGPS make_temp_cal_gps(int tick, boolean sats) {
+ if (temp_gps == null)
+ temp_gps = new AltosGPS();
if (sats) {
if (tick != temp_gps_sat_tick)
temp_gps.cc_gps_sat = null;