update ChangeLog for 1.9.18 release
[fw/altos] / telegps / TeleGPSConfigUI.java
index 1a951309e331cec9644e7cbafd4f9705ead52558..a4a60b6f267670f07591d1d5f41d5ed56d748d77 100644 (file)
@@ -39,6 +39,9 @@ public class TeleGPSConfigUI
        JLabel                  radio_calibration_label;
        JLabel                  radio_frequency_label;
        JLabel                  radio_enable_label;
+       JLabel                  radio_10mw_label;
+       JLabel                  report_feet_label;
+       JLabel                  gps_receiver_label;
        JLabel                  rate_label;
        JLabel                  aprs_interval_label;
        JLabel                  aprs_ssid_label;
@@ -58,6 +61,9 @@ public class TeleGPSConfigUI
        AltosUIFreqList         radio_frequency_value;
        JLabel                  radio_calibration_value;
        JRadioButton            radio_enable_value;
+       JRadioButton            radio_10mw_value;
+       JComboBox<String>       report_feet_value;
+       JComboBox<String>       gps_receiver_value;
        AltosUIRateList         rate_value;
        JComboBox<String>       aprs_interval_value;
        JComboBox<Integer>      aprs_ssid_value;
@@ -111,6 +117,11 @@ public class TeleGPSConfigUI
                "10"
        };
 
+       static String[]         report_feet_values = {
+               "Meters",
+               "Feet",
+       };
+
        /* A window listener to catch closing events and tell the config code */
        class ConfigListener extends WindowAdapter {
                TeleGPSConfigUI ui;
@@ -152,6 +163,78 @@ public class TeleGPSConfigUI
                        radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
        }
 
+       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");
+       }
+
+       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;
+       }
+
+       void set_gps_receiver_tool_tip() {
+               if (gps_receiver_value.isVisible())
+                       gps_receiver_value.setToolTipText("GPS receiver selection");
+               else
+                       gps_receiver_value.setToolTipText("Only TeleMega with new firmware supports alternate GPS receivers");
+       }
+
+       public void set_gps_receiver(int new_gps_receiver) {
+               System.out.printf("set_gps_receiver %d\n", new_gps_receiver);
+               if (new_gps_receiver != AltosLib.MISSING) {
+                       if (new_gps_receiver >= AltosLib.gps_receiver_names.length)
+                               new_gps_receiver = 0;
+                       if (new_gps_receiver < 0) {
+                               gps_receiver_value.setEnabled(false);
+                               new_gps_receiver = 0;
+                       } else {
+                               gps_receiver_value.setEnabled(true);
+                       }
+                       gps_receiver_value.setSelectedIndex(new_gps_receiver);
+               }
+               gps_receiver_value.setVisible(new_gps_receiver != AltosLib.MISSING);
+               gps_receiver_label.setVisible(new_gps_receiver != AltosLib.MISSING);
+
+               set_gps_receiver_tool_tip();
+       }
+
+       public int gps_receiver() {
+               if (gps_receiver_value.isVisible())
+                       return gps_receiver_value.getSelectedIndex();
+               else
+                       return AltosLib.MISSING;
+       }
+
        void set_rate_tool_tip() {
                if (rate_value.isVisible())
                        rate_value.setToolTipText("Select telemetry baud rate");
@@ -200,6 +283,8 @@ public class TeleGPSConfigUI
                        flight_log_max_value.setToolTipText("Cannot set max value with flight logs in memory");
        }
 
+       public boolean has_radio() { return true; }
+
        /* Build the UI using a grid bag */
        public TeleGPSConfigUI(JFrame in_owner) {
                super (in_owner, "Configure Device", false);
@@ -211,7 +296,7 @@ public class TeleGPSConfigUI
                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 */
@@ -354,6 +439,83 @@ public class TeleGPSConfigUI
                set_radio_enable_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<String>(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++;
+
+               /* GPS Receiver */
+               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;
+               gps_receiver_label = new JLabel("GPS Receiver:");
+               pane.add(gps_receiver_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;
+               gps_receiver_value = new JComboBox<String>(AltosLib.gps_receiver_names);
+               gps_receiver_value.setEditable(false);
+               gps_receiver_value.addItemListener(this);
+               pane.add(gps_receiver_value, c);
+               set_gps_receiver_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++;
+
                /* Telemetry Rate */
                c = new GridBagConstraints();
                c.gridx = 0; c.gridy = row;
@@ -811,6 +973,22 @@ public class TeleGPSConfigUI
                        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_telemetry_rate(int new_rate) {
                if (new_rate != AltosLib.MISSING)
                        rate_value.set_rate(new_rate);
@@ -874,14 +1052,18 @@ public class TeleGPSConfigUI
                return parse_int("flight log max", flight_log_max_value.getSelectedItem().toString(), true);
        }
 
-       public void set_flight_log_max_limit(int new_flight_log_max_limit) {
+       public void set_flight_log_max_limit(int new_flight_log_max_limit, int new_storage_erase_unit) {
                flight_log_max_limit = new_flight_log_max_limit;
-               flight_log_max_value.removeAllItems();
-               for (int i = 8; i >= 1; i--) {
-                       int     size = flight_log_max_limit / i;
-                       flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
+               if (new_flight_log_max_limit != AltosLib.MISSING) {
+                       flight_log_max_value.removeAllItems();
+                       for (int i = 8; i >= 1; i--) {
+                               int     size = flight_log_max_limit / i;
+                               if (new_storage_erase_unit != 0)
+                                       size &= ~(new_storage_erase_unit - 1);
+                               flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
+                       }
                }
-               if (flight_log_max != 0)
+               if (flight_log_max != 0 && flight_log_max != AltosLib.MISSING)
                        set_flight_log_max(flight_log_max);
        }