X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=telegps%2FTeleGPSStatus.java;h=5479f43a025927f762c4051aed61dff1b84185d6;hb=bc150497de8539827177805c7f4430c67ca6762f;hp=1d4415d6064d400444891ea769c3a0643a3ac0ea;hpb=bd440afc2a6e37b74fffcf1b977e149485095316;p=fw%2Faltos diff --git a/telegps/TeleGPSStatus.java b/telegps/TeleGPSStatus.java index 1d4415d6..5479f43a 100644 --- a/telegps/TeleGPSStatus.java +++ b/telegps/TeleGPSStatus.java @@ -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_5.*; -import org.altusmetrum.altosuilib_3.*; +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();