add(label);
value = new JTextField("");
+ value.setEditable(false);
value.setFont(AltosUILib.status_font);
value.setHorizontalAlignment(SwingConstants.CENTER);
c.gridx = x; c.gridy = 1;
}
class Call extends Value {
+ String call;
+
void show(AltosState state, AltosListenerState listener_state) {
- value.setText(state.callsign);
+ if (state.callsign != call) {
+ value.setText(state.callsign);
+ call = state.callsign;
+ }
if (state.callsign == null)
setVisible(false);
else
Call call;
class Serial extends Value {
+ int serial = -1;
void show(AltosState state, AltosListenerState listener_state) {
- if (state.serial == AltosLib.MISSING)
- value.setText("none");
- else
- value.setText(String.format("%d", state.serial));
+ if (state.serial != serial) {
+ if (state.serial == AltosLib.MISSING)
+ value.setText("none");
+ else
+ value.setText(String.format("%d", state.serial));
+ serial = state.serial;
+ }
}
public Serial (GridBagLayout layout, int x) {
super (layout, x, "Serial");
Serial serial;
class RSSI extends Value {
+ int rssi = 10000;
+
void show(AltosState state, AltosListenerState listener_state) {
- value.setText(String.format("%d", state.rssi()));
- if (state.rssi == AltosLib.MISSING)
- setVisible(false);
- else
- setVisible(true);
+ int new_rssi = state.rssi();
+
+ if (new_rssi != rssi) {
+ value.setText(String.format("%d", new_rssi));
+ if (state.rssi == AltosLib.MISSING)
+ setVisible(false);
+ else
+ setVisible(true);
+ rssi = new_rssi;
+ }
}
public RSSI (GridBagLayout layout, int x) {
super (layout, x, "RSSI");
RSSI rssi;
class LastPacket extends Value {
+
+ long last_secs = -1;
+
void show(AltosState state, AltosListenerState listener_state) {
long secs = (System.currentTimeMillis() - state.received_time + 500) / 1000;
- value.setText(String.format("%d", secs));
+
+ if (secs != last_secs) {
+ value.setText(String.format("%d", secs));
+ last_secs = secs;
+ }
}
public LastPacket(GridBagLayout layout, int x) {
super (layout, x, "Age");