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