X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosdroid%2Fsrc%2Forg%2Faltusmetrum%2FAltosDroid%2FAltosVoice.java;h=ae3299facba66c76ea1ed15aa02308b276a982ac;hp=adf52dd9ab8f7907bf18fb95ee845ab31079a927;hb=4a257455b2dc57069c41e1845daf66239c5cbe1d;hpb=643c2fb03833d658320f476ef731bbb06fe3cc31 diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java index adf52dd9..ae3299fa 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java @@ -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 @@ -22,7 +23,7 @@ import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech.OnInitListener; import android.location.Location; -import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altoslib_13.*; public class AltosVoice { @@ -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, @@ -186,9 +191,9 @@ public class AltosVoice { if (last_tell_mode != TELL_MODE_FLIGHT) last_flight_tell = TELL_FLIGHT_NONE; - if (state.state != last_state && AltosLib.ao_flight_boost <= state.state && state.state <= AltosLib.ao_flight_landed) { + if (state.state() != last_state && AltosLib.ao_flight_boost <= state.state() && state.state() <= AltosLib.ao_flight_landed) { speak(state.state_name()); - if (descending(state.state) && !descending(last_state)) { + if (descending(state.state()) && !descending(last_state)) { if (state.max_height() != AltosLib.MISSING) { speak("max height: %s.", AltosConvert.height.say_units(state.max_height())); @@ -211,7 +216,7 @@ public class AltosVoice { if (last_flight_tell == TELL_FLIGHT_NONE || last_flight_tell == TELL_FLIGHT_STATE || last_flight_tell == TELL_FLIGHT_TRACK) { last_flight_tell = TELL_FLIGHT_SPEED; - if (state.state <= AltosLib.ao_flight_coast) { + if (state.state() <= AltosLib.ao_flight_coast) { speed = state.speed(); } else { speed = state.gps_speed(); @@ -238,12 +243,12 @@ public class AltosVoice { if (last_flight_tell == TELL_FLIGHT_HEIGHT) { last_flight_tell = TELL_FLIGHT_TRACK; if (from_receiver != null) { - speak("bearing %s %d, elevation %d, range %s.", + speak("bearing %s %d, elevation %d, distance %s.", from_receiver.bearing_words( AltosGreatCircle.BEARING_VOICE), (int) (from_receiver.bearing + 0.5), (int) (from_receiver.elevation + 0.5), - AltosConvert.distance.say(from_receiver.range)); + AltosConvert.distance.say(from_receiver.distance)); return true; } } @@ -268,7 +273,7 @@ public class AltosVoice { if (direction == null) direction = String.format("Bearing %d", (int) (from_receiver.bearing + 0.5)); - speak("%s, range %s.", direction, + speak("%s, distance %s.", direction, AltosConvert.distance.say_units(from_receiver.distance)); return true; @@ -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(); @@ -312,7 +319,7 @@ public class AltosVoice { last_tell_mode = tell_mode; last_tell_serial = tell_serial; if (state != null) { - last_state = state.state; + last_state = state.state(); last_height = state.height(); if (state.gps != null) last_gps = state.gps;