X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosIdleMonitorUI.java;h=02295ea98c05fde6c36e5979c88793ab1ebe0414;hp=988a797c963a85cdad456e530d16286983fd7fdc;hb=3c2f601139d36761de6a8a2210545d082ef16133;hpb=cbfbaabb39f9f7709d00cf3dc63cc1bc7563062e diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 988a797c..02295ea9 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; class AltosADC { int tick; @@ -90,7 +91,9 @@ class AltosADC { } class AltosGPSQuery extends AltosGPS { - public AltosGPSQuery (AltosSerial serial) throws TimeoutException, InterruptedException { + public AltosGPSQuery (AltosSerial serial, AltosConfigData config_data) + throws TimeoutException, InterruptedException { + boolean says_done = config_data.compare_version("1.0") >= 0; serial.printf("g\n"); for (;;) { String line = serial.get_reply_no_dialog(5000); @@ -140,6 +143,8 @@ class AltosGPSQuery extends AltosGPS { int status = Integer.decode(bits[1]); connected = (status & Altos.AO_GPS_RUNNING) != 0; locked = (status & Altos.AO_GPS_VALID) != 0; + if (!says_done) + break; continue; } if (line.startsWith("Sats:")) { @@ -184,7 +189,7 @@ class AltosIdleMonitor extends Thread { serial.flush_input(); config_data = new AltosConfigData(serial); adc = new AltosADC(serial); - gps = new AltosGPSQuery(serial); + gps = new AltosGPSQuery(serial, config_data); } finally { if (remote) serial.stop_remote(); @@ -237,6 +242,8 @@ class AltosIdleMonitor extends Thread { update_state(); post_state(); } catch (TimeoutException te) { + if (AltosSerial.debug) + System.out.printf ("monitor idle data timeout\n"); } Thread.sleep(1000); } @@ -255,7 +262,7 @@ class AltosIdleMonitor extends Thread { } } -public class AltosIdleMonitorUI extends JFrame implements AltosFlightDisplay { +public class AltosIdleMonitorUI extends AltosFrame implements AltosFlightDisplay, AltosFontListener { AltosDevice device; JTabbedPane pane; AltosPad pad; @@ -289,7 +296,14 @@ public class AltosIdleMonitorUI extends JFrame implements AltosFlightDisplay { flightInfo.set_font(); } + public void font_size_changed(int font_size) { + set_font(); + } + + AltosFlightStatusUpdate status_update; + public void show(AltosState state, int crc_errors) { + status_update.saved_state = state; try { pad.show(state, crc_errors); flightStatus.show(state, crc_errors); @@ -329,12 +343,12 @@ public class AltosIdleMonitorUI extends JFrame implements AltosFlightDisplay { /* Stick frequency selector at top of table for telemetry monitoring */ if (remote && serial >= 0) { // Frequency menu - frequencies = new AltosFreqList(AltosPreferences.frequency(serial)); + frequencies = new AltosFreqList(AltosUIPreferences.frequency(serial)); frequencies.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { double frequency = frequencies.frequency(); thread.set_frequency(frequency); - AltosPreferences.set_frequency(device.getSerial(), + AltosUIPreferences.set_frequency(device.getSerial(), frequency); } }); @@ -377,12 +391,16 @@ public class AltosIdleMonitorUI extends JFrame implements AltosFlightDisplay { bag.add(pane, c); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + + AltosUIPreferences.register_font_listener(this); + addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { disconnect(); setVisible(false); dispose(); + AltosUIPreferences.unregister_font_listener(AltosIdleMonitorUI.this); } }); @@ -391,6 +409,10 @@ public class AltosIdleMonitorUI extends JFrame implements AltosFlightDisplay { thread = new AltosIdleMonitor(this, device, remote); + status_update = new AltosFlightStatusUpdate(flightStatus); + + new javax.swing.Timer(100, status_update).start(); + thread.start(); } }