X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosui%2FAltosConfigFCUI.java;h=88f8b0808a92a59c68aab2cf982d43bac124949d;hb=d80c1317f596f73d192e6fbb33c3579d54802182;hp=3b11fb68d716a2838a8560cf510e275c41eccaf5;hpb=8ec51d698921d07c394e6e0e48ac5d587f70ece8;p=fw%2Faltos diff --git a/altosui/AltosConfigFCUI.java b/altosui/AltosConfigFCUI.java index 3b11fb68..88f8b080 100644 --- a/altosui/AltosConfigFCUI.java +++ b/altosui/AltosConfigFCUI.java @@ -42,6 +42,8 @@ public class AltosConfigFCUI JLabel radio_calibration_label; JLabel radio_frequency_label; JLabel radio_enable_label; + JLabel radio_10mw_label; + JLabel report_feet_label; JLabel rate_label; JLabel aprs_interval_label; JLabel aprs_ssid_label; @@ -69,6 +71,8 @@ public class AltosConfigFCUI AltosUIFreqList radio_frequency_value; JLabel radio_calibration_value; JRadioButton radio_enable_value; + JRadioButton radio_10mw_value; + JComboBox report_feet_value; AltosUIRateList rate_value; JComboBox aprs_interval_value; JComboBox aprs_ssid_value; @@ -97,6 +101,8 @@ public class AltosConfigFCUI ActionListener listener; + static final String title = "Configure Flight Computer"; + static String[] main_deploy_values_m = { "100", "150", "200", "250", "300", "350", "400", "450", "500" @@ -138,6 +144,9 @@ public class AltosConfigFCUI }; static String[] beep_values = { + "2000", + "2100", + "2200", "3750", "4000", "4250", @@ -176,6 +185,11 @@ public class AltosConfigFCUI "10" }; + static String[] report_feet_values = { + "Meters", + "Feet", + }; + /* A window listener to catch closing events and tell the config code */ class ConfigListener extends WindowAdapter { AltosConfigFCUI ui; @@ -311,6 +325,22 @@ public class AltosConfigFCUI } } + void set_pad_orientation_values() { + String [] new_values; + if (has_radio()) + new_values = pad_orientation_values_radio; + else + new_values = pad_orientation_values_no_radio; + if (new_values != pad_orientation_values) { + int id = pad_orientation_value.getSelectedIndex(); + pad_orientation_value.removeAllItems(); + pad_orientation_values = new_values; + for (int i = 0; i < new_values.length; i++) + pad_orientation_value.addItem(pad_orientation_values[i]); + pad_orientation_value.setSelectedIndex(id); + } + } + void set_accel_tool_tips() { if (accel_plus_value.isVisible()) { accel_plus_value.setToolTipText("Pad acceleration value in flight orientation"); @@ -328,9 +358,23 @@ public class AltosConfigFCUI beep_value.setToolTipText("Older firmware could not select beeper frequency"); } + void set_radio_10mw_tool_tip() { + if (radio_10mw_value.isVisible()) + radio_10mw_value.setToolTipText("Should transmitter power be limited to 10mW"); + else + radio_10mw_value.setToolTipText("Older firmware could not limit radio power"); + } + + void set_report_feet_tool_tip() { + if (report_feet_value.isVisible()) + report_feet_value.setToolTipText("Units used after landing to beep max height"); + else + report_feet_value.setToolTipText("Older firmware always beeps max height in meters"); + } + /* Build the UI using a grid bag */ public AltosConfigFCUI(JFrame in_owner, boolean remote) { - super (in_owner, "Configure Flight Computer", false); + super (in_owner, title, false); owner = in_owner; GridBagConstraints c; @@ -339,7 +383,8 @@ public class AltosConfigFCUI Insets il = new Insets(4,4,4,4); Insets ir = new Insets(4,4,4,4); - pane = getContentPane(); + pane = getScrollablePane(); + pane.setLayout(new GridBagLayout()); /* Product */ @@ -560,6 +605,57 @@ public class AltosConfigFCUI set_radio_enable_tool_tip(); row++; + /* Radio 10mW limit */ + 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; + radio_10mw_label = new JLabel("Limit transmit to 10mW:"); + pane.add(radio_10mw_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; + radio_10mw_value = new JRadioButton("Limited"); + radio_10mw_value.addItemListener(this); + pane.add(radio_10mw_value, c); + set_radio_10mw_tool_tip(); + row++; + + /* Report feet */ + 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; + report_feet_label = new JLabel("Beep max height in:"); + pane.add(report_feet_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; + report_feet_value = new JComboBox(report_feet_values); + report_feet_value.setEditable(false); + report_feet_value.addItemListener(this); + pane.add(report_feet_value, c); + set_report_feet_tool_tip(); + row++; + /* Telemetry Rate */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = row; @@ -788,10 +884,7 @@ public class AltosConfigFCUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - if (has_radio()) - pad_orientation_values = pad_orientation_values_radio; - else - pad_orientation_values = pad_orientation_values_no_radio; + pad_orientation_values = pad_orientation_values_no_radio; pad_orientation_value = new JComboBox(pad_orientation_values); pad_orientation_value.setEditable(false); @@ -1031,11 +1124,13 @@ public class AltosConfigFCUI public void set_dirty() { dirty = true; + setTitle(title + " (modified)"); save.setEnabled(true); } public void set_clean() { dirty = false; + setTitle(title); save.setEnabled(false); } @@ -1063,13 +1158,13 @@ public class AltosConfigFCUI if (cmd.equals("Close") || cmd.equals("Reboot")) if (!check_dirty(cmd)) return; + if (cmd.equals("Save")) + save.setEnabled(false); listener.actionPerformed(e); if (cmd.equals("Close") || cmd.equals("Reboot")) { setVisible(false); dispose(); } - if (cmd.equals("Save") || cmd.equals("Reset")) - set_clean(); } /* ItemListener interface method */ @@ -1102,6 +1197,7 @@ public class AltosConfigFCUI set_pad_orientation_tool_tip(); set_accel_tool_tips(); set_flight_log_max_tool_tip(); + set_pad_orientation_values(); } public void set_version(String version) { @@ -1416,6 +1512,47 @@ public class AltosConfigFCUI return AltosLib.MISSING; } + public void set_radio_10mw(int new_radio_10mw) { + if (new_radio_10mw != AltosLib.MISSING) { + radio_10mw_value.setSelected(new_radio_10mw != 0); + } + radio_10mw_value.setVisible(new_radio_10mw != AltosLib.MISSING); + radio_10mw_label.setVisible(new_radio_10mw != AltosLib.MISSING); + set_radio_10mw_tool_tip(); + } + + public int radio_10mw() { + if (radio_10mw_value.isVisible()) + return radio_10mw_value.isSelected() ? 1 : 0; + else + return AltosLib.MISSING; + } + + public void set_report_feet(int new_report_feet) { + if (new_report_feet != AltosLib.MISSING) { + if (new_report_feet >= report_feet_values.length) + new_report_feet = 0; + if (new_report_feet < 0) { + report_feet_value.setEnabled(false); + new_report_feet = 0; + } else { + report_feet_value.setEnabled(true); + } + report_feet_value.setSelectedIndex(new_report_feet); + } + report_feet_value.setVisible(new_report_feet != AltosLib.MISSING); + report_feet_label.setVisible(new_report_feet != AltosLib.MISSING); + + set_report_feet_tool_tip(); + } + + public int report_feet() { + if (report_feet_value.isVisible()) + return report_feet_value.getSelectedIndex(); + else + return AltosLib.MISSING; + } + String[] tracker_motion_values() { if (AltosConvert.imperial_units) return tracker_motion_values_ft;