diff options
author | Keith Packard <keithp@keithp.com> | 2017-05-27 16:12:31 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2017-05-27 16:12:31 -0700 |
commit | 855a7d243a5a85728a7b23fdfe9485d4ecaf71cf (patch) | |
tree | 19a8189f462119b9e9790f2768c7bcd8480d41b5 /telegps/TeleGPSDisplayThread.java | |
parent | b6b5c64f93fa56bcb22ea1c4279e4f754e6e6f1c (diff) |
telegps: Get telegps application working again
Many minor API tweaks
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'telegps/TeleGPSDisplayThread.java')
-rw-r--r-- | telegps/TeleGPSDisplayThread.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/telegps/TeleGPSDisplayThread.java b/telegps/TeleGPSDisplayThread.java index a9c80dc0..c311dd7e 100644 --- a/telegps/TeleGPSDisplayThread.java +++ b/telegps/TeleGPSDisplayThread.java @@ -31,7 +31,9 @@ public class TeleGPSDisplayThread extends Thread { IdleThread idle_thread; AltosVoice voice; AltosFlightReader reader; - AltosState old_state, state; + AltosState state; + int old_state = AltosLib.ao_flight_invalid; + boolean old_gps_ready = false; AltosListenerState listener_state; AltosFlightDisplay display; @@ -130,11 +132,12 @@ public class TeleGPSDisplayThread extends Thread { } public synchronized void notice(boolean spoken) { - if (old_state != null && old_state.state() != state.state()) { + if (old_state != state.state()) { report_time = now(); this.notify(); } else if (spoken) set_report_time(); + old_state = state.state(); } public IdleThread() { @@ -144,17 +147,17 @@ public class TeleGPSDisplayThread extends Thread { synchronized boolean tell() { boolean ret = false; - if (old_state == null || old_state.gps_ready != state.gps_ready) { + if (old_gps_ready != state.gps_ready) { if (state.gps_ready) { voice.speak("GPS ready"); ret = true; } - else if (old_state != null) { + else if (old_gps_ready) { voice.speak("GPS lost"); ret = true; } + old_gps_ready = state.gps_ready; } - old_state = state; return ret; } @@ -173,7 +176,6 @@ public class TeleGPSDisplayThread extends Thread { listener_state.running = false; break; } - reader.update(state); show_safely(); told = tell(); idle_thread.notice(told); |