altos: Use #define values for ublox packet types
[fw/altos] / altosui / AltosDisplayThread.java
index 095bed992c08c524d5718e21066ece2b20ad5df6..37f6adf9051613ec0686b0564dacfc442e128024 100644 (file)
@@ -21,7 +21,7 @@ import java.awt.*;
 import javax.swing.*;
 import java.io.*;
 import java.text.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
 
 public class AltosDisplayThread extends Thread {
 
@@ -92,14 +92,14 @@ public class AltosDisplayThread extends Thread {
                            state.range >= 0)
                        {
                                voice.speak("Height %s, bearing %s %d, elevation %d, range %s.\n",
-                                           AltosConvert.height.say(state.height),
+                                           AltosConvert.height.say(state.height()),
                                            state.from_pad.bearing_words(
                                                    AltosGreatCircle.BEARING_VOICE),
                                            (int) (state.from_pad.bearing + 0.5),
                                            (int) (state.elevation + 0.5),
                                            AltosConvert.distance.say(state.range));
                        } else if (state.state > Altos.ao_flight_pad) {
-                               voice.speak(AltosConvert.height.say_units(state.height));
+                               voice.speak(AltosConvert.height.say_units(state.height()));
                        } else {
                                reported_landing = 0;
                        }
@@ -110,10 +110,10 @@ public class AltosDisplayThread extends Thread {
                         */
                        if (state.state >= Altos.ao_flight_drogue &&
                            (last ||
-                            System.currentTimeMillis() - state.report_time >= 15000 ||
+                            System.currentTimeMillis() - state.received_time >= 15000 ||
                             state.state == Altos.ao_flight_landed))
                        {
-                               if (Math.abs(state.baro_speed) < 20 && state.height < 100)
+                               if (Math.abs(state.speed()) < 20 && state.height() < 100)
                                        voice.speak("rocket landed safely");
                                else
                                        voice.speak("rocket may have crashed");
@@ -181,16 +181,16 @@ public class AltosDisplayThread extends Thread {
        synchronized boolean tell() {
                boolean ret = false;
                if (old_state == null || old_state.state != state.state) {
-                       voice.speak(state.data.state());
+                       voice.speak(state.state_name());
                        if ((old_state == null || old_state.state <= Altos.ao_flight_boost) &&
                            state.state > Altos.ao_flight_boost) {
                                voice.speak("max speed: %s.",
-                                           AltosConvert.speed.say_units(state.max_accel_speed + 0.5));
+                                           AltosConvert.speed.say_units(state.max_speed() + 0.5));
                                ret = true;
                        } else if ((old_state == null || old_state.state < Altos.ao_flight_drogue) &&
                                   state.state >= Altos.ao_flight_drogue) {
                                voice.speak("max height: %s.",
-                                           AltosConvert.height.say_units(state.max_height + 0.5));
+                                           AltosConvert.height.say_units(state.max_height() + 0.5));
                                ret = true;
                        }
                }
@@ -218,11 +218,9 @@ public class AltosDisplayThread extends Thread {
                try {
                        for (;;) {
                                try {
-                                       AltosRecord record = reader.read();
-                                       if (record == null)
+                                       state = reader.read();
+                                       if (state == null)
                                                break;
-                                       old_state = state;
-                                       state = new AltosState(record, state);
                                        reader.update(state);
                                        show_safely();
                                        told = tell();