altosui: Correctly show/hide receiver battery value
[fw/altos] / altosui / AltosConfigUI.java
1 /*
2  * Copyright © 2010 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 package altosui;
19
20 import java.awt.*;
21 import java.awt.event.*;
22 import javax.swing.*;
23 import javax.swing.event.*;
24 import java.text.*;
25 import org.altusmetrum.altoslib_7.*;
26 import org.altusmetrum.altosuilib_7.*;
27
28 public class AltosConfigUI
29         extends AltosUIDialog
30         implements ActionListener, ItemListener, DocumentListener, AltosConfigValues, AltosUnitsListener
31 {
32
33         Container               pane;
34         JLabel                  product_label;
35         JLabel                  version_label;
36         JLabel                  serial_label;
37         JLabel                  main_deploy_label;
38         JLabel                  apogee_delay_label;
39         JLabel                  apogee_lockout_label;
40         JLabel                  frequency_label;
41         JLabel                  radio_calibration_label;
42         JLabel                  radio_frequency_label;
43         JLabel                  radio_enable_label;
44         JLabel                  rate_label;
45         JLabel                  aprs_interval_label;
46         JLabel                  aprs_ssid_label;
47         JLabel                  aprs_format_label;
48         JLabel                  flight_log_max_label;
49         JLabel                  ignite_mode_label;
50         JLabel                  pad_orientation_label;
51         JLabel                  callsign_label;
52         JLabel                  beep_label;
53         JLabel                  tracker_motion_label;
54         JLabel                  tracker_interval_label;
55
56         public boolean          dirty;
57
58         JFrame                  owner;
59         JLabel                  product_value;
60         JLabel                  version_value;
61         JLabel                  serial_value;
62         JComboBox<String>       main_deploy_value;
63         JComboBox<String>       apogee_delay_value;
64         JComboBox<String>       apogee_lockout_value;
65         AltosUIFreqList         radio_frequency_value;
66         JTextField              radio_calibration_value;
67         JRadioButton            radio_enable_value;
68         AltosUIRateList         rate_value;
69         JComboBox<String>       aprs_interval_value;
70         JComboBox<Integer>      aprs_ssid_value;
71         JComboBox<String>       aprs_format_value;
72         JComboBox<String>       flight_log_max_value;
73         JComboBox<String>       ignite_mode_value;
74         JComboBox<String>       pad_orientation_value;
75         JTextField              callsign_value;
76         JComboBox<String>       beep_value;
77         JComboBox<String>       tracker_motion_value;
78         JComboBox<String>       tracker_interval_value;
79
80         JButton                 pyro;
81
82         JButton                 save;
83         JButton                 reset;
84         JButton                 reboot;
85         JButton                 close;
86
87         AltosPyro[]             pyros;
88         double                  pyro_firing_time;
89
90         ActionListener          listener;
91
92         static String[]         main_deploy_values_m = {
93                 "100", "150", "200", "250", "300", "350",
94                 "400", "450", "500"
95         };
96
97         static String[]         main_deploy_values_ft = {
98                 "250", "500", "750", "1000", "1250", "1500",
99                 "1750", "2000"
100         };
101
102         static String[]         apogee_delay_values = {
103                 "0", "1", "2", "3", "4", "5"
104         };
105
106         static String[]         apogee_lockout_values = {
107                 "0", "5", "10", "15", "20"
108         };
109
110         static String[]         ignite_mode_values = {
111                 "Dual Deploy",
112                 "Redundant Apogee",
113                 "Redundant Main",
114         };
115
116         static String[]         aprs_interval_values = {
117                 "Disabled",
118                 "2",
119                 "5",
120                 "10"
121         };
122
123         static Integer[]        aprs_ssid_values = {
124                 0, 1, 2 ,3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
125         };
126
127         static String[]         beep_values = {
128                 "3750",
129                 "4000",
130                 "4250",
131         };
132
133         static String[]         pad_orientation_values = {
134                 "Antenna Up",
135                 "Antenna Down",
136         };
137
138         static String[]         tracker_motion_values_m = {
139                 "2",
140                 "5",
141                 "10",
142                 "25",
143         };
144
145         static String[]         tracker_motion_values_ft = {
146                 "5",
147                 "20",
148                 "50",
149                 "100"
150         };
151
152         static String[]         tracker_interval_values = {
153                 "1",
154                 "2",
155                 "5",
156                 "10"
157         };
158
159         /* A window listener to catch closing events and tell the config code */
160         class ConfigListener extends WindowAdapter {
161                 AltosConfigUI   ui;
162
163                 public ConfigListener(AltosConfigUI this_ui) {
164                         ui = this_ui;
165                 }
166
167                 public void windowClosing(WindowEvent e) {
168                         ui.actionPerformed(new ActionEvent(e.getSource(),
169                                                            ActionEvent.ACTION_PERFORMED,
170                                                            "Close"));
171                 }
172         }
173
174         boolean is_telemini_v1() {
175                 String  product = product_value.getText();
176                 return product != null && product.startsWith("TeleMini-v1");
177         }
178
179         boolean is_telemini() {
180                 String  product = product_value.getText();
181                 return product != null && product.startsWith("TeleMini");
182         }
183
184         boolean is_easymini() {
185                 String  product = product_value.getText();
186                 return product != null && product.startsWith("EasyMini");
187         }
188
189         boolean is_telemetrum() {
190                 String  product = product_value.getText();
191                 return product != null && product.startsWith("TeleMetrum");
192         }
193
194         void set_radio_calibration_tool_tip() {
195                 if (radio_calibration_value.isEnabled())
196                         radio_calibration_value.setToolTipText("Tune radio output to match desired frequency");
197                 else
198                         radio_calibration_value.setToolTipText("Cannot tune radio while connected over packet mode");
199         }
200
201         void set_radio_enable_tool_tip() {
202                 if (radio_enable_value.isEnabled())
203                         radio_enable_value.setToolTipText("Enable/Disable telemetry and RDF transmissions");
204                 else
205                         radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
206         }
207
208         void set_rate_tool_tip() {
209                 if (rate_value.isEnabled())
210                         rate_value.setToolTipText("Select telemetry baud rate");
211                 else
212                         rate_value.setToolTipText("Firmware version does not support variable telemetry rates");
213         }
214
215         void set_aprs_interval_tool_tip() {
216                 if (aprs_interval_value.isEnabled())
217                         aprs_interval_value.setToolTipText("Enable APRS and set the interval between APRS reports");
218                 else
219                         aprs_interval_value.setToolTipText("Hardware doesn't support APRS");
220         }
221
222         void set_aprs_ssid_tool_tip() {
223                 if (aprs_ssid_value.isEnabled())
224                         aprs_ssid_value.setToolTipText("Set the APRS SSID (secondary station identifier)");
225                 else if (aprs_ssid_value.isEnabled())
226                         aprs_ssid_value.setToolTipText("Software version doesn't support setting the APRS SSID");
227                 else
228                         aprs_ssid_value.setToolTipText("Hardware doesn't support APRS");
229         }
230
231         void set_aprs_format_tool_tip() {
232                 if (aprs_format_value.isEnabled())
233                         aprs_format_value.setToolTipText("Set the APRS format (compressed/uncompressed)");
234                 else if (aprs_format_value.isEnabled())
235                         aprs_format_value.setToolTipText("Software version doesn't support setting the APRS format");
236                 else
237                         aprs_format_value.setToolTipText("Hardware doesn't support APRS");
238         }
239
240         void set_flight_log_max_tool_tip() {
241                 if (flight_log_max_value.isEnabled())
242                         flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)");
243                 else {
244                         if (is_telemini_v1())
245                                 flight_log_max_value.setToolTipText("TeleMini-v1 stores only one flight");
246                         else
247                                 flight_log_max_value.setToolTipText("Cannot set max value with flight logs in memory");
248                 }
249         }
250
251         void set_ignite_mode_tool_tip() {
252                 if (ignite_mode_value.isEnabled())
253                         ignite_mode_value.setToolTipText("Select when igniters will be fired");
254                 else
255                         ignite_mode_value.setToolTipText("Older firmware could not select ignite mode");
256         }
257
258         void set_pad_orientation_tool_tip() {
259                 if (pad_orientation_value.isEnabled())
260                         pad_orientation_value.setToolTipText("How will the computer be mounted in the airframe");
261                 else {
262                         if (is_telemetrum())
263                                 pad_orientation_value.setToolTipText("Older TeleMetrum firmware must fly antenna forward");
264                         else if (is_telemini() || is_easymini())
265                                 pad_orientation_value.setToolTipText("TeleMini and EasyMini don't care how they are mounted");
266                         else
267                                 pad_orientation_value.setToolTipText("Can't select orientation");
268                 }
269         }
270
271         void set_beep_tool_tip() {
272                 if (beep_value.isEnabled())
273                         beep_value.setToolTipText("What frequency the beeper will sound at");
274                 else
275                         beep_value.setToolTipText("Older firmware could not select beeper frequency");
276         }
277
278         /* Build the UI using a grid bag */
279         public AltosConfigUI(JFrame in_owner, boolean remote) {
280                 super (in_owner, "Configure Flight Computer", false);
281
282                 owner = in_owner;
283                 GridBagConstraints c;
284                 int row = 0;
285
286                 Insets il = new Insets(4,4,4,4);
287                 Insets ir = new Insets(4,4,4,4);
288
289                 pane = getContentPane();
290                 pane.setLayout(new GridBagLayout());
291
292                 /* Product */
293                 c = new GridBagConstraints();
294                 c.gridx = 0; c.gridy = row;
295                 c.gridwidth = 4;
296                 c.fill = GridBagConstraints.NONE;
297                 c.anchor = GridBagConstraints.LINE_START;
298                 c.insets = il;
299                 product_label = new JLabel("Product:");
300                 pane.add(product_label, c);
301
302                 c = new GridBagConstraints();
303                 c.gridx = 4; c.gridy = row;
304                 c.gridwidth = 4;
305                 c.fill = GridBagConstraints.HORIZONTAL;
306                 c.weightx = 1;
307                 c.anchor = GridBagConstraints.LINE_START;
308                 c.insets = ir;
309                 product_value = new JLabel("");
310                 pane.add(product_value, c);
311                 row++;
312
313                 /* Version */
314                 c = new GridBagConstraints();
315                 c.gridx = 0; c.gridy = row;
316                 c.gridwidth = 4;
317                 c.fill = GridBagConstraints.NONE;
318                 c.anchor = GridBagConstraints.LINE_START;
319                 c.insets = il;
320                 c.ipady = 5;
321                 version_label = new JLabel("Software version:");
322                 pane.add(version_label, c);
323
324                 c = new GridBagConstraints();
325                 c.gridx = 4; c.gridy = row;
326                 c.gridwidth = 4;
327                 c.fill = GridBagConstraints.HORIZONTAL;
328                 c.weightx = 1;
329                 c.anchor = GridBagConstraints.LINE_START;
330                 c.insets = ir;
331                 c.ipady = 5;
332                 version_value = new JLabel("");
333                 pane.add(version_value, c);
334                 row++;
335
336                 /* Serial */
337                 c = new GridBagConstraints();
338                 c.gridx = 0; c.gridy = row;
339                 c.gridwidth = 4;
340                 c.fill = GridBagConstraints.NONE;
341                 c.anchor = GridBagConstraints.LINE_START;
342                 c.insets = il;
343                 c.ipady = 5;
344                 serial_label = new JLabel("Serial:");
345                 pane.add(serial_label, c);
346
347                 c = new GridBagConstraints();
348                 c.gridx = 4; c.gridy = row;
349                 c.gridwidth = 4;
350                 c.fill = GridBagConstraints.HORIZONTAL;
351                 c.weightx = 1;
352                 c.anchor = GridBagConstraints.LINE_START;
353                 c.insets = ir;
354                 c.ipady = 5;
355                 serial_value = new JLabel("");
356                 pane.add(serial_value, c);
357                 row++;
358
359                 /* Main deploy */
360                 c = new GridBagConstraints();
361                 c.gridx = 0; c.gridy = row;
362                 c.gridwidth = 4;
363                 c.fill = GridBagConstraints.NONE;
364                 c.anchor = GridBagConstraints.LINE_START;
365                 c.insets = il;
366                 c.ipady = 5;
367                 main_deploy_label = new JLabel(get_main_deploy_label());
368                 pane.add(main_deploy_label, c);
369
370                 c = new GridBagConstraints();
371                 c.gridx = 4; c.gridy = row;
372                 c.gridwidth = 4;
373                 c.fill = GridBagConstraints.HORIZONTAL;
374                 c.weightx = 1;
375                 c.anchor = GridBagConstraints.LINE_START;
376                 c.insets = ir;
377                 c.ipady = 5;
378                 main_deploy_value = new JComboBox<String>(main_deploy_values());
379                 main_deploy_value.setEditable(true);
380                 main_deploy_value.addItemListener(this);
381                 pane.add(main_deploy_value, c);
382                 main_deploy_value.setToolTipText("Height above pad altitude to fire main charge");
383                 row++;
384
385                 /* Apogee delay */
386                 c = new GridBagConstraints();
387                 c.gridx = 0; c.gridy = row;
388                 c.gridwidth = 4;
389                 c.fill = GridBagConstraints.NONE;
390                 c.anchor = GridBagConstraints.LINE_START;
391                 c.insets = il;
392                 c.ipady = 5;
393                 apogee_delay_label = new JLabel("Apogee Delay(s):");
394                 pane.add(apogee_delay_label, c);
395
396                 c = new GridBagConstraints();
397                 c.gridx = 4; c.gridy = row;
398                 c.gridwidth = 4;
399                 c.fill = GridBagConstraints.HORIZONTAL;
400                 c.weightx = 1;
401                 c.anchor = GridBagConstraints.LINE_START;
402                 c.insets = ir;
403                 c.ipady = 5;
404                 apogee_delay_value = new JComboBox<String>(apogee_delay_values);
405                 apogee_delay_value.setEditable(true);
406                 apogee_delay_value.addItemListener(this);
407                 pane.add(apogee_delay_value, c);
408                 apogee_delay_value.setToolTipText("Delay after apogee before charge fires");
409                 row++;
410
411                 /* Apogee lockout */
412                 c = new GridBagConstraints();
413                 c.gridx = 0; c.gridy = row;
414                 c.gridwidth = 4;
415                 c.fill = GridBagConstraints.NONE;
416                 c.anchor = GridBagConstraints.LINE_START;
417                 c.insets = il;
418                 c.ipady = 5;
419                 apogee_lockout_label = new JLabel("Apogee Lockout(s):");
420                 pane.add(apogee_lockout_label, c);
421
422                 c = new GridBagConstraints();
423                 c.gridx = 4; c.gridy = row;
424                 c.gridwidth = 4;
425                 c.fill = GridBagConstraints.HORIZONTAL;
426                 c.weightx = 1;
427                 c.anchor = GridBagConstraints.LINE_START;
428                 c.insets = ir;
429                 c.ipady = 5;
430                 apogee_lockout_value = new JComboBox<String>(apogee_lockout_values);
431                 apogee_lockout_value.setEditable(true);
432                 apogee_lockout_value.addItemListener(this);
433                 pane.add(apogee_lockout_value, c);
434                 apogee_lockout_value.setToolTipText("Time after boost while apogee detection is locked out");
435                 row++;
436
437                 /* Frequency */
438                 c = new GridBagConstraints();
439                 c.gridx = 0; c.gridy = row;
440                 c.gridwidth = 4;
441                 c.fill = GridBagConstraints.NONE;
442                 c.anchor = GridBagConstraints.LINE_START;
443                 c.insets = il;
444                 c.ipady = 5;
445                 radio_frequency_label = new JLabel("Frequency:");
446                 pane.add(radio_frequency_label, c);
447
448                 c = new GridBagConstraints();
449                 c.gridx = 4; c.gridy = row;
450                 c.gridwidth = 4;
451                 c.fill = GridBagConstraints.HORIZONTAL;
452                 c.weightx = 1;
453                 c.anchor = GridBagConstraints.LINE_START;
454                 c.insets = ir;
455                 c.ipady = 5;
456                 radio_frequency_value = new AltosUIFreqList();
457                 radio_frequency_value.addItemListener(this);
458                 pane.add(radio_frequency_value, c);
459                 radio_frequency_value.setToolTipText("Telemetry, RDF and packet frequency");
460                 row++;
461
462                 /* Radio Calibration */
463                 c = new GridBagConstraints();
464                 c.gridx = 0; c.gridy = row;
465                 c.gridwidth = 4;
466                 c.fill = GridBagConstraints.NONE;
467                 c.anchor = GridBagConstraints.LINE_START;
468                 c.insets = il;
469                 c.ipady = 5;
470                 radio_calibration_label = new JLabel("RF Calibration:");
471                 pane.add(radio_calibration_label, c);
472
473                 c = new GridBagConstraints();
474                 c.gridx = 4; c.gridy = row;
475                 c.gridwidth = 4;
476                 c.fill = GridBagConstraints.HORIZONTAL;
477                 c.weightx = 1;
478                 c.anchor = GridBagConstraints.LINE_START;
479                 c.insets = ir;
480                 c.ipady = 5;
481                 radio_calibration_value = new JTextField(String.format("%d", 1186611));
482                 radio_calibration_value.getDocument().addDocumentListener(this);
483                 if (remote)
484                         radio_calibration_value.setEnabled(false);
485                 pane.add(radio_calibration_value, c);
486                 set_radio_calibration_tool_tip();
487                 row++;
488
489                 /* Radio Enable */
490                 c = new GridBagConstraints();
491                 c.gridx = 0; c.gridy = row;
492                 c.gridwidth = 4;
493                 c.fill = GridBagConstraints.NONE;
494                 c.anchor = GridBagConstraints.LINE_START;
495                 c.insets = il;
496                 c.ipady = 5;
497                 radio_enable_label = new JLabel("Telemetry/RDF/APRS Enable:");
498                 pane.add(radio_enable_label, c);
499
500                 c = new GridBagConstraints();
501                 c.gridx = 4; c.gridy = row;
502                 c.gridwidth = 4;
503                 c.fill = GridBagConstraints.HORIZONTAL;
504                 c.weightx = 1;
505                 c.anchor = GridBagConstraints.LINE_START;
506                 c.insets = ir;
507                 c.ipady = 5;
508                 radio_enable_value = new JRadioButton("Enabled");
509                 radio_enable_value.addItemListener(this);
510                 pane.add(radio_enable_value, c);
511                 set_radio_enable_tool_tip();
512                 row++;
513
514                 /* Telemetry Rate */
515                 c = new GridBagConstraints();
516                 c.gridx = 0; c.gridy = row;
517                 c.gridwidth = 4;
518                 c.fill = GridBagConstraints.NONE;
519                 c.anchor = GridBagConstraints.LINE_START;
520                 c.insets = il;
521                 c.ipady = 5;
522                 rate_label = new JLabel("Telemetry baud rate:");
523                 pane.add(rate_label, c);
524
525                 c = new GridBagConstraints();
526                 c.gridx = 4; c.gridy = row;
527                 c.gridwidth = 4;
528                 c.fill = GridBagConstraints.HORIZONTAL;
529                 c.weightx = 1;
530                 c.anchor = GridBagConstraints.LINE_START;
531                 c.insets = ir;
532                 c.ipady = 5;
533                 rate_value = new AltosUIRateList();
534                 rate_value.addItemListener(this);
535                 pane.add(rate_value, c);
536                 set_rate_tool_tip();
537                 row++;
538
539                 /* APRS interval */
540                 c = new GridBagConstraints();
541                 c.gridx = 0; c.gridy = row;
542                 c.gridwidth = 4;
543                 c.fill = GridBagConstraints.NONE;
544                 c.anchor = GridBagConstraints.LINE_START;
545                 c.insets = il;
546                 c.ipady = 5;
547                 aprs_interval_label = new JLabel("APRS Interval(s):");
548                 pane.add(aprs_interval_label, c);
549
550                 c = new GridBagConstraints();
551                 c.gridx = 4; c.gridy = row;
552                 c.gridwidth = 4;
553                 c.fill = GridBagConstraints.HORIZONTAL;
554                 c.weightx = 1;
555                 c.anchor = GridBagConstraints.LINE_START;
556                 c.insets = ir;
557                 c.ipady = 5;
558                 aprs_interval_value = new JComboBox<String>(aprs_interval_values);
559                 aprs_interval_value.setEditable(true);
560                 aprs_interval_value.addItemListener(this);
561                 pane.add(aprs_interval_value, c);
562                 set_aprs_interval_tool_tip();
563                 row++;
564
565                 /* APRS SSID */
566                 c = new GridBagConstraints();
567                 c.gridx = 0; c.gridy = row;
568                 c.gridwidth = 4;
569                 c.fill = GridBagConstraints.NONE;
570                 c.anchor = GridBagConstraints.LINE_START;
571                 c.insets = il;
572                 c.ipady = 5;
573                 aprs_ssid_label = new JLabel("APRS SSID:");
574                 pane.add(aprs_ssid_label, c);
575
576                 c = new GridBagConstraints();
577                 c.gridx = 4; c.gridy = row;
578                 c.gridwidth = 4;
579                 c.fill = GridBagConstraints.HORIZONTAL;
580                 c.weightx = 1;
581                 c.anchor = GridBagConstraints.LINE_START;
582                 c.insets = ir;
583                 c.ipady = 5;
584                 aprs_ssid_value = new JComboBox<Integer>(aprs_ssid_values);
585                 aprs_ssid_value.setEditable(false);
586                 aprs_ssid_value.addItemListener(this);
587                 aprs_ssid_value.setMaximumRowCount(aprs_ssid_values.length);
588                 pane.add(aprs_ssid_value, c);
589                 set_aprs_ssid_tool_tip();
590                 row++;
591
592                 /* APRS format */
593                 c = new GridBagConstraints();
594                 c.gridx = 0; c.gridy = row;
595                 c.gridwidth = 4;
596                 c.fill = GridBagConstraints.NONE;
597                 c.anchor = GridBagConstraints.LINE_START;
598                 c.insets = il;
599                 c.ipady = 5;
600                 aprs_format_label = new JLabel("APRS format:");
601                 pane.add(aprs_format_label, c);
602
603                 c = new GridBagConstraints();
604                 c.gridx = 4; c.gridy = row;
605                 c.gridwidth = 4;
606                 c.fill = GridBagConstraints.HORIZONTAL;
607                 c.weightx = 1;
608                 c.anchor = GridBagConstraints.LINE_START;
609                 c.insets = ir;
610                 c.ipady = 5;
611                 aprs_format_value = new JComboBox<String>(AltosLib.ao_aprs_format_name);
612                 aprs_format_value.setEditable(false);
613                 aprs_format_value.addItemListener(this);
614                 aprs_format_value.setMaximumRowCount(AltosLib.ao_aprs_format_name.length);
615                 pane.add(aprs_format_value, c);
616                 set_aprs_format_tool_tip();
617                 row++;
618
619                 /* Callsign */
620                 c = new GridBagConstraints();
621                 c.gridx = 0; c.gridy = row;
622                 c.gridwidth = 4;
623                 c.fill = GridBagConstraints.NONE;
624                 c.anchor = GridBagConstraints.LINE_START;
625                 c.insets = il;
626                 c.ipady = 5;
627                 callsign_label = new JLabel("Callsign:");
628                 pane.add(callsign_label, c);
629
630                 c = new GridBagConstraints();
631                 c.gridx = 4; c.gridy = row;
632                 c.gridwidth = 4;
633                 c.fill = GridBagConstraints.HORIZONTAL;
634                 c.weightx = 1;
635                 c.anchor = GridBagConstraints.LINE_START;
636                 c.insets = ir;
637                 c.ipady = 5;
638                 callsign_value = new JTextField(AltosUIPreferences.callsign());
639                 callsign_value.getDocument().addDocumentListener(this);
640                 pane.add(callsign_value, c);
641                 callsign_value.setToolTipText("Callsign reported in telemetry data");
642                 row++;
643
644                 /* Flight log max */
645                 c = new GridBagConstraints();
646                 c.gridx = 0; c.gridy = row;
647                 c.gridwidth = 4;
648                 c.fill = GridBagConstraints.NONE;
649                 c.anchor = GridBagConstraints.LINE_START;
650                 c.insets = il;
651                 c.ipady = 5;
652                 flight_log_max_label = new JLabel("Maximum Flight Log Size (kB):");
653                 pane.add(flight_log_max_label, c);
654
655                 c = new GridBagConstraints();
656                 c.gridx = 4; c.gridy = row;
657                 c.gridwidth = 4;
658                 c.fill = GridBagConstraints.HORIZONTAL;
659                 c.weightx = 1;
660                 c.anchor = GridBagConstraints.LINE_START;
661                 c.insets = ir;
662                 c.ipady = 5;
663                 flight_log_max_value = new JComboBox<String>();
664                 flight_log_max_value.setEditable(true);
665                 flight_log_max_value.addItemListener(this);
666                 pane.add(flight_log_max_value, c);
667                 set_flight_log_max_tool_tip();
668                 row++;
669
670                 /* Ignite mode */
671                 c = new GridBagConstraints();
672                 c.gridx = 0; c.gridy = row;
673                 c.gridwidth = 4;
674                 c.fill = GridBagConstraints.NONE;
675                 c.anchor = GridBagConstraints.LINE_START;
676                 c.insets = il;
677                 c.ipady = 5;
678                 ignite_mode_label = new JLabel("Igniter Firing Mode:");
679                 pane.add(ignite_mode_label, c);
680
681                 c = new GridBagConstraints();
682                 c.gridx = 4; c.gridy = row;
683                 c.gridwidth = 4;
684                 c.fill = GridBagConstraints.HORIZONTAL;
685                 c.weightx = 1;
686                 c.anchor = GridBagConstraints.LINE_START;
687                 c.insets = ir;
688                 c.ipady = 5;
689                 ignite_mode_value = new JComboBox<String>(ignite_mode_values);
690                 ignite_mode_value.setEditable(false);
691                 ignite_mode_value.addItemListener(this);
692                 pane.add(ignite_mode_value, c);
693                 set_ignite_mode_tool_tip();
694                 row++;
695
696                 /* Pad orientation */
697                 c = new GridBagConstraints();
698                 c.gridx = 0; c.gridy = row;
699                 c.gridwidth = 4;
700                 c.fill = GridBagConstraints.NONE;
701                 c.anchor = GridBagConstraints.LINE_START;
702                 c.insets = il;
703                 c.ipady = 5;
704                 pad_orientation_label = new JLabel("Pad Orientation:");
705                 pane.add(pad_orientation_label, c);
706
707                 c = new GridBagConstraints();
708                 c.gridx = 4; c.gridy = row;
709                 c.gridwidth = 4;
710                 c.fill = GridBagConstraints.HORIZONTAL;
711                 c.weightx = 1;
712                 c.anchor = GridBagConstraints.LINE_START;
713                 c.insets = ir;
714                 c.ipady = 5;
715                 pad_orientation_value = new JComboBox<String>(pad_orientation_values);
716                 pad_orientation_value.setEditable(false);
717                 pad_orientation_value.addItemListener(this);
718                 pane.add(pad_orientation_value, c);
719                 set_pad_orientation_tool_tip();
720                 row++;
721
722                 /* Beeper */
723                 c = new GridBagConstraints();
724                 c.gridx = 0; c.gridy = row;
725                 c.gridwidth = 4;
726                 c.fill = GridBagConstraints.NONE;
727                 c.anchor = GridBagConstraints.LINE_START;
728                 c.insets = il;
729                 c.ipady = 5;
730                 beep_label = new JLabel("Beeper Frequency:");
731                 pane.add(beep_label, c);
732
733                 c = new GridBagConstraints();
734                 c.gridx = 4; c.gridy = row;
735                 c.gridwidth = 4;
736                 c.fill = GridBagConstraints.HORIZONTAL;
737                 c.weightx = 1;
738                 c.anchor = GridBagConstraints.LINE_START;
739                 c.insets = ir;
740                 c.ipady = 5;
741                 beep_value = new JComboBox<String>(beep_values);
742                 beep_value.setEditable(true);
743                 beep_value.addItemListener(this);
744                 pane.add(beep_value, c);
745                 set_beep_tool_tip();
746                 row++;
747
748                 /* Tracker triger horiz distances */
749                 c = new GridBagConstraints();
750                 c.gridx = 0; c.gridy = row;
751                 c.gridwidth = 4;
752                 c.fill = GridBagConstraints.NONE;
753                 c.anchor = GridBagConstraints.LINE_START;
754                 c.insets = il;
755                 c.ipady = 5;
756                 tracker_motion_label = new JLabel(get_tracker_motion_label());
757                 pane.add(tracker_motion_label, c);
758
759                 c = new GridBagConstraints();
760                 c.gridx = 4; c.gridy = row;
761                 c.gridwidth = 4;
762                 c.fill = GridBagConstraints.HORIZONTAL;
763                 c.weightx = 1;
764                 c.anchor = GridBagConstraints.LINE_START;
765                 c.insets = ir;
766                 c.ipady = 5;
767                 tracker_motion_value = new JComboBox<String>(tracker_motion_values());
768                 tracker_motion_value.setEditable(true);
769                 tracker_motion_value.addItemListener(this);
770                 pane.add(tracker_motion_value, c);
771                 row++;
772
773                 /* Tracker triger vert distances */
774                 c = new GridBagConstraints();
775                 c.gridx = 0; c.gridy = row;
776                 c.gridwidth = 4;
777                 c.fill = GridBagConstraints.NONE;
778                 c.anchor = GridBagConstraints.LINE_START;
779                 c.insets = il;
780                 c.ipady = 5;
781                 tracker_interval_label = new JLabel("Position Reporting Interval(s):");
782                 pane.add(tracker_interval_label, c);
783
784                 c = new GridBagConstraints();
785                 c.gridx = 4; c.gridy = row;
786                 c.gridwidth = 4;
787                 c.fill = GridBagConstraints.HORIZONTAL;
788                 c.weightx = 1;
789                 c.anchor = GridBagConstraints.LINE_START;
790                 c.insets = ir;
791                 c.ipady = 5;
792                 tracker_interval_value = new JComboBox<String>(tracker_interval_values);
793                 tracker_interval_value.setEditable(true);
794                 tracker_interval_value.addItemListener(this);
795                 pane.add(tracker_interval_value, c);
796                 set_tracker_tool_tip();
797                 row++;
798
799                 /* Pyro channels */
800                 c = new GridBagConstraints();
801                 c.gridx = 4; c.gridy = row;
802                 c.gridwidth = 4;
803                 c.fill = GridBagConstraints.HORIZONTAL;
804                 c.anchor = GridBagConstraints.LINE_START;
805                 c.insets = il;
806                 c.ipady = 5;
807                 pyro = new JButton("Configure Pyro Channels");
808                 pane.add(pyro, c);
809                 pyro.addActionListener(this);
810                 pyro.setActionCommand("Pyro");
811                 row++;
812
813                 /* Buttons */
814                 c = new GridBagConstraints();
815                 c.gridx = 0; c.gridy = row;
816                 c.gridwidth = 2;
817                 c.fill = GridBagConstraints.NONE;
818                 c.anchor = GridBagConstraints.LINE_START;
819                 c.insets = il;
820                 save = new JButton("Save");
821                 pane.add(save, c);
822                 save.addActionListener(this);
823                 save.setActionCommand("Save");
824
825                 c = new GridBagConstraints();
826                 c.gridx = 2; c.gridy = row;
827                 c.gridwidth = 2;
828                 c.fill = GridBagConstraints.NONE;
829                 c.anchor = GridBagConstraints.CENTER;
830                 c.insets = il;
831                 reset = new JButton("Reset");
832                 pane.add(reset, c);
833                 reset.addActionListener(this);
834                 reset.setActionCommand("Reset");
835
836                 c = new GridBagConstraints();
837                 c.gridx = 4; c.gridy = row;
838                 c.gridwidth = 2;
839                 c.fill = GridBagConstraints.NONE;
840                 c.anchor = GridBagConstraints.CENTER;
841                 c.insets = il;
842                 reboot = new JButton("Reboot");
843                 pane.add(reboot, c);
844                 reboot.addActionListener(this);
845                 reboot.setActionCommand("Reboot");
846
847                 c = new GridBagConstraints();
848                 c.gridx = 6; c.gridy = row;
849                 c.gridwidth = 2;
850                 c.fill = GridBagConstraints.NONE;
851                 c.anchor = GridBagConstraints.LINE_END;
852                 c.insets = il;
853                 close = new JButton("Close");
854                 pane.add(close, c);
855                 close.addActionListener(this);
856                 close.setActionCommand("Close");
857
858                 addWindowListener(new ConfigListener(this));
859                 AltosPreferences.register_units_listener(this);
860         }
861
862         /* Once the initial values are set, the config code will show the dialog */
863         public void make_visible() {
864                 pack();
865                 setLocationRelativeTo(owner);
866                 setVisible(true);
867         }
868
869         /* If any values have been changed, confirm before closing */
870         public boolean check_dirty(String operation) {
871                 if (dirty) {
872                         Object[] options = { String.format("%s anyway", operation), "Keep editing" };
873                         int i;
874                         i = JOptionPane.showOptionDialog(this,
875                                                          String.format("Configuration modified. %s anyway?", operation),
876                                                          "Configuration Modified",
877                                                          JOptionPane.DEFAULT_OPTION,
878                                                          JOptionPane.WARNING_MESSAGE,
879                                                          null, options, options[1]);
880                         if (i != 0)
881                                 return false;
882                 }
883                 return true;
884         }
885
886         void set_dirty() {
887                 dirty = true;
888                 save.setEnabled(true);
889         }
890
891         public void set_clean() {
892                 dirty = false;
893                 save.setEnabled(false);
894         }
895
896         AltosConfigPyroUI       pyro_ui;
897
898         public void dispose() {
899                 if (pyro_ui != null)
900                         pyro_ui.dispose();
901                 AltosPreferences.unregister_units_listener(this);
902                 super.dispose();
903         }
904
905         /* Listen for events from our buttons */
906         public void actionPerformed(ActionEvent e) {
907                 String  cmd = e.getActionCommand();
908
909                 if (cmd.equals("Pyro")) {
910                         if (pyro_ui == null && pyros != null)
911                                 pyro_ui = new AltosConfigPyroUI(this, pyros, pyro_firing_time);
912                         if (pyro_ui != null)
913                                 pyro_ui.make_visible();
914                         return;
915                 }
916
917                 if (cmd.equals("Close") || cmd.equals("Reboot"))
918                         if (!check_dirty(cmd))
919                                 return;
920                 listener.actionPerformed(e);
921                 if (cmd.equals("Close") || cmd.equals("Reboot")) {
922                         setVisible(false);
923                         dispose();
924                 }
925                 set_clean();
926         }
927
928         /* ItemListener interface method */
929         public void itemStateChanged(ItemEvent e) {
930                 set_dirty();
931         }
932
933         /* DocumentListener interface methods */
934         public void changedUpdate(DocumentEvent e) {
935                 set_dirty();
936         }
937
938         public void insertUpdate(DocumentEvent e) {
939                 set_dirty();
940         }
941
942         public void removeUpdate(DocumentEvent e) {
943                 set_dirty();
944         }
945
946         /* Let the config code hook on a listener */
947         public void addActionListener(ActionListener l) {
948                 listener = l;
949         }
950
951         /* set and get all of the dialog values */
952         public void set_product(String product) {
953                 radio_frequency_value.set_product(product);
954                 product_value.setText(product);
955                 set_pad_orientation_tool_tip();
956                 set_flight_log_max_tool_tip();
957         }
958
959         public void set_version(String version) {
960                 version_value.setText(version);
961         }
962
963         public void set_serial(int serial) {
964                 radio_frequency_value.set_serial(serial);
965                 serial_value.setText(String.format("%d", serial));
966         }
967
968         public void set_altitude_32(int altitude_32) {
969         }
970
971         public void set_main_deploy(int new_main_deploy) {
972                 main_deploy_value.setSelectedItem(AltosConvert.height.say(new_main_deploy));
973                 main_deploy_value.setEnabled(new_main_deploy >= 0);
974
975                 main_deploy_value.setVisible(new_main_deploy >= 0);
976                 main_deploy_label.setVisible(new_main_deploy >= 0);
977
978         }
979
980         public int main_deploy() throws AltosConfigDataException {
981                 String  str = main_deploy_value.getSelectedItem().toString();
982                 try {
983                         return (int) (AltosConvert.height.parse_locale(str) + 0.5);
984                 } catch (ParseException pe) {
985                         throw new AltosConfigDataException("invalid main deploy height %s", str);
986                 }
987         }
988
989         String get_main_deploy_label() {
990                 return String.format("Main Deploy Altitude(%s):", AltosConvert.height.show_units());
991         }
992
993         String[] main_deploy_values() {
994                 if (AltosConvert.imperial_units)
995                         return main_deploy_values_ft;
996                 else
997                         return main_deploy_values_m;
998         }
999
1000         void set_main_deploy_values() {
1001                 String[]        v = main_deploy_values();
1002                 while (main_deploy_value.getItemCount() > 0)
1003                         main_deploy_value.removeItemAt(0);
1004                 for (int i = 0; i < v.length; i++)
1005                         main_deploy_value.addItem(v[i]);
1006                 main_deploy_value.setMaximumRowCount(v.length);
1007         }
1008
1009         public void units_changed(boolean imperial_units) {
1010                 boolean was_dirty = dirty;
1011
1012                 String v = main_deploy_value.getSelectedItem().toString();
1013                 main_deploy_label.setText(get_main_deploy_label());
1014                 set_main_deploy_values();
1015                 try {
1016                         int m = (int) (AltosConvert.height.parse_locale(v, !imperial_units) + 0.5);
1017                         set_main_deploy(m);
1018                 } catch (ParseException pe) {
1019                 }
1020
1021                 if (tracker_motion_value.isEnabled()) {
1022                         String motion = tracker_motion_value.getSelectedItem().toString();
1023                         tracker_motion_label.setText(get_tracker_motion_label());
1024                         set_tracker_motion_values();
1025                         try {
1026                                 int m = (int) (AltosConvert.height.parse_locale(motion, !imperial_units) + 0.5);
1027                                 set_tracker_motion(m);
1028                         } catch (ParseException pe) {
1029                         }
1030                 }
1031
1032                 if (!was_dirty)
1033                         set_clean();
1034         }
1035
1036         public void set_apogee_delay(int new_apogee_delay) {
1037                 apogee_delay_value.setVisible(new_apogee_delay >= 0);
1038                 apogee_delay_label.setVisible(new_apogee_delay >= 0);
1039
1040                 apogee_delay_value.setSelectedItem(Integer.toString(new_apogee_delay));
1041                 apogee_delay_value.setEnabled(new_apogee_delay >= 0);
1042         }
1043
1044         private int parse_int(String name, String s, boolean split) throws AltosConfigDataException {
1045                 String v = s;
1046                 if (split)
1047                         v = s.split("\\s+")[0];
1048                 try {
1049                         return Integer.parseInt(v);
1050                 } catch (NumberFormatException ne) {
1051                         throw new AltosConfigDataException("Invalid %s \"%s\"", name, s);
1052                 }
1053         }
1054
1055         public int apogee_delay() throws AltosConfigDataException {
1056                 return parse_int("apogee delay", apogee_delay_value.getSelectedItem().toString(), false);
1057         }
1058
1059         public void set_apogee_lockout(int new_apogee_lockout) {
1060                 apogee_lockout_value.setSelectedItem(Integer.toString(new_apogee_lockout));
1061                 apogee_lockout_value.setEnabled(new_apogee_lockout >= 0);
1062
1063                 apogee_lockout_value.setVisible(new_apogee_lockout >= 0);
1064                 apogee_lockout_label.setVisible(new_apogee_lockout >= 0);
1065         }
1066
1067         public int apogee_lockout() throws AltosConfigDataException {
1068                 return parse_int("apogee lockout", apogee_lockout_value.getSelectedItem().toString(), false);
1069         }
1070
1071         public void set_radio_frequency(double new_radio_frequency) {
1072                 radio_frequency_label.setVisible(new_radio_frequency >= 0);
1073                 radio_frequency_value.set_frequency(new_radio_frequency);
1074         }
1075
1076         public double radio_frequency() {
1077                 return radio_frequency_value.frequency();
1078         }
1079
1080         public void set_radio_calibration(int new_radio_calibration) {
1081                 radio_calibration_value.setVisible(new_radio_calibration >= 0);
1082                 radio_calibration_label.setVisible(new_radio_calibration >= 0);
1083
1084                 if (new_radio_calibration < 0)
1085                         radio_calibration_value.setText("Disabled");
1086                 else
1087                         radio_calibration_value.setText(String.format("%d", new_radio_calibration));
1088         }
1089
1090         public int radio_calibration() throws AltosConfigDataException {
1091                 return parse_int("radio calibration", radio_calibration_value.getText(), false);
1092         }
1093
1094         public void set_radio_enable(int new_radio_enable) {
1095                 radio_enable_label.setVisible(new_radio_enable >= 0);
1096                 radio_enable_value.setVisible(new_radio_enable >= 0);
1097
1098                 if (new_radio_enable >= 0) {
1099                         radio_enable_value.setSelected(new_radio_enable > 0);
1100                         radio_enable_value.setEnabled(true);
1101                 } else {
1102                         radio_enable_value.setSelected(true);
1103                         radio_enable_value.setEnabled(false);
1104                 }
1105                 set_radio_enable_tool_tip();
1106         }
1107
1108         public int radio_enable() {
1109                 if (radio_enable_value.isEnabled())
1110                         return radio_enable_value.isSelected() ? 1 : 0;
1111                 else
1112                         return -1;
1113         }
1114
1115         public void set_telemetry_rate(int new_rate) {
1116                 rate_label.setVisible(new_rate >= 0);
1117
1118                 rate_value.set_rate(new_rate);
1119         }
1120
1121         public int telemetry_rate() {
1122                 return rate_value.rate();
1123         }
1124
1125         public void set_callsign(String new_callsign) {
1126                 callsign_value.setVisible(new_callsign != null);
1127                 callsign_label.setVisible(new_callsign != null);
1128
1129                 callsign_value.setText(new_callsign);
1130         }
1131
1132         public String callsign() {
1133                 return callsign_value.getText();
1134         }
1135
1136         int     flight_log_max_limit;
1137         int     flight_log_max;
1138
1139         public String flight_log_max_label(int flight_log_max) {
1140                 if (flight_log_max_limit != 0) {
1141                         int     nflight = flight_log_max_limit / flight_log_max;
1142                         String  plural = nflight > 1 ? "s" : "";
1143
1144                         return String.format("%d (%d flight%s)", flight_log_max, nflight, plural);
1145                 }
1146                 return String.format("%d", flight_log_max);
1147         }
1148
1149         public void set_flight_log_max(int new_flight_log_max) {
1150                 flight_log_max_value.setVisible(new_flight_log_max >= 0);
1151                 flight_log_max_label.setVisible(new_flight_log_max >= 0);
1152
1153                 flight_log_max_value.setSelectedItem(flight_log_max_label(new_flight_log_max));
1154                 flight_log_max = new_flight_log_max;
1155                 set_flight_log_max_tool_tip();
1156         }
1157
1158         public void set_flight_log_max_enabled(boolean enable) {
1159                 flight_log_max_value.setEnabled(enable);
1160                 set_flight_log_max_tool_tip();
1161         }
1162
1163         public int flight_log_max() throws AltosConfigDataException {
1164                 return parse_int("flight log max", flight_log_max_value.getSelectedItem().toString(), true);
1165         }
1166
1167         public void set_flight_log_max_limit(int new_flight_log_max_limit) {
1168                 flight_log_max_limit = new_flight_log_max_limit;
1169                 flight_log_max_value.removeAllItems();
1170                 for (int i = 8; i >= 1; i--) {
1171                         int     size = flight_log_max_limit / i;
1172                         flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
1173                 }
1174                 if (flight_log_max != 0)
1175                         set_flight_log_max(flight_log_max);
1176         }
1177
1178         public void set_ignite_mode(int new_ignite_mode) {
1179                 ignite_mode_value.setVisible(new_ignite_mode >= 0);
1180                 ignite_mode_label.setVisible(new_ignite_mode >= 0);
1181
1182                 if (new_ignite_mode >= ignite_mode_values.length)
1183                         new_ignite_mode = 0;
1184                 if (new_ignite_mode < 0) {
1185                         ignite_mode_value.setEnabled(false);
1186                         new_ignite_mode = 0;
1187                 } else {
1188                         ignite_mode_value.setEnabled(true);
1189                 }
1190                 ignite_mode_value.setSelectedIndex(new_ignite_mode);
1191                 set_ignite_mode_tool_tip();
1192         }
1193
1194         public int ignite_mode() {
1195                 if (ignite_mode_value.isEnabled())
1196                         return ignite_mode_value.getSelectedIndex();
1197                 else
1198                         return -1;
1199         }
1200
1201
1202         public void set_pad_orientation(int new_pad_orientation) {
1203                 pad_orientation_value.setVisible(new_pad_orientation >= 0);
1204                 pad_orientation_label.setVisible(new_pad_orientation >= 0);
1205
1206                 if (new_pad_orientation >= pad_orientation_values.length)
1207                         new_pad_orientation = 0;
1208                 if (new_pad_orientation < 0)
1209                         new_pad_orientation = 0;
1210                 pad_orientation_value.setSelectedIndex(new_pad_orientation);
1211                 set_pad_orientation_tool_tip();
1212         }
1213
1214         public int pad_orientation() {
1215                 if (pad_orientation_value.isEnabled())
1216                         return pad_orientation_value.getSelectedIndex();
1217                 else
1218                         return -1;
1219         }
1220
1221         public void set_beep(int new_beep) {
1222                 beep_value.setVisible(new_beep >= 0);
1223                 beep_label.setVisible(new_beep >= 0);
1224
1225                 int new_freq = (int) Math.floor (AltosConvert.beep_value_to_freq(new_beep) + 0.5);
1226                 for (int i = 0; i < beep_values.length; i++)
1227                         if (new_beep == AltosConvert.beep_freq_to_value(Integer.parseInt(beep_values[i]))) {
1228                                 beep_value.setSelectedIndex(i);
1229                                 set_beep_tool_tip();
1230                                 return;
1231                         }
1232                 beep_value.setSelectedItem(String.format("%d", new_freq));
1233                 beep_value.setEnabled(new_beep >= 0);
1234                 set_beep_tool_tip();
1235         }
1236
1237         public int beep() {
1238                 if (beep_value.isEnabled())
1239                         return AltosConvert.beep_freq_to_value(Integer.parseInt(beep_value.getSelectedItem().toString()));
1240                 else
1241                         return -1;
1242         }
1243
1244         String[] tracker_motion_values() {
1245                 if (AltosConvert.imperial_units)
1246                         return tracker_motion_values_ft;
1247                 else
1248                         return tracker_motion_values_m;
1249         }
1250
1251         void set_tracker_motion_values() {
1252                 String[]        v = tracker_motion_values();
1253                 while (tracker_motion_value.getItemCount() > 0)
1254                         tracker_motion_value.removeItemAt(0);
1255                 for (int i = 0; i < v.length; i++)
1256                         tracker_motion_value.addItem(v[i]);
1257                 tracker_motion_value.setMaximumRowCount(v.length);
1258         }
1259
1260         String get_tracker_motion_label() {
1261                 return String.format("Logging Trigger Motion (%s):", AltosConvert.height.show_units());
1262         }
1263
1264         void set_tracker_tool_tip() {
1265                 if (tracker_motion_value.isEnabled())
1266                         tracker_motion_value.setToolTipText("How far the device must move before logging");
1267                 else
1268                         tracker_motion_value.setToolTipText("This device doesn't disable logging when stationary");
1269                 if (tracker_interval_value.isEnabled())
1270                         tracker_interval_value.setToolTipText("How often to report GPS position");
1271                 else
1272                         tracker_interval_value.setToolTipText("This device can't configure interval");
1273         }
1274
1275         public void set_tracker_motion(int tracker_motion) {
1276                 tracker_motion_label.setVisible(tracker_motion >= 0);
1277                 tracker_motion_value.setVisible(tracker_motion >= 0);
1278
1279                 if (tracker_motion < 0) {
1280                         tracker_motion_value.setEnabled(false);
1281                 } else {
1282                         tracker_motion_value.setEnabled(true);
1283                         tracker_motion_value.setSelectedItem(AltosConvert.height.say(tracker_motion));
1284                 }
1285         }
1286
1287         public int tracker_motion() throws AltosConfigDataException {
1288                 String str = tracker_motion_value.getSelectedItem().toString();
1289                 try {
1290                         return (int) (AltosConvert.height.parse_locale(str) + 0.5);
1291                 } catch (ParseException pe) {
1292                         throw new AltosConfigDataException("invalid tracker motion %s", str);
1293                 }
1294         }
1295
1296         public void set_tracker_interval(int tracker_interval) {
1297                 tracker_interval_label.setVisible(tracker_interval >= 0);
1298                 tracker_interval_value.setVisible(tracker_interval >= 0);
1299
1300                 if (tracker_interval< 0) {
1301                         tracker_interval_value.setEnabled(false);
1302                 } else {
1303                         tracker_interval_value.setEnabled(true);
1304                         tracker_interval_value.setSelectedItem(String.format("%d", tracker_interval));
1305                 }
1306         }
1307
1308         public int tracker_interval() throws AltosConfigDataException {
1309                 return parse_int ("tracker interval", tracker_interval_value.getSelectedItem().toString(), false);
1310         }
1311
1312         public void set_pyros(AltosPyro[] new_pyros) {
1313                 pyros = new_pyros;
1314                 pyro.setVisible(pyros != null);
1315                 if (pyros != null && pyro_ui != null)
1316                         pyro_ui.set_pyros(pyros);
1317         }
1318
1319         public AltosPyro[] pyros() throws AltosConfigDataException {
1320                 if (pyro_ui != null)
1321                         pyros = pyro_ui.get_pyros();
1322                 return pyros;
1323         }
1324
1325         public void set_pyro_firing_time(double new_pyro_firing_time) {
1326                 pyro_firing_time = new_pyro_firing_time;
1327                 pyro.setVisible(pyro_firing_time >= 0);
1328                 if (pyro_firing_time >= 0 && pyro_ui != null)
1329                         pyro_ui.set_pyro_firing_time(pyro_firing_time);
1330         }
1331
1332         public double pyro_firing_time() throws AltosConfigDataException {
1333                 if (pyro_ui != null)
1334                         pyro_firing_time = pyro_ui.get_pyro_firing_time();
1335                 return pyro_firing_time;
1336         }
1337
1338         public void set_aprs_interval(int new_aprs_interval) {
1339                 aprs_interval_value.setVisible(new_aprs_interval >= 0);
1340                 aprs_interval_label.setVisible(new_aprs_interval >= 0);
1341
1342                 String  s;
1343
1344                 if (new_aprs_interval <= 0)
1345                         s = "Disabled";
1346                 else
1347                         s = Integer.toString(new_aprs_interval);
1348                 aprs_interval_value.setSelectedItem(s);
1349                 set_aprs_interval_tool_tip();
1350         }
1351
1352         public int aprs_interval() throws AltosConfigDataException {
1353                 String  s = aprs_interval_value.getSelectedItem().toString();
1354
1355                 if (s.equals("Disabled"))
1356                         return 0;
1357                 return parse_int("aprs interval", s, false);
1358         }
1359
1360         public void set_aprs_ssid(int new_aprs_ssid) {
1361                 aprs_ssid_value.setVisible(new_aprs_ssid >= 0);
1362                 aprs_ssid_label.setVisible(new_aprs_ssid >= 0);
1363
1364                 aprs_ssid_value.setSelectedItem(Math.max(0,new_aprs_ssid));
1365                 set_aprs_ssid_tool_tip();
1366         }
1367
1368         public int aprs_ssid() throws AltosConfigDataException {
1369                 Integer i = (Integer) aprs_ssid_value.getSelectedItem();
1370                 return i;
1371         }
1372
1373         public void set_aprs_format(int new_aprs_format) {
1374                 aprs_format_value.setVisible(new_aprs_format >= 0);
1375                 aprs_format_label.setVisible(new_aprs_format >= 0);
1376
1377                 aprs_format_value.setSelectedIndex(Math.max(0,new_aprs_format));
1378                 set_aprs_format_tool_tip();
1379         }
1380
1381         public int aprs_format() throws AltosConfigDataException {
1382                 return aprs_format_value.getSelectedIndex();
1383         }
1384 }