altosui: Add config and pyro tabs to graph widget
[fw/altos] / altosui / AltosConfigFCUI.java
index 88f8b0808a92a59c68aab2cf982d43bac124949d..9d39cda1bf820e0c898b8a3b1d5633881c57b5f2 100644 (file)
@@ -44,6 +44,7 @@ public class AltosConfigFCUI
        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;
@@ -73,6 +74,7 @@ public class AltosConfigFCUI
        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;
@@ -121,13 +123,6 @@ public class AltosConfigFCUI
                "0", "5", "10", "15", "20"
        };
 
-       static String[]         ignite_mode_values = {
-               "Dual Deploy",
-               "Redundant Apogee",
-               "Redundant Main",
-               "Separation & Apogee",
-       };
-
        static String[]         aprs_interval_values = {
                "Disabled",
                "2",
@@ -152,16 +147,6 @@ public class AltosConfigFCUI
                "4250",
        };
 
-       static String[]         pad_orientation_values_radio = {
-               "Antenna Up",
-               "Antenna Down",
-       };
-
-       static String[]         pad_orientation_values_no_radio = {
-               "Beeper Up",
-               "Beeper Down",
-       };
-
        String[] pad_orientation_values;
 
        static String[]         tracker_motion_values_m = {
@@ -240,7 +225,7 @@ public class AltosConfigFCUI
                return product != null && product.startsWith("EasyTimer");
        }
 
-       boolean has_radio() {
+       public boolean has_radio() {
                return is_telemega() || is_telemetrum() || is_telemini();
        }
 
@@ -326,11 +311,7 @@ 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;
+               String [] new_values = AltosLib.pad_orientation_values(has_radio());
                if (new_values != pad_orientation_values) {
                        int id = pad_orientation_value.getSelectedIndex();
                        pad_orientation_value.removeAllItems();
@@ -353,7 +334,7 @@ public class AltosConfigFCUI
 
        void set_beep_tool_tip() {
                if (beep_value.isVisible())
-                       beep_value.setToolTipText("What frequency the beeper will sound at");
+                       beep_value.setToolTipText("What frequency the beeper will sound at (0 for off)");
                else
                        beep_value.setToolTipText("Older firmware could not select beeper frequency");
        }
@@ -372,6 +353,13 @@ public class AltosConfigFCUI
                        report_feet_value.setToolTipText("Older firmware always beeps max height in meters");
        }
 
+       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");
+       }
+
        /* Build the UI using a grid bag */
        public AltosConfigFCUI(JFrame in_owner, boolean remote) {
                super (in_owner, title, false);
@@ -656,6 +644,32 @@ public class AltosConfigFCUI
                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++;
+
                /* Telemetry Rate */
                c = new GridBagConstraints();
                c.gridx = 0; c.gridy = row;
@@ -858,7 +872,7 @@ public class AltosConfigFCUI
                c.anchor = GridBagConstraints.LINE_START;
                c.insets = ir;
                c.ipady = 5;
-               ignite_mode_value = new JComboBox<String>(ignite_mode_values);
+               ignite_mode_value = new JComboBox<String>(AltosLib.ignite_mode_values);
                ignite_mode_value.setEditable(false);
                ignite_mode_value.addItemListener(this);
                pane.add(ignite_mode_value, c);
@@ -884,7 +898,7 @@ public class AltosConfigFCUI
                c.anchor = GridBagConstraints.LINE_START;
                c.insets = ir;
                c.ipady = 5;
-               pad_orientation_values = pad_orientation_values_no_radio;
+               pad_orientation_values = AltosLib.pad_orientation_values(false);
 
                pad_orientation_value = new JComboBox<String>(pad_orientation_values);
                pad_orientation_value.setEditable(false);
@@ -1418,7 +1432,7 @@ public class AltosConfigFCUI
 
        public void set_ignite_mode(int new_ignite_mode) {
                if (new_ignite_mode != AltosLib.MISSING) {
-                       if (new_ignite_mode >= ignite_mode_values.length)
+                       if (new_ignite_mode >= AltosLib.ignite_mode_values.length)
                                new_ignite_mode = 0;
                        if (new_ignite_mode < 0) {
                                ignite_mode_value.setEnabled(false);
@@ -1553,6 +1567,32 @@ public class AltosConfigFCUI
                        return AltosLib.MISSING;
        }
 
+       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;
+       }
+
        String[] tracker_motion_values() {
                if (AltosConvert.imperial_units)
                        return tracker_motion_values_ft;