altoslib,altosuilib: Bump library version numbers
[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_12.*;
27 import org.altusmetrum.altosuilib_12.*;
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.isVisible())
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.isVisible())
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.isVisible())
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.isVisible())
218                         aprs_ssid_value.setToolTipText("Set the APRS SSID (secondary station identifier)");
219                 else if (aprs_ssid_value.isVisible())
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.isVisible())
227                         aprs_format_value.setToolTipText("Set the APRS format (compressed/uncompressed)");
228                 else if (aprs_format_value.isVisible())
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.isVisible())
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.isVisible())
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.isVisible())
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.isVisible())
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                 if (new_main_deploy != AltosLib.MISSING)
963                         main_deploy_value.setSelectedItem(AltosConvert.height.say(new_main_deploy));
964                 main_deploy_value.setVisible(new_main_deploy != AltosLib.MISSING);
965                 main_deploy_label.setVisible(new_main_deploy != AltosLib.MISSING);
966         }
967
968         public int main_deploy() throws AltosConfigDataException {
969                 String  str = main_deploy_value.getSelectedItem().toString();
970                 try {
971                         return (int) (AltosConvert.height.parse_locale(str) + 0.5);
972                 } catch (ParseException pe) {
973                         throw new AltosConfigDataException("invalid main deploy height %s", str);
974                 }
975         }
976
977         String get_main_deploy_label() {
978                 return String.format("Main Deploy Altitude(%s):", AltosConvert.height.parse_units());
979         }
980
981         String[] main_deploy_values() {
982                 if (AltosConvert.imperial_units)
983                         return main_deploy_values_ft;
984                 else
985                         return main_deploy_values_m;
986         }
987
988         void set_main_deploy_values() {
989                 String[]        v = main_deploy_values();
990                 while (main_deploy_value.getItemCount() > 0)
991                         main_deploy_value.removeItemAt(0);
992                 for (int i = 0; i < v.length; i++)
993                         main_deploy_value.addItem(v[i]);
994                 main_deploy_value.setMaximumRowCount(v.length);
995         }
996
997         public void units_changed(boolean imperial_units) {
998                 boolean was_dirty = dirty;
999
1000                 String v = main_deploy_value.getSelectedItem().toString();
1001                 main_deploy_label.setText(get_main_deploy_label());
1002                 set_main_deploy_values();
1003                 try {
1004                         int m = (int) (AltosConvert.height.parse_locale(v, !imperial_units) + 0.5);
1005                         set_main_deploy(m);
1006                 } catch (ParseException pe) {
1007                 }
1008
1009                 if (tracker_motion_value.isVisible()) {
1010                         String motion = tracker_motion_value.getSelectedItem().toString();
1011                         tracker_motion_label.setText(get_tracker_motion_label());
1012                         set_tracker_motion_values();
1013                         try {
1014                                 int m = (int) (AltosConvert.height.parse_locale(motion, !imperial_units) + 0.5);
1015                                 set_tracker_motion(m);
1016                         } catch (ParseException pe) {
1017                         }
1018                 }
1019
1020                 if (!was_dirty)
1021                         set_clean();
1022         }
1023
1024         public void set_apogee_delay(int new_apogee_delay) {
1025                 if (new_apogee_delay != AltosLib.MISSING)
1026                         apogee_delay_value.setSelectedItem(Integer.toString(new_apogee_delay));
1027                 apogee_delay_value.setVisible(new_apogee_delay != AltosLib.MISSING);
1028                 apogee_delay_label.setVisible(new_apogee_delay != AltosLib.MISSING);
1029         }
1030
1031         private int parse_int(String name, String s, boolean split) throws AltosConfigDataException {
1032                 String v = s;
1033                 if (split)
1034                         v = s.split("\\s+")[0];
1035                 try {
1036                         return Integer.parseInt(v);
1037                 } catch (NumberFormatException ne) {
1038                         throw new AltosConfigDataException("Invalid %s \"%s\"", name, s);
1039                 }
1040         }
1041
1042         public int apogee_delay() throws AltosConfigDataException {
1043                 return parse_int("apogee delay", apogee_delay_value.getSelectedItem().toString(), false);
1044         }
1045
1046         public void set_apogee_lockout(int new_apogee_lockout) {
1047                 if (new_apogee_lockout != AltosLib.MISSING)
1048                         apogee_lockout_value.setSelectedItem(Integer.toString(new_apogee_lockout));
1049
1050                 apogee_lockout_value.setVisible(new_apogee_lockout != AltosLib.MISSING);
1051                 apogee_lockout_label.setVisible(new_apogee_lockout != AltosLib.MISSING);
1052         }
1053
1054         public int apogee_lockout() throws AltosConfigDataException {
1055                 return parse_int("apogee lockout", apogee_lockout_value.getSelectedItem().toString(), false);
1056         }
1057
1058         public void set_radio_frequency(double new_radio_frequency) {
1059                 if (new_radio_frequency != AltosLib.MISSING)
1060                         radio_frequency_value.set_frequency(new_radio_frequency);
1061                 radio_frequency_label.setVisible(new_radio_frequency != AltosLib.MISSING);
1062                 radio_frequency_value.setVisible(new_radio_frequency != AltosLib.MISSING);
1063         }
1064
1065         public double radio_frequency() {
1066                 return radio_frequency_value.frequency();
1067         }
1068
1069         public void set_radio_calibration(int new_radio_calibration) {
1070                 if (new_radio_calibration != AltosLib.MISSING)
1071                         radio_calibration_value.setText(String.format("%d", new_radio_calibration));
1072                 radio_calibration_value.setVisible(new_radio_calibration != AltosLib.MISSING);
1073                 radio_calibration_label.setVisible(new_radio_calibration != AltosLib.MISSING);
1074         }
1075
1076         public void set_radio_enable(int new_radio_enable) {
1077                 if (new_radio_enable != AltosLib.MISSING)
1078                         radio_enable_value.setSelected(new_radio_enable != 0);
1079                 radio_enable_label.setVisible(new_radio_enable != AltosLib.MISSING);
1080                 radio_enable_value.setVisible(new_radio_enable != AltosLib.MISSING);
1081                 set_radio_enable_tool_tip();
1082         }
1083
1084         public int radio_enable() {
1085                 if (radio_enable_value.isVisible())
1086                         return radio_enable_value.isSelected() ? 1 : 0;
1087                 else
1088                         return AltosLib.MISSING;
1089         }
1090
1091         public void set_telemetry_rate(int new_rate) {
1092                 if (new_rate != AltosLib.MISSING)
1093                         rate_value.set_rate(new_rate);
1094                 rate_label.setVisible(new_rate != AltosLib.MISSING);
1095                 rate_value.setVisible(new_rate != AltosLib.MISSING);
1096                 set_rate_tool_tip();
1097         }
1098
1099         public int telemetry_rate() {
1100                 return rate_value.rate();
1101         }
1102
1103         public void set_callsign(String new_callsign) {
1104                 if (new_callsign != null)
1105                         callsign_value.setText(new_callsign);
1106                 callsign_value.setVisible(new_callsign != null);
1107                 callsign_label.setVisible(new_callsign != null);
1108         }
1109
1110         public String callsign() {
1111                 if (callsign_value.isVisible())
1112                         return callsign_value.getText();
1113                 return null;
1114         }
1115
1116         int     flight_log_max_limit;
1117         int     flight_log_max;
1118
1119         public String flight_log_max_label(int flight_log_max) {
1120                 if (flight_log_max_limit != 0) {
1121                         int     nflight = flight_log_max_limit / flight_log_max;
1122                         String  plural = nflight > 1 ? "s" : "";
1123
1124                         return String.format("%d (%d flight%s)", flight_log_max, nflight, plural);
1125                 }
1126                 return String.format("%d", flight_log_max);
1127         }
1128
1129         public void set_flight_log_max(int new_flight_log_max) {
1130                 if (new_flight_log_max != AltosLib.MISSING) {
1131                         flight_log_max_value.setSelectedItem(flight_log_max_label(new_flight_log_max));
1132                         flight_log_max = new_flight_log_max;
1133                 }
1134                 flight_log_max_value.setVisible(new_flight_log_max != AltosLib.MISSING);
1135                 flight_log_max_label.setVisible(new_flight_log_max != AltosLib.MISSING);
1136                 set_flight_log_max_tool_tip();
1137         }
1138
1139         public void set_flight_log_max_enabled(boolean enable) {
1140                 flight_log_max_value.setEnabled(enable);
1141                 set_flight_log_max_tool_tip();
1142         }
1143
1144         public int flight_log_max() throws AltosConfigDataException {
1145                 if (flight_log_max_value.isVisible())
1146                         return parse_int("flight log max", flight_log_max_value.getSelectedItem().toString(), true);
1147                 return AltosLib.MISSING;
1148         }
1149
1150         public void set_flight_log_max_limit(int new_flight_log_max_limit) {
1151                 flight_log_max_limit = new_flight_log_max_limit;
1152                 if (new_flight_log_max_limit != AltosLib.MISSING) {
1153                         flight_log_max_value.removeAllItems();
1154                         for (int i = 8; i >= 1; i--) {
1155                                 int     size = flight_log_max_limit / i;
1156                                 flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
1157                         }
1158                 }
1159                 if (flight_log_max != 0)
1160                         set_flight_log_max(flight_log_max);
1161         }
1162
1163         public void set_ignite_mode(int new_ignite_mode) {
1164                 if (new_ignite_mode != AltosLib.MISSING) {
1165                         if (new_ignite_mode >= ignite_mode_values.length)
1166                                 new_ignite_mode = 0;
1167                         if (new_ignite_mode < 0) {
1168                                 ignite_mode_value.setEnabled(false);
1169                                 new_ignite_mode = 0;
1170                         } else {
1171                                 ignite_mode_value.setEnabled(true);
1172                         }
1173                         ignite_mode_value.setSelectedIndex(new_ignite_mode);
1174                 }
1175                 ignite_mode_value.setVisible(new_ignite_mode != AltosLib.MISSING);
1176                 ignite_mode_label.setVisible(new_ignite_mode != AltosLib.MISSING);
1177
1178                 set_ignite_mode_tool_tip();
1179         }
1180
1181         public int ignite_mode() {
1182                 if (ignite_mode_value.isVisible())
1183                         return ignite_mode_value.getSelectedIndex();
1184                 else
1185                         return AltosLib.MISSING;
1186         }
1187
1188
1189         public void set_pad_orientation(int new_pad_orientation) {
1190                 if (new_pad_orientation != AltosLib.MISSING) {
1191                         if (new_pad_orientation >= pad_orientation_values.length)
1192                                 new_pad_orientation = 0;
1193                         if (new_pad_orientation < 0)
1194                                 new_pad_orientation = 0;
1195                         pad_orientation_value.setSelectedIndex(new_pad_orientation);
1196                 }
1197                 pad_orientation_value.setVisible(new_pad_orientation != AltosLib.MISSING);
1198                 pad_orientation_label.setVisible(new_pad_orientation != AltosLib.MISSING);
1199
1200                 set_pad_orientation_tool_tip();
1201         }
1202
1203         public int pad_orientation() {
1204                 if (pad_orientation_value.isVisible())
1205                         return pad_orientation_value.getSelectedIndex();
1206                 else
1207                         return AltosLib.MISSING;
1208         }
1209
1210         public void set_beep(int new_beep) {
1211                 if (new_beep != AltosLib.MISSING) {
1212                         int new_freq = (int) Math.floor (AltosConvert.beep_value_to_freq(new_beep) + 0.5);
1213                         for (int i = 0; i < beep_values.length; i++)
1214                                 if (new_beep == AltosConvert.beep_freq_to_value(Integer.parseInt(beep_values[i]))) {
1215                                         beep_value.setSelectedIndex(i);
1216                                         set_beep_tool_tip();
1217                                         return;
1218                                 }
1219                         beep_value.setSelectedItem(String.format("%d", new_freq));
1220                 }
1221                 beep_value.setVisible(new_beep != AltosLib.MISSING);
1222                 beep_label.setVisible(new_beep != AltosLib.MISSING);
1223                 set_beep_tool_tip();
1224         }
1225
1226         public int beep() {
1227                 if (beep_value.isVisible())
1228                         return AltosConvert.beep_freq_to_value(Integer.parseInt(beep_value.getSelectedItem().toString()));
1229                 else
1230                         return AltosLib.MISSING;
1231         }
1232
1233         String[] tracker_motion_values() {
1234                 if (AltosConvert.imperial_units)
1235                         return tracker_motion_values_ft;
1236                 else
1237                         return tracker_motion_values_m;
1238         }
1239
1240         void set_tracker_motion_values() {
1241                 String[]        v = tracker_motion_values();
1242                 while (tracker_motion_value.getItemCount() > 0)
1243                         tracker_motion_value.removeItemAt(0);
1244                 for (int i = 0; i < v.length; i++)
1245                         tracker_motion_value.addItem(v[i]);
1246                 tracker_motion_value.setMaximumRowCount(v.length);
1247         }
1248
1249         String get_tracker_motion_label() {
1250                 return String.format("Logging Trigger Motion (%s):", AltosConvert.height.parse_units());
1251         }
1252
1253         void set_tracker_tool_tip() {
1254                 if (tracker_motion_value.isVisible())
1255                         tracker_motion_value.setToolTipText("How far the device must move before logging");
1256                 else
1257                         tracker_motion_value.setToolTipText("This device doesn't disable logging when stationary");
1258                 if (tracker_interval_value.isVisible())
1259                         tracker_interval_value.setToolTipText("How often to report GPS position");
1260                 else
1261                         tracker_interval_value.setToolTipText("This device can't configure interval");
1262         }
1263
1264         public void set_tracker_motion(int tracker_motion) {
1265                 if (tracker_motion != AltosLib.MISSING)
1266                         tracker_motion_value.setSelectedItem(AltosConvert.height.say(tracker_motion));
1267                 tracker_motion_label.setVisible(tracker_motion != AltosLib.MISSING);
1268                 tracker_motion_value.setVisible(tracker_motion != AltosLib.MISSING);
1269         }
1270
1271         public int tracker_motion() throws AltosConfigDataException {
1272                 if (tracker_motion_value.isVisible()) {
1273                         String str = tracker_motion_value.getSelectedItem().toString();
1274                         try {
1275                                 return (int) (AltosConvert.height.parse_locale(str) + 0.5);
1276                         } catch (ParseException pe) {
1277                                 throw new AltosConfigDataException("invalid tracker motion %s", str);
1278                         }
1279                 }
1280                 return AltosLib.MISSING;
1281         }
1282
1283         public void set_tracker_interval(int tracker_interval) {
1284                 if (tracker_interval != AltosLib.MISSING)
1285                         tracker_interval_value.setSelectedItem(String.format("%d", tracker_interval));
1286                 tracker_interval_label.setVisible(tracker_interval != AltosLib.MISSING);
1287                 tracker_interval_value.setVisible(tracker_interval != AltosLib.MISSING);
1288         }
1289
1290         public int tracker_interval() throws AltosConfigDataException {
1291                 if (tracker_interval_value.isVisible())
1292                         return parse_int ("tracker interval", tracker_interval_value.getSelectedItem().toString(), false);
1293                 return AltosLib.MISSING;
1294         }
1295
1296         public void set_pyros(AltosPyro[] new_pyros) {
1297                 pyros = new_pyros;
1298                 if (pyros != null && pyro_ui != null)
1299                         pyro_ui.set_pyros(pyros);
1300                 pyro.setVisible(pyros != null);
1301         }
1302
1303         public AltosPyro[] pyros() throws AltosConfigDataException {
1304                 if (pyro_ui != null)
1305                         pyros = pyro_ui.get_pyros();
1306                 return pyros;
1307         }
1308
1309         public void set_pyro_firing_time(double new_pyro_firing_time) {
1310                 pyro_firing_time = new_pyro_firing_time;
1311                 if (pyro_firing_time != AltosLib.MISSING && pyro_ui != null)
1312                         pyro_ui.set_pyro_firing_time(pyro_firing_time);
1313                 pyro.setVisible(pyro_firing_time != AltosLib.MISSING);
1314         }
1315
1316         public double pyro_firing_time() throws AltosConfigDataException {
1317                 if (pyro_ui != null)
1318                         pyro_firing_time = pyro_ui.get_pyro_firing_time();
1319                 return pyro_firing_time;
1320         }
1321
1322         public void set_aprs_interval(int new_aprs_interval) {
1323                 if (new_aprs_interval != AltosLib.MISSING)
1324                         aprs_interval_value.setSelectedItem(Integer.toString(new_aprs_interval));
1325                 aprs_interval_value.setVisible(new_aprs_interval != AltosLib.MISSING);
1326                 aprs_interval_label.setVisible(new_aprs_interval != AltosLib.MISSING);
1327                 set_aprs_interval_tool_tip();
1328         }
1329
1330         public int aprs_interval() throws AltosConfigDataException {
1331                 if (aprs_interval_value.isVisible()) {
1332                         String  s = aprs_interval_value.getSelectedItem().toString();
1333
1334                         return parse_int("aprs interval", s, false);
1335                 }
1336                 return AltosLib.MISSING;
1337         }
1338
1339         public void set_aprs_ssid(int new_aprs_ssid) {
1340                 if (new_aprs_ssid != AltosLib.MISSING)
1341                         aprs_ssid_value.setSelectedItem(new_aprs_ssid);
1342                 aprs_ssid_value.setVisible(new_aprs_ssid != AltosLib.MISSING);
1343                 aprs_ssid_label.setVisible(new_aprs_ssid != AltosLib.MISSING);
1344                 set_aprs_ssid_tool_tip();
1345         }
1346
1347         public int aprs_ssid() throws AltosConfigDataException {
1348                 if (aprs_ssid_value.isVisible()) {
1349                         Integer i = (Integer) aprs_ssid_value.getSelectedItem();
1350                         return i;
1351                 }
1352                 return AltosLib.MISSING;
1353         }
1354
1355         public void set_aprs_format(int new_aprs_format) {
1356                 if (new_aprs_format != AltosLib.MISSING)
1357                         aprs_format_value.setSelectedIndex(new_aprs_format);
1358                 aprs_format_value.setVisible(new_aprs_format != AltosLib.MISSING);
1359                 aprs_format_label.setVisible(new_aprs_format != AltosLib.MISSING);
1360                 set_aprs_format_tool_tip();
1361         }
1362
1363         public int aprs_format() throws AltosConfigDataException {
1364                 if (aprs_format_value.isVisible())
1365                         return aprs_format_value.getSelectedIndex();
1366                 return AltosLib.MISSING;
1367         }
1368 }