altosui: Add pyro firing time configuration
authorKeith Packard <keithp@keithp.com>
Thu, 12 Jun 2014 02:51:37 +0000 (19:51 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 12 Jun 2014 02:51:37 +0000 (19:51 -0700)
Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosConfigData.java
altoslib/AltosConfigValues.java
altosui/AltosConfigPyroUI.java
altosui/AltosConfigUI.java
telegps/TeleGPSConfigUI.java

index 563bef4..e104395 100644 (file)
@@ -67,6 +67,7 @@ public class AltosConfigData implements Iterable<String> {
        public AltosPyro[]      pyros;
        public int              npyro;
        public int              pyro;
+       public double           pyro_firing_time;
 
        /* HAS_APRS */
        public int              aprs_interval;
@@ -246,6 +247,7 @@ public class AltosConfigData implements Iterable<String> {
                pyro = 0;
                npyro = 0;
                pyros = null;
+               pyro_firing_time = -1;
 
                aprs_interval = -1;
 
@@ -327,6 +329,7 @@ public class AltosConfigData implements Iterable<String> {
                                        pyros[pyro++] = p;
                        } catch (Exception e) {}
                }
+               try { pyro_firing_time = get_int(line, "Pyro time:") / 100.0; } catch (Exception e) {}
 
                /* HAS_APRS */
                try { aprs_interval = get_int(line, "APRS interval:"); } catch (Exception e) {}
@@ -450,6 +453,8 @@ public class AltosConfigData implements Iterable<String> {
                /* AO_PYRO_NUM */
                if (npyro > 0)
                        pyros = source.pyros();
+               if (pyro_firing_time >= 0)
+                       pyro_firing_time = source.pyro_firing_time();
 
                /* HAS_APRS */
                if (aprs_interval >= 0)
@@ -500,6 +505,7 @@ public class AltosConfigData implements Iterable<String> {
                        dest.set_pyros(pyros);
                else
                        dest.set_pyros(null);
+               dest.set_pyro_firing_time(pyro_firing_time);
                dest.set_aprs_interval(aprs_interval);
                dest.set_beep(beep);
                dest.set_tracker_motion(tracker_motion);
@@ -565,6 +571,8 @@ public class AltosConfigData implements Iterable<String> {
                                                   pyros[p].toString());
                        }
                }
+               if (pyro_firing_time >= 0)
+                       link.printf("c I %d\n", (int) (pyro_firing_time * 100.0 + 0.5));
 
                /* HAS_APRS */
                if (aprs_interval >= 0)
index 778f122..724ba7d 100644 (file)
@@ -73,6 +73,10 @@ public interface AltosConfigValues {
 
        public abstract AltosPyro[] pyros() throws AltosConfigDataException;
 
+       public abstract void set_pyro_firing_time(double new_pyro_firing_time);
+
+       public abstract double pyro_firing_time() throws AltosConfigDataException;
+
        public abstract int aprs_interval() throws AltosConfigDataException;
 
        public abstract void set_aprs_interval(int new_aprs_interval);
index 7a298a3..f0b4f0f 100644 (file)
@@ -278,6 +278,28 @@ public class AltosConfigPyroUI
                return pyros;
        }
 
+       JLabel                  pyro_firing_time_label;
+       JComboBox<String>       pyro_firing_time_value;
+
+       static String[]         pyro_firing_time_values = {
+               "0.050", "0.100", "0.250", "0.500", "1.0", "2.0"
+       };
+
+       public void set_pyro_firing_time(double new_pyro_firing_time) {
+               pyro_firing_time_value.setSelectedItem(Double.toString(new_pyro_firing_time));
+               pyro_firing_time_value.setEnabled(new_pyro_firing_time >= 0);
+       }
+
+       public double get_pyro_firing_time() throws AltosConfigDataException {
+               String  v = pyro_firing_time_value.getSelectedItem().toString();
+
+               try {
+                       return Double.parseDouble(v);
+               } catch (NumberFormatException e) {
+                       throw new AltosConfigDataException("Invalid pyro firing time \"%s\"", v);
+               }
+       }
+
        public void set_dirty() {
                owner.set_dirty();
        }
@@ -334,7 +356,7 @@ public class AltosConfigPyroUI
                        setVisible(false);
        }
 
-       public AltosConfigPyroUI(AltosConfigUI in_owner, AltosPyro[] pyros) {
+       public AltosConfigPyroUI(AltosConfigUI in_owner, AltosPyro[] pyros, double pyro_firing_time) {
 
                super(in_owner, "Configure Pyro Channels", false);
 
@@ -379,6 +401,32 @@ public class AltosConfigPyroUI
                        columns[i].set(pyros[i]);
                }
 
+               /* Pyro firing time */
+               c = new GridBagConstraints();
+               c.gridx = 0; c.gridy = row;
+               c.gridwidth = 2;
+               c.fill = GridBagConstraints.NONE;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = il;
+               c.ipady = 5;
+               pyro_firing_time_label = new JLabel("Pyro Firing Time(s):");
+               pane.add(pyro_firing_time_label, c);
+
+               c = new GridBagConstraints();
+               c.gridx = 2; c.gridy = row;
+               c.gridwidth = 7;
+               c.fill = GridBagConstraints.HORIZONTAL;
+               c.weightx = 1;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = ir;
+               c.ipady = 5;
+               pyro_firing_time_value = new JComboBox<String>(pyro_firing_time_values);
+               pyro_firing_time_value.setEditable(true);
+               pyro_firing_time_value.addItemListener(this);
+               set_pyro_firing_time(pyro_firing_time);
+               pane.add(pyro_firing_time_value, c);
+               pyro_firing_time_value.setToolTipText("Length of extra pyro channel firing pulse");
+
                c = new GridBagConstraints();
                c.gridx = pyros.length*2-1;
                c.fill = GridBagConstraints.HORIZONTAL;
index ee54e31..56d0d2a 100644 (file)
@@ -78,6 +78,7 @@ public class AltosConfigUI
        JButton                 close;
 
        AltosPyro[]             pyros;
+       double                  pyro_firing_time;
 
        ActionListener          listener;
 
@@ -792,7 +793,7 @@ public class AltosConfigUI
 
                if (cmd.equals("Pyro")) {
                        if (pyro_ui == null && pyros != null)
-                               pyro_ui = new AltosConfigPyroUI(this, pyros);
+                               pyro_ui = new AltosConfigPyroUI(this, pyros, pyro_firing_time);
                        if (pyro_ui != null)
                                pyro_ui.make_visible();
                        return;
@@ -1130,6 +1131,19 @@ public class AltosConfigUI
                return pyros;
        }
 
+       public void set_pyro_firing_time(double new_pyro_firing_time) {
+               pyro_firing_time = new_pyro_firing_time;
+               pyro.setVisible(pyro_firing_time >= 0);
+               if (pyro_firing_time >= 0 && pyro_ui != null)
+                       pyro_ui.set_pyro_firing_time(pyro_firing_time);
+       }
+
+       public double pyro_firing_time() throws AltosConfigDataException {
+               if (pyro_ui != null)
+                       pyro_firing_time = pyro_ui.get_pyro_firing_time();
+               return pyro_firing_time;
+       }
+
        public void set_aprs_interval(int new_aprs_interval) {
                String  s;
 
index 325ca7b..f6c6904 100644 (file)
@@ -115,6 +115,13 @@ public class TeleGPSConfigUI
                return null;
        }
 
+       public void set_pyro_firing_time(double new_pyro_firing_time) {
+       }
+
+       public double pyro_firing_time() {
+               return -1;
+       }
+
        boolean is_telemetrum() {
                String  product = product_value.getText();
                return product != null && product.startsWith("TeleGPS");