altosui: Add options for low frequency beeper
[fw/altos] / altosui / AltosConfigFCUI.java
index b7dc70bf4cb9d1aa6d0fbca9456b63e08e885932..562c695207613638bb3a61253d04bd3290964a1e 100644 (file)
@@ -97,6 +97,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"
@@ -119,6 +121,7 @@ public class AltosConfigFCUI
                "Dual Deploy",
                "Redundant Apogee",
                "Redundant Main",
+               "Separation & Apogee",
        };
 
        static String[]         aprs_interval_values = {
@@ -137,16 +140,26 @@ public class AltosConfigFCUI
        };
 
        static String[]         beep_values = {
+               "2000",
+               "2100",
+               "2200",
                "3750",
                "4000",
                "4250",
        };
 
-       static String[]         pad_orientation_values = {
+       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 = {
                "2",
                "5",
@@ -203,6 +216,25 @@ public class AltosConfigFCUI
                return product != null && product.startsWith("TeleMetrum");
        }
 
+       boolean is_telemega() {
+               String  product = product_value.getText();
+               return product != null && product.startsWith("TeleMega");
+       }
+
+       boolean is_easymega() {
+               String  product = product_value.getText();
+               return product != null && product.startsWith("EasyMega");
+       }
+
+       boolean is_easytimer() {
+               String  product = product_value.getText();
+               return product != null && product.startsWith("EasyTimer");
+       }
+
+       boolean has_radio() {
+               return is_telemega() || is_telemetrum() || is_telemini();
+       }
+
        void set_radio_enable_tool_tip() {
                if (radio_enable_value.isVisible())
                        radio_enable_value.setToolTipText("Enable/Disable telemetry and RDF transmissions");
@@ -277,11 +309,29 @@ public class AltosConfigFCUI
                                pad_orientation_value.setToolTipText("Older TeleMetrum firmware must fly antenna forward");
                        else if (is_telemini() || is_easymini())
                                pad_orientation_value.setToolTipText("TeleMini and EasyMini don't care how they are mounted");
+                       else if (is_easytimer())
+                               pad_orientation_value.setToolTipText("EasyTimer can be mounted in any of six orientations");
                        else
                                pad_orientation_value.setToolTipText("Can't select orientation");
                }
        }
 
+       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");
@@ -301,7 +351,7 @@ public class AltosConfigFCUI
 
        /* 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;
@@ -310,7 +360,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 */
@@ -759,6 +810,8 @@ public class AltosConfigFCUI
                c.anchor = GridBagConstraints.LINE_START;
                c.insets = ir;
                c.ipady = 5;
+               pad_orientation_values = pad_orientation_values_no_radio;
+
                pad_orientation_value = new JComboBox<String>(pad_orientation_values);
                pad_orientation_value.setEditable(false);
                pad_orientation_value.addItemListener(this);
@@ -997,11 +1050,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);
        }
 
@@ -1029,13 +1084,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 */
@@ -1068,6 +1123,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) {