altosdroid: Deal with AltosState changes
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / AltosVoice.java
index d7c0f6237c4843a551e0451c4ecca3110117e9e7..308c50e7d182eb7f3622f1a0082c1ebebb957fcf 100644 (file)
@@ -4,7 +4,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -48,6 +49,7 @@ public class AltosVoice {
        private Location        last_receiver;
        private long            last_speak_time;
        private int             last_flight_tell = TELL_FLIGHT_NONE;
+       private boolean         quiet = false;
 
        private long now() {
                return System.currentTimeMillis();
@@ -79,7 +81,8 @@ public class AltosVoice {
        public synchronized void speak(String s) {
                if (!tts_enabled) return;
                last_speak_time = now();
-               tts.speak(s, TextToSpeech.QUEUE_ADD, null);
+               if (!quiet)
+                       tts.speak(s, TextToSpeech.QUEUE_ADD, null);
        }
 
        public synchronized long time_since_speak() {
@@ -120,6 +123,8 @@ public class AltosVoice {
                if (state == null)
                        return false;
 
+               AltosDebug.debug("tell_pad lag %b ltm %d\n", last_apogee_good, last_tell_mode);
+
                if (state.apogee_voltage != AltosLib.MISSING)
                        last_apogee_good = tell_gonogo("apogee",
                                                       state.apogee_voltage >= AltosLib.ao_igniter_good,
@@ -276,7 +281,9 @@ public class AltosVoice {
 
        public void tell(TelemetryState telem_state, AltosState state,
                         AltosGreatCircle from_receiver, Location receiver,
-                        AltosDroidTab tab) {
+                        AltosDroidTab tab, boolean quiet) {
+
+               this.quiet = quiet;
 
                boolean spoken = false;
 
@@ -287,7 +294,7 @@ public class AltosVoice {
                int     tell_serial = last_tell_serial;
 
                if (state != null)
-                       tell_serial = state.serial;
+                       tell_serial = state.cal_data.serial;
 
                if (tell_serial != last_tell_serial)
                        reset_last();