ao-tools/ao-flash-lpc: Adapt to current openocd LPC support
[fw/altos] / telegps / TeleGPSStatus.java
index f3951a37544dbc80d900024f3d78adb87adf49df..5479f43a025927f762c4051aed61dff1b84185d6 100644 (file)
@@ -3,7 +3,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
@@ -19,8 +20,8 @@ package org.altusmetrum.telegps;
 
 import java.awt.*;
 import javax.swing.*;
-import org.altusmetrum.altoslib_4.*;
-import org.altusmetrum.altosuilib_2.*;
+import org.altusmetrum.altoslib_11.*;
+import org.altusmetrum.altosuilib_11.*;
 
 public class TeleGPSStatus extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
@@ -179,11 +180,15 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay {
                long    last_secs = -1;
 
                void show(AltosState state, AltosListenerState listener_state) {
-                       long secs = (System.currentTimeMillis() - state.received_time + 500) / 1000;
-
-                       if (secs != last_secs) {
-                               value.setText(String.format("%d", secs));
-                               last_secs = secs;
+                       if (listener_state.running) {
+                               long secs = (System.currentTimeMillis() - state.received_time + 500) / 1000;
+
+                               if (secs != last_secs) {
+                                       value.setText(String.format("%d", secs));
+                                       last_secs = secs;
+                               }
+                       } else {
+                               value.setText("done");
                        }
                }
 
@@ -232,6 +237,8 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay {
                flight.show(state, listener_state);
                rssi.show(state, listener_state);
                last_packet.show(state, listener_state);
+               if (!listener_state.running)
+                       stop();
        }
 
        public int height() {
@@ -239,6 +246,22 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay {
                return d.height;
        }
 
+       TeleGPSStatusUpdate     status_update;
+       javax.swing.Timer       timer;
+
+       public void start(TeleGPSStatusUpdate status_update) {
+               this.status_update = status_update;
+               timer = new javax.swing.Timer(100, status_update);
+               timer.start();
+       }
+
+       public void stop() {
+               if (timer != null) {
+                       timer.stop();
+                       timer = null;
+               }
+       }
+
        public TeleGPSStatus() {
                layout = new GridBagLayout();