summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-03-26 22:04:13 -0700
committerKeith Packard <keithp@keithp.com>2012-03-26 22:04:13 -0700
commit8610fdae8f47e1e8b6e8525227cc912664ecfafd (patch)
tree9c2091390470aaef033f695cac0937c5a3c960c0
parent392a3107b9e9cc8c1ea51df6ff5ec54817adbc65 (diff)
altosui: Show time since last packet in flight status window
Makes it easy to see when the UI is wedged, and when telemetry data are being successfully received. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--altosui/AltosFlightStatus.java18
-rw-r--r--altosui/AltosFlightUI.java25
2 files changed, 42 insertions, 1 deletions
diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java
index ed273384..45e55b4b 100644
--- a/altosui/AltosFlightStatus.java
+++ b/altosui/AltosFlightStatus.java
@@ -119,18 +119,31 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
value.setText(String.format("%d", state.data.rssi));
}
public RSSI (GridBagLayout layout, int x) {
- super (layout, x, "RSSI (dBm)");
+ super (layout, x, "RSSI");
}
}
RSSI rssi;
+ class LastPacket extends FlightValue {
+ void show(AltosState state, int crc_errors) {
+ long secs = (System.currentTimeMillis() - state.report_time + 500) / 1000;
+ value.setText(String.format("%d", secs));
+ }
+ public LastPacket(GridBagLayout layout, int x) {
+ super (layout, x, "Age");
+ }
+ }
+
+ LastPacket last_packet;
+
public void reset () {
call.reset();
serial.reset();
flight.reset();
flight_state.reset();
rssi.reset();
+ last_packet.reset();
}
public void set_font () {
@@ -139,6 +152,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
flight.set_font();
flight_state.set_font();
rssi.set_font();
+ last_packet.set_font();
}
public void show (AltosState state, int crc_errors) {
@@ -147,6 +161,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
flight.show(state, crc_errors);
flight_state.show(state, crc_errors);
rssi.show(state, crc_errors);
+ last_packet.show(state, crc_errors);
}
public int height() {
@@ -164,5 +179,6 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
flight = new Flight(layout, 2);
flight_state = new FlightState(layout, 3);
rssi = new RSSI(layout, 4);
+ last_packet = new LastPacket(layout, 5);
}
}
diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java
index d166c9ae..dcf85277 100644
--- a/altosui/AltosFlightUI.java
+++ b/altosui/AltosFlightUI.java
@@ -28,6 +28,21 @@ import java.text.*;
import java.util.prefs.*;
import java.util.concurrent.*;
+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;
@@ -98,7 +113,11 @@ public class AltosFlightUI extends AltosFrame implements AltosFlightDisplay, Alt
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 AltosFrame implements AltosFlightDisplay, Alt
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 AltosFrame implements AltosFlightDisplay, Alt
thread = new AltosDisplayThread(this, voice, this, reader);
+ status_update = new AltosFlightStatusUpdate(flightStatus);
+
+ new javax.swing.Timer(100, status_update).start();
+
thread.start();
}