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 () {
flight.set_font();
flight_state.set_font();
rssi.set_font();
+ last_packet.set_font();
}
public void show (AltosState state, int crc_errors) {
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() {
flight = new Flight(layout, 2);
flight_state = new FlightState(layout, 3);
rssi = new RSSI(layout, 4);
+ last_packet = new LastPacket(layout, 5);
}
}
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;
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);
AltosFreqList frequencies;
JComboBox telemetries;
+ ActionListener show_timer;
+
public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) {
AltosPreferences.set_component(this);
thread = new AltosDisplayThread(this, voice, this, reader);
+ status_update = new AltosFlightStatusUpdate(flightStatus);
+
+ new javax.swing.Timer(100, status_update).start();
+
thread.start();
}