diff options
Diffstat (limited to 'altosui')
| -rw-r--r-- | altosui/AltosConfigTDUI.java | 33 | ||||
| -rw-r--r-- | altosui/AltosConfigUI.java | 9 | ||||
| -rw-r--r-- | altosui/AltosFlightUI.java | 65 | ||||
| -rw-r--r-- | altosui/AltosIdleMonitorUI.java | 4 |
4 files changed, 74 insertions, 37 deletions
diff --git a/altosui/AltosConfigTDUI.java b/altosui/AltosConfigTDUI.java index ca365718..947d78ee 100644 --- a/altosui/AltosConfigTDUI.java +++ b/altosui/AltosConfigTDUI.java @@ -44,8 +44,7 @@ public class AltosConfigTDUI JLabel product_value; JLabel version_value; JLabel serial_value; - JMenuBar radio_frequency_menu_bar; - AltosFreqList radio_frequency_value; + AltosUIFreqList radio_frequency_value; JLabel radio_calibration_value; JButton save; @@ -55,7 +54,6 @@ public class AltosConfigTDUI ActionListener listener; - /* A window listener to catch closing events and tell the config code */ class ConfigListener extends WindowAdapter { AltosConfigTDUI ui; @@ -167,11 +165,9 @@ public class AltosConfigTDUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - radio_frequency_value = new AltosFreqList(false); + radio_frequency_value = new AltosUIFreqList(); radio_frequency_value.addItemListener(this); - radio_frequency_menu_bar = new JMenuBar(); - radio_frequency_menu_bar.add(radio_frequency_value); - pane.add(radio_frequency_menu_bar, c); + pane.add(radio_frequency_value, c); radio_frequency_value.setToolTipText("Telemetry, RDF and packet frequency"); /* Radio Calibration */ @@ -311,7 +307,28 @@ public class AltosConfigTDUI } public void set_radio_frequency(double new_radio_frequency) { - radio_frequency_value.set_frequency(new_radio_frequency); + int i; + for (i = 0; i < radio_frequency_value.getItemCount(); i++) { + AltosFrequency f = (AltosFrequency) radio_frequency_value.getItemAt(i); + + if (f.close(new_radio_frequency)) { + radio_frequency_value.setSelectedIndex(i); + return; + } + } + for (i = 0; i < radio_frequency_value.getItemCount(); i++) { + AltosFrequency f = (AltosFrequency) radio_frequency_value.getItemAt(i); + + if (new_radio_frequency < f.frequency) + break; + } + String description = String.format("%s serial %s", + product_value.getText(), + serial_value.getText()); + AltosFrequency new_frequency = new AltosFrequency(new_radio_frequency, description); + AltosPreferences.add_common_frequency(new_frequency); + radio_frequency_value.insertItemAt(new_frequency, i); + radio_frequency_value.setSelectedIndex(i); } public double radio_frequency() { diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index de1b582e..91c37fd5 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -59,7 +59,7 @@ public class AltosConfigUI JComboBox<String> main_deploy_value; JComboBox<String> apogee_delay_value; JComboBox<String> apogee_lockout_value; - AltosFreqList radio_frequency_value; + AltosUIFreqList radio_frequency_value; JTextField radio_calibration_value; JRadioButton radio_enable_value; JComboBox<String> aprs_interval_value; @@ -432,12 +432,9 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - radio_frequency_value = new AltosFreqList(); + radio_frequency_value = new AltosUIFreqList(); radio_frequency_value.addItemListener(this); - - JMenuBar menu_bar = new JMenuBar(); - menu_bar.add(radio_frequency_value); - pane.add(menu_bar, c); + pane.add(radio_frequency_value, c); radio_frequency_value.setToolTipText("Telemetry, RDF and packet frequency"); row++; diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index 5aff1817..5db0ee92 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -169,18 +169,14 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { exit_on_close = true; } - Container bag; - - JMenuBar menu_bar; - AltosFreqList frequencies; - AltosUITelemetryMenu telemetries; + Container bag; + AltosUIFreqList frequencies; + AltosUITelemetryList telemetries; JLabel telemetry; ActionListener show_timer; public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) { - super(); - AltosUIPreferences.set_component(this); displays = new LinkedList<AltosFlightDisplay>(); @@ -197,12 +193,8 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { /* Stick channel selector at top of table for telemetry monitoring */ if (serial >= 0) { - - menu_bar = new JMenuBar(); - setJMenuBar(menu_bar); - - // Channel menu - frequencies = new AltosFreqList(AltosUIPreferences.frequency(serial)); + // Frequency menu + frequencies = new AltosUIFreqList(AltosUIPreferences.frequency(serial)); frequencies.set_product("Monitor"); frequencies.set_serial(serial); frequencies.addActionListener(new ActionListener() { @@ -216,19 +208,43 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { reader.save_frequency(); } }); - menu_bar.add (frequencies); - - // Telemetry format menu - if (reader.supports_telemetry(AltosLib.ao_telemetry_standard)) { - telemetries = new AltosUITelemetryMenu(serial); + c.gridx = 0; + c.gridy = 0; + c.weightx = 0; + c.weighty = 0; + c.insets = new Insets(3, 3, 3, 3); + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.WEST; + bag.add (frequencies, c); + + // Telemetry format list + if (reader.supports_telemetry(Altos.ao_telemetry_standard)) { + telemetries = new JComboBox<String>(); + for (int i = 1; i <= Altos.ao_telemetry_max; i++) + telemetries.addItem(Altos.telemetry_name(i)); + int telemetry = AltosPreferences.telemetry(serial); + if (telemetry <= Altos.ao_telemetry_off || + telemetry > Altos.ao_telemetry_max) + telemetry = Altos.ao_telemetry_standard; + telemetries.setSelectedIndex(telemetry - 1); + telemetries.setMaximumRowCount(Altos.ao_telemetry_max); + telemetries.setPreferredSize(null); + telemetries.revalidate(); telemetries.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - int telemetry = telemetries.get_selected(); + int telemetry = telemetries.getSelectedIndex() + 1; reader.set_telemetry(telemetry); reader.save_telemetry(); } }); - menu_bar.add(telemetries); + c.gridx = 1; + c.gridy = 0; + c.weightx = 0; + c.weighty = 0; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.WEST; + bag.add (telemetries, c); + c.insets = new Insets(0, 0, 0, 0); } else { String version; @@ -240,7 +256,14 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { version = "Telemetry: None"; telemetry = new JLabel(version); - menu_bar.add(telemetry); + c.gridx = 1; + c.gridy = 0; + c.weightx = 0; + c.weighty = 0; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.WEST; + bag.add (telemetry, c); + c.insets = new Insets(0, 0, 0, 0); } } diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 63d86291..67b7a989 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -103,7 +103,7 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl } Container bag; - AltosFreqList frequencies; + AltosUIFreqList frequencies; JTextField callsign_value; /* DocumentListener interface methods */ @@ -200,7 +200,7 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl /* Stick frequency selector at top of table for telemetry monitoring */ if (remote && serial >= 0) { // Frequency menu - frequencies = new AltosFreqList(AltosUIPreferences.frequency(serial)); + frequencies = new AltosUIFreqList(AltosUIPreferences.frequency(serial)); frequencies.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { double frequency = frequencies.frequency(); |
