From c8078d352a7f54a4a97d25af080155d3f875536a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 16 Jun 2014 22:49:34 -0700 Subject: java: Bump java library versions for next release Prepare for future release by bumping java versions now Signed-off-by: Keith Packard --- altosui/AltosConfigTD.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'altosui/AltosConfigTD.java') diff --git a/altosui/AltosConfigTD.java b/altosui/AltosConfigTD.java index bfbd2c77..2976657c 100644 --- a/altosui/AltosConfigTD.java +++ b/altosui/AltosConfigTD.java @@ -21,8 +21,8 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_4.*; -import org.altusmetrum.altosuilib_2.*; +import org.altusmetrum.altoslib_5.*; +import org.altusmetrum.altosuilib_3.*; public class AltosConfigTD implements ActionListener { -- cgit v1.2.3 From efb86669b5a74f244e2218f3385db633c36208af Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 4 Jul 2014 23:41:16 -0700 Subject: altosui: Support telemetry data rates Add combo box to flight UI and flight hardware configuration UIs Add telemetry rate to the TD/TBT config dialog Signed-off-by: Keith Packard --- altosui/AltosConfigTD.java | 25 +++++++++++++++- altosui/AltosConfigTDUI.java | 32 ++++++++++++++++++++ altosui/AltosConfigUI.java | 42 ++++++++++++++++++++++++++ altosui/AltosFlightUI.java | 46 ++++++++++++++++++----------- altosuilib/AltosUIRateList.java | 65 +++++++++++++++++++++++++++++++++++++++++ altosuilib/Makefile.am | 1 + 6 files changed, 193 insertions(+), 18 deletions(-) create mode 100644 altosuilib/AltosUIRateList.java (limited to 'altosui/AltosConfigTD.java') diff --git a/altosui/AltosConfigTD.java b/altosui/AltosConfigTD.java index 2976657c..397ed3db 100644 --- a/altosui/AltosConfigTD.java +++ b/altosui/AltosConfigTD.java @@ -62,6 +62,7 @@ public class AltosConfigTD implements ActionListener { int_ref radio_calibration; int_ref radio_setting; int_ref radio_frequency; + int_ref telemetry_rate; string_ref config_version; string_ref version; string_ref product; @@ -105,6 +106,7 @@ public class AltosConfigTD implements ActionListener { config_ui.set_version(version.get()); config_ui.set_radio_frequency(frequency()); config_ui.set_radio_calibration(radio_calibration.get()); + config_ui.set_telemetry_rate(telemetry_rate.get()); config_ui.set_clean(); if (!made_visible) { made_visible = true; @@ -140,6 +142,7 @@ public class AltosConfigTD implements ActionListener { get_int(line, "Radio cal:", radio_calibration); get_int(line, "Frequency:", radio_frequency); get_int(line, "Radio setting:", radio_setting); + get_int(line, "Telemetry rate:", telemetry_rate); get_string(line,"software-version", version); get_string(line,"product", product); } @@ -151,6 +154,7 @@ public class AltosConfigTD implements ActionListener { radio_setting.set(0); radio_frequency.set(0); radio_calibration.set(1186611); + telemetry_rate.set(Altos.ao_telemetry_rate_38400); config_version.set("0.0"); version.set("unknown"); product.set("unknown"); @@ -178,6 +182,19 @@ public class AltosConfigTD implements ActionListener { } } + synchronized int telemetry_rate() { + System.out.printf("telemetry_rate: %d\n", telemetry_rate.get()); + return telemetry_rate.get(); + } + + synchronized void set_telemetry_rate(int new_telemetry_rate){ + int rate = telemetry_rate.get(); + + System.out.printf("set_telemetry_rate %d\n", new_telemetry_rate); + if (rate >= 0) + telemetry_rate.set(new_telemetry_rate); + } + final static int serial_mode_read = 0; final static int serial_mode_save = 1; final static int serial_mode_reboot = 2; @@ -218,6 +235,7 @@ public class AltosConfigTD implements ActionListener { * available firmware version might place on the actual frequency */ config.set_frequency(AltosPreferences.frequency(serial.get())); + config.set_telemetry_rate(AltosPreferences.telemetry_rate(serial.get())); config.process_line("all finished"); } @@ -226,6 +244,8 @@ public class AltosConfigTD implements ActionListener { if (frequency != 0) AltosPreferences.set_frequency(serial.get(), frequency); + AltosPreferences.set_telemetry_rate(serial.get(), + telemetry_rate()); } public void run () { @@ -279,6 +299,8 @@ public class AltosConfigTD implements ActionListener { void save_data() { double freq = config_ui.radio_frequency(); set_frequency(freq); + int telemetry_rate = config_ui.telemetry_rate(); + set_telemetry_rate(telemetry_rate); run_serial_thread(serial_mode_save); } @@ -311,6 +333,7 @@ public class AltosConfigTD implements ActionListener { radio_setting = new int_ref(0); radio_frequency = new int_ref(0); radio_calibration = new int_ref(1186611); + telemetry_rate = new int_ref(AltosLib.ao_telemetry_rate_38400); config_version = new string_ref("0.0"); version = new string_ref("unknown"); product = new string_ref("unknown"); @@ -340,4 +363,4 @@ public class AltosConfigTD implements ActionListener { } } } -} \ No newline at end of file +} diff --git a/altosui/AltosConfigTDUI.java b/altosui/AltosConfigTDUI.java index 947d78ee..b677ad23 100644 --- a/altosui/AltosConfigTDUI.java +++ b/altosui/AltosConfigTDUI.java @@ -37,6 +37,7 @@ public class AltosConfigTDUI JLabel frequency_label; JLabel radio_calibration_label; JLabel radio_frequency_label; + JLabel rate_label; public boolean dirty; @@ -46,6 +47,7 @@ public class AltosConfigTDUI JLabel serial_value; AltosUIFreqList radio_frequency_value; JLabel radio_calibration_value; + AltosUIRateList rate_value; JButton save; JButton reset; @@ -192,6 +194,28 @@ public class AltosConfigTDUI radio_calibration_value = new JLabel(String.format("%d", 1186611)); pane.add(radio_calibration_value, c); + /* Telemetry Rate */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = 7; + c.gridwidth = 4; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + rate_label = new JLabel("Telemetry Rate:"); + pane.add(rate_label, c); + + c = new GridBagConstraints(); + c.gridx = 4; c.gridy = 7; + c.gridwidth = 4; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + rate_value = new AltosUIRateList(); + pane.add(rate_value, c); + /* Buttons */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 12; @@ -339,6 +363,14 @@ public class AltosConfigTDUI radio_calibration_value.setText(String.format("%d", calibration)); } + public int telemetry_rate() { + return rate_value.getSelectedIndex(); + } + + public void set_telemetry_rate(int rate) { + rate_value.setSelectedIndex(rate); + } + public void set_clean() { dirty = false; } diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 91c37fd5..e3a1a24f 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -40,6 +40,7 @@ public class AltosConfigUI JLabel radio_calibration_label; JLabel radio_frequency_label; JLabel radio_enable_label; + JLabel rate_label; JLabel aprs_interval_label; JLabel aprs_ssid_label; JLabel flight_log_max_label; @@ -62,6 +63,7 @@ public class AltosConfigUI AltosUIFreqList radio_frequency_value; JTextField radio_calibration_value; JRadioButton radio_enable_value; + AltosUIRateList rate_value; JComboBox aprs_interval_value; JComboBox aprs_ssid_value; JComboBox flight_log_max_value; @@ -200,6 +202,13 @@ public class AltosConfigUI radio_enable_value.setToolTipText("Firmware version does not support disabling radio"); } + void set_rate_tool_tip() { + if (rate_value.isEnabled()) + rate_value.setToolTipText("Select telemetry baud rate"); + else + rate_value.setToolTipText("Firmware version does not support variable telemetry rates"); + } + void set_aprs_interval_tool_tip() { if (aprs_interval_value.isEnabled()) aprs_interval_value.setToolTipText("Enable APRS and set the interval between APRS reports"); @@ -490,6 +499,31 @@ public class AltosConfigUI set_radio_enable_tool_tip(); row++; + /* Telemetry Rate */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + rate_label = new JLabel("Telemetry baud rate:"); + pane.add(radio_enable_label, c); + + c = new GridBagConstraints(); + c.gridx = 4; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + rate_value = new AltosUIRateList(); + rate_value.addItemListener(this); + pane.add(rate_value, c); + set_rate_tool_tip(); + row++; + /* APRS interval */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = row; @@ -1009,6 +1043,14 @@ public class AltosConfigUI return -1; } + public void set_telemetry_rate(int new_rate) { + rate_value.set_rate(new_rate); + } + + public int telemetry_rate() { + return rate_value.rate(); + } + public void set_callsign(String new_callsign) { callsign_value.setVisible(new_callsign != null); callsign_value.setText(new_callsign); diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index 5db0ee92..6af345ea 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -171,6 +171,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { Container bag; AltosUIFreqList frequencies; + AltosUIRateList rates; AltosUITelemetryList telemetries; JLabel telemetry; @@ -217,27 +218,40 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { c.anchor = GridBagConstraints.WEST; bag.add (frequencies, c); + // Telemetry rate list + rates = new AltosUIRateList(AltosUIPreferences.telemetry_rate(serial)); + rates.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + int rate = rates.rate(); + try { + reader.set_telemetry_rate(rate); + } catch (TimeoutException te) { + } catch (InterruptedException ie) { + } + reader.save_telemetry_rate(); + } + }); + rates.setEnabled(reader.supports_telemetry_rate(AltosLib.ao_telemetry_rate_2400)); + c.gridx = 1; + 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 (rates, c); + // Telemetry format list if (reader.supports_telemetry(Altos.ao_telemetry_standard)) { - telemetries = new JComboBox(); - 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 = new AltosUITelemetryList(serial); telemetries.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - int telemetry = telemetries.getSelectedIndex() + 1; + int telemetry = telemetries.get_selected(); reader.set_telemetry(telemetry); reader.save_telemetry(); } }); - c.gridx = 1; + c.gridx = 2; c.gridy = 0; c.weightx = 0; c.weighty = 0; @@ -256,7 +270,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { version = "Telemetry: None"; telemetry = new JLabel(version); - c.gridx = 1; + c.gridx = 2; c.gridy = 0; c.weightx = 0; c.weighty = 0; @@ -274,9 +288,8 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { c.gridy = 1; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; - c.gridwidth = 2; + c.gridwidth = 3; bag.add(flightStatus, c); - c.gridwidth = 1; /* The rest of the window uses a tabbed pane to * show one of the alternate data views @@ -315,7 +328,6 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; - c.gridwidth = 2; bag.add(pane, c); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); diff --git a/altosuilib/AltosUIRateList.java b/altosuilib/AltosUIRateList.java new file mode 100644 index 00000000..2e0c65a2 --- /dev/null +++ b/altosuilib/AltosUIRateList.java @@ -0,0 +1,65 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_3; + +import javax.swing.*; +import org.altusmetrum.altoslib_5.*; + +public class AltosUIRateList extends JComboBox { + + String product; + int serial; + + public void set_rate(int new_rate) { + int i; + + if (new_rate < 0) { + setVisible(false); + return; + } + + setSelectedIndex(new_rate); + } + + public void set_product(String new_product) { + product = new_product; + } + + public void set_serial(int new_serial) { + serial = new_serial; + } + + public int rate() { + return getSelectedIndex(); + } + + public AltosUIRateList () { + super(); + for (int i = 0; i < AltosLib.ao_telemetry_rate_values.length; i++) + addItem(String.format("%d baud", AltosLib.ao_telemetry_rate_values[i])); + setMaximumRowCount(getItemCount()); + setEditable(false); + product = "Unknown"; + serial = 0; + } + + public AltosUIRateList(int in_rate) { + this(); + set_rate(in_rate); + } +} diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index 40e6dda5..21ccd131 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -83,6 +83,7 @@ altosuilib_JAVA = \ AltosUIVoltageIndicator.java \ AltosUIFreqList.java \ AltosUITelemetryList.java \ + AltosUIRateList.java \ OSXAdapter.java JAR=altosuilib_$(ALTOSUILIB_VERSION).jar -- cgit v1.2.3 From 95f3a2825377bdb6737446df051c069d58f42d08 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 8 Jul 2014 23:43:31 -0700 Subject: altosui: Hide inactive altimeter configuration entries Instead of disabling them, just hide them so that entries that do not apply to a particular device won't get shown at all. Signed-off-by: Keith Packard --- altosui/AltosConfigTD.java | 2 -- altosui/AltosConfigUI.java | 63 ++++++++++++++++++++++++++++++----------- altosuilib/AltosUIFreqList.java | 1 + altosuilib/AltosUIRateList.java | 6 +--- 4 files changed, 48 insertions(+), 24 deletions(-) (limited to 'altosui/AltosConfigTD.java') diff --git a/altosui/AltosConfigTD.java b/altosui/AltosConfigTD.java index 397ed3db..4389e49b 100644 --- a/altosui/AltosConfigTD.java +++ b/altosui/AltosConfigTD.java @@ -183,14 +183,12 @@ public class AltosConfigTD implements ActionListener { } synchronized int telemetry_rate() { - System.out.printf("telemetry_rate: %d\n", telemetry_rate.get()); return telemetry_rate.get(); } synchronized void set_telemetry_rate(int new_telemetry_rate){ int rate = telemetry_rate.get(); - System.out.printf("set_telemetry_rate %d\n", new_telemetry_rate); if (rate >= 0) telemetry_rate.set(new_telemetry_rate); } diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index e3a1a24f..043cb876 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -508,7 +508,7 @@ public class AltosConfigUI c.insets = il; c.ipady = 5; rate_label = new JLabel("Telemetry baud rate:"); - pane.add(radio_enable_label, c); + pane.add(rate_label, c); c = new GridBagConstraints(); c.gridx = 4; c.gridy = row; @@ -929,6 +929,10 @@ public class AltosConfigUI public void set_main_deploy(int new_main_deploy) { main_deploy_value.setSelectedItem(AltosConvert.height.say(new_main_deploy)); main_deploy_value.setEnabled(new_main_deploy >= 0); + + main_deploy_value.setVisible(new_main_deploy >= 0); + main_deploy_label.setVisible(new_main_deploy >= 0); + } public int main_deploy() { @@ -976,6 +980,9 @@ public class AltosConfigUI } public void set_apogee_delay(int new_apogee_delay) { + apogee_delay_value.setVisible(new_apogee_delay >= 0); + apogee_delay_label.setVisible(new_apogee_delay >= 0); + apogee_delay_value.setSelectedItem(Integer.toString(new_apogee_delay)); apogee_delay_value.setEnabled(new_apogee_delay >= 0); } @@ -998,6 +1005,9 @@ public class AltosConfigUI public void set_apogee_lockout(int new_apogee_lockout) { apogee_lockout_value.setSelectedItem(Integer.toString(new_apogee_lockout)); apogee_lockout_value.setEnabled(new_apogee_lockout >= 0); + + apogee_lockout_value.setVisible(new_apogee_lockout >= 0); + apogee_lockout_label.setVisible(new_apogee_lockout >= 0); } public int apogee_lockout() throws AltosConfigDataException { @@ -1005,6 +1015,7 @@ public class AltosConfigUI } public void set_radio_frequency(double new_radio_frequency) { + radio_frequency_label.setVisible(new_radio_frequency >= 0); radio_frequency_value.set_frequency(new_radio_frequency); } @@ -1014,6 +1025,8 @@ public class AltosConfigUI public void set_radio_calibration(int new_radio_calibration) { radio_calibration_value.setVisible(new_radio_calibration >= 0); + radio_calibration_label.setVisible(new_radio_calibration >= 0); + if (new_radio_calibration < 0) radio_calibration_value.setText("Disabled"); else @@ -1025,12 +1038,14 @@ public class AltosConfigUI } public void set_radio_enable(int new_radio_enable) { + radio_enable_label.setVisible(new_radio_enable >= 0); + radio_enable_value.setVisible(new_radio_enable >= 0); + if (new_radio_enable >= 0) { radio_enable_value.setSelected(new_radio_enable > 0); radio_enable_value.setEnabled(true); } else { radio_enable_value.setSelected(true); - radio_enable_value.setVisible(radio_frequency() > 0); radio_enable_value.setEnabled(false); } set_radio_enable_tool_tip(); @@ -1044,6 +1059,8 @@ public class AltosConfigUI } public void set_telemetry_rate(int new_rate) { + rate_label.setVisible(new_rate >= 0); + rate_value.set_rate(new_rate); } @@ -1053,6 +1070,8 @@ public class AltosConfigUI public void set_callsign(String new_callsign) { callsign_value.setVisible(new_callsign != null); + callsign_label.setVisible(new_callsign != null); + callsign_value.setText(new_callsign); } @@ -1074,6 +1093,9 @@ public class AltosConfigUI } public void set_flight_log_max(int new_flight_log_max) { + flight_log_max_value.setVisible(new_flight_log_max >= 0); + flight_log_max_label.setVisible(new_flight_log_max >= 0); + flight_log_max_value.setSelectedItem(flight_log_max_label(new_flight_log_max)); flight_log_max = new_flight_log_max; set_flight_log_max_tool_tip(); @@ -1100,6 +1122,9 @@ public class AltosConfigUI } public void set_ignite_mode(int new_ignite_mode) { + ignite_mode_value.setVisible(new_ignite_mode >= 0); + ignite_mode_label.setVisible(new_ignite_mode >= 0); + if (new_ignite_mode >= ignite_mode_values.length) new_ignite_mode = 0; if (new_ignite_mode < 0) { @@ -1121,14 +1146,13 @@ public class AltosConfigUI public void set_pad_orientation(int new_pad_orientation) { + pad_orientation_value.setVisible(new_pad_orientation >= 0); + pad_orientation_label.setVisible(new_pad_orientation >= 0); + if (new_pad_orientation >= pad_orientation_values.length) new_pad_orientation = 0; - if (new_pad_orientation < 0) { - pad_orientation_value.setVisible(false); + if (new_pad_orientation < 0) new_pad_orientation = 0; - } else { - pad_orientation_value.setVisible(true); - } pad_orientation_value.setSelectedIndex(new_pad_orientation); set_pad_orientation_tool_tip(); } @@ -1141,6 +1165,9 @@ public class AltosConfigUI } public void set_beep(int new_beep) { + beep_value.setVisible(new_beep >= 0); + beep_label.setVisible(new_beep >= 0); + int new_freq = (int) Math.floor (AltosConvert.beep_value_to_freq(new_beep) + 0.5); for (int i = 0; i < beep_values.length; i++) if (new_beep == AltosConvert.beep_freq_to_value(Integer.parseInt(beep_values[i]))) { @@ -1192,13 +1219,12 @@ public class AltosConfigUI } public void set_tracker_motion(int tracker_motion) { + tracker_motion_label.setVisible(tracker_motion >= 0); + tracker_motion_value.setVisible(tracker_motion >= 0); + if (tracker_motion < 0) { - tracker_motion_label.setVisible(false); - tracker_motion_value.setVisible(false); tracker_motion_value.setEnabled(false); } else { - tracker_motion_label.setVisible(true); - tracker_motion_value.setVisible(true); tracker_motion_value.setEnabled(true); tracker_motion_value.setSelectedItem(AltosConvert.height.say(tracker_motion)); } @@ -1209,13 +1235,12 @@ public class AltosConfigUI } public void set_tracker_interval(int tracker_interval) { + tracker_interval_label.setVisible(tracker_interval >= 0); + tracker_interval_value.setVisible(tracker_interval >= 0); + if (tracker_interval< 0) { - tracker_interval_label.setVisible(false); - tracker_interval_value.setVisible(false); tracker_interval_value.setEnabled(false); } else { - tracker_interval_label.setVisible(true); - tracker_interval_value.setVisible(true); tracker_interval_value.setEnabled(true); tracker_interval_value.setSelectedItem(String.format("%d", tracker_interval)); } @@ -1252,6 +1277,9 @@ public class AltosConfigUI } public void set_aprs_interval(int new_aprs_interval) { + aprs_interval_value.setVisible(new_aprs_interval >= 0); + aprs_interval_label.setVisible(new_aprs_interval >= 0); + String s; if (new_aprs_interval <= 0) @@ -1259,7 +1287,6 @@ public class AltosConfigUI else s = Integer.toString(new_aprs_interval); aprs_interval_value.setSelectedItem(s); - aprs_interval_value.setVisible(new_aprs_interval >= 0); set_aprs_interval_tool_tip(); } @@ -1272,8 +1299,10 @@ public class AltosConfigUI } public void set_aprs_ssid(int new_aprs_ssid) { - aprs_ssid_value.setSelectedItem(Math.max(0,new_aprs_ssid)); aprs_ssid_value.setVisible(new_aprs_ssid >= 0); + aprs_ssid_label.setVisible(new_aprs_ssid >= 0); + + aprs_ssid_value.setSelectedItem(Math.max(0,new_aprs_ssid)); set_aprs_ssid_tool_tip(); } diff --git a/altosuilib/AltosUIFreqList.java b/altosuilib/AltosUIFreqList.java index f1f83dd5..84e6dce4 100644 --- a/altosuilib/AltosUIFreqList.java +++ b/altosuilib/AltosUIFreqList.java @@ -53,6 +53,7 @@ public class AltosUIFreqList extends JComboBox { AltosUIPreferences.add_common_frequency(frequency); insertItemAt(frequency, i); setMaximumRowCount(getItemCount()); + setVisible(true); } public void set_product(String new_product) { diff --git a/altosuilib/AltosUIRateList.java b/altosuilib/AltosUIRateList.java index 2e0c65a2..ee35ce6d 100644 --- a/altosuilib/AltosUIRateList.java +++ b/altosuilib/AltosUIRateList.java @@ -28,11 +28,7 @@ public class AltosUIRateList extends JComboBox { public void set_rate(int new_rate) { int i; - if (new_rate < 0) { - setVisible(false); - return; - } - + setVisible(new_rate >= 0); setSelectedIndex(new_rate); } -- cgit v1.2.3 From 7735cee871d02215517cb9d91cd552f003ca6a50 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 1 Sep 2014 18:23:42 -0500 Subject: altoslib: Catch a couple null pointers in AltosConfigTD When messing with TD, I hit a couple of paths that could try to dereference null pointers. Check for those. Signed-off-by: Keith Packard --- altosui/AltosConfigTD.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'altosui/AltosConfigTD.java') diff --git a/altosui/AltosConfigTD.java b/altosui/AltosConfigTD.java index 4389e49b..9020ed9d 100644 --- a/altosui/AltosConfigTD.java +++ b/altosui/AltosConfigTD.java @@ -223,8 +223,10 @@ public class AltosConfigTD implements ActionListener { if (!config_version.get().equals("0.0")) break; been_there = true; - config.serial_line.printf("C\n "); - config.serial_line.flush_input(); + if (config != null && config.serial_line != null) { + config.serial_line.printf("C\n "); + config.serial_line.flush_input(); + } } } catch (InterruptedException ie) { } @@ -277,8 +279,10 @@ public class AltosConfigTD implements ActionListener { } void abort() { - serial_line.close(); - serial_line = null; + if (serial_line != null) { + serial_line.close(); + serial_line = null; + } JOptionPane.showMessageDialog(owner, String.format("Connection to \"%s\" failed", device.toShortString()), -- cgit v1.2.3