altosui: Show time since last packet in flight status window
[fw/altos] / altosui / AltosFlightUI.java
index b44b9d43b84c4a7f3f511120a4c2e183c68f028d..dcf852776a0904f4dd78850bb9300c3056440b6c 100644 (file)
@@ -28,7 +28,22 @@ import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
 
-public class AltosFlightUI extends JFrame implements AltosFlightDisplay, AltosFontListener {
+class AltosFlightStatusUpdate implements ActionListener {
+
+       public AltosState       saved_state;
+       AltosFlightStatus       flightStatus;
+
+       public void actionPerformed (ActionEvent e) {
+               if (saved_state != null)
+                       flightStatus.show(saved_state, 0);
+       }
+
+       public AltosFlightStatusUpdate (AltosFlightStatus in_flightStatus) {
+               flightStatus = in_flightStatus;
+       }
+}
+
+public class AltosFlightUI extends AltosFrame implements AltosFlightDisplay, AltosFontListener {
        AltosVoice              voice;
        AltosFlightReader       reader;
        AltosDisplayThread      thread;
@@ -98,7 +113,11 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay, AltosFo
                set_font();
        }
 
+
+       AltosFlightStatusUpdate status_update;
+
        public void show(AltosState state, int crc_errors) {
+               status_update.saved_state = state;
                JComponent tab = which_tab(state);
                try {
                pad.show(state, crc_errors);
@@ -151,6 +170,8 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay, AltosFo
        AltosFreqList   frequencies;
        JComboBox       telemetries;
 
+       ActionListener  show_timer;
+
        public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) {
                AltosPreferences.set_component(this);
 
@@ -289,6 +310,10 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay, AltosFo
 
                thread = new AltosDisplayThread(this, voice, this, reader);
 
+               status_update = new AltosFlightStatusUpdate(flightStatus);
+
+               new javax.swing.Timer(100, status_update).start();
+
                thread.start();
        }