f6c6904068b634a256284a77ed9647f8f606b3ff
[fw/altos] / telegps / TeleGPSConfigUI.java
1 /*
2  * Copyright © 2010 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 package org.altusmetrum.telegps;
19
20 import java.awt.*;
21 import java.awt.event.*;
22 import javax.swing.*;
23 import javax.swing.event.*;
24 import org.altusmetrum.altoslib_4.*;
25 import org.altusmetrum.altosuilib_2.*;
26
27 public class TeleGPSConfigUI
28         extends AltosUIDialog
29         implements ActionListener, ItemListener, DocumentListener, AltosConfigValues, AltosUnitsListener
30 {
31
32         Container               pane;
33         JLabel                  product_label;
34         JLabel                  version_label;
35         JLabel                  serial_label;
36         JLabel                  frequency_label;
37         JLabel                  radio_calibration_label;
38         JLabel                  radio_frequency_label;
39         JLabel                  radio_enable_label;
40         JLabel                  aprs_interval_label;
41         JLabel                  flight_log_max_label;
42         JLabel                  callsign_label;
43         JLabel                  tracker_motion_label;
44         JLabel                  tracker_interval_label;
45
46         public boolean          dirty;
47
48         JFrame                  owner;
49         JLabel                  product_value;
50         JLabel                  version_value;
51         JLabel                  serial_value;
52         AltosFreqList           radio_frequency_value;
53         JTextField              radio_calibration_value;
54         JRadioButton            radio_enable_value;
55         JComboBox<String>       aprs_interval_value;
56         JComboBox<String>       flight_log_max_value;
57         JTextField              callsign_value;
58         JComboBox<String>       tracker_motion_value;
59         JComboBox<String>       tracker_interval_value;
60
61         JButton                 save;
62         JButton                 reset;
63         JButton                 reboot;
64         JButton                 close;
65
66         ActionListener          listener;
67
68         static String[]         aprs_interval_values = {
69                 "Disabled",
70                 "2",
71                 "5",
72                 "10"
73         };
74
75         static String[]         tracker_motion_values_m = {
76                 "2",
77                 "5",
78                 "10",
79                 "25",
80         };
81
82         static String[]         tracker_motion_values_ft = {
83                 "5",
84                 "20",
85                 "50",
86                 "100"
87         };
88
89         static String[]         tracker_interval_values = {
90                 "1",
91                 "2",
92                 "5",
93                 "10"
94         };
95
96         /* A window listener to catch closing events and tell the config code */
97         class ConfigListener extends WindowAdapter {
98                 TeleGPSConfigUI ui;
99
100                 public ConfigListener(TeleGPSConfigUI this_ui) {
101                         ui = this_ui;
102                 }
103
104                 public void windowClosing(WindowEvent e) {
105                         ui.actionPerformed(new ActionEvent(e.getSource(),
106                                                            ActionEvent.ACTION_PERFORMED,
107                                                            "Close"));
108                 }
109         }
110
111         public void set_pyros(AltosPyro[] new_pyros) {
112         }
113
114         public AltosPyro[] pyros() {
115                 return null;
116         }
117
118         public void set_pyro_firing_time(double new_pyro_firing_time) {
119         }
120
121         public double pyro_firing_time() {
122                 return -1;
123         }
124
125         boolean is_telemetrum() {
126                 String  product = product_value.getText();
127                 return product != null && product.startsWith("TeleGPS");
128         }
129
130         void set_radio_calibration_tool_tip() {
131                 if (radio_calibration_value.isEnabled())
132                         radio_calibration_value.setToolTipText("Tune radio output to match desired frequency");
133                 else
134                         radio_calibration_value.setToolTipText("Cannot tune radio while connected over packet mode");
135         }
136
137         void set_radio_enable_tool_tip() {
138                 if (radio_enable_value.isEnabled())
139                         radio_enable_value.setToolTipText("Enable/Disable telemetry and RDF transmissions");
140                 else
141                         radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
142         }
143
144         void set_aprs_interval_tool_tip() {
145                 if (aprs_interval_value.isEnabled())
146                         aprs_interval_value.setToolTipText("Enable APRS and set the interval between APRS reports");
147                 else
148                         aprs_interval_value.setToolTipText("Hardware doesn't support APRS");
149         }
150
151         void set_flight_log_max_tool_tip() {
152                 if (flight_log_max_value.isEnabled())
153                         flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)");
154                 else
155                         flight_log_max_value.setToolTipText("Cannot set max value with flight logs in memory");
156         }
157
158         /* Build the UI using a grid bag */
159         public TeleGPSConfigUI(JFrame in_owner) {
160                 super (in_owner, "Configure Flight Computer", false);
161
162                 owner = in_owner;
163                 GridBagConstraints c;
164                 int row = 0;
165
166                 Insets il = new Insets(4,4,4,4);
167                 Insets ir = new Insets(4,4,4,4);
168
169                 pane = getContentPane();
170                 pane.setLayout(new GridBagLayout());
171
172                 /* Product */
173                 c = new GridBagConstraints();
174                 c.gridx = 0; c.gridy = row;
175                 c.gridwidth = 4;
176                 c.fill = GridBagConstraints.NONE;
177                 c.anchor = GridBagConstraints.LINE_START;
178                 c.insets = il;
179                 product_label = new JLabel("Product:");
180                 pane.add(product_label, c);
181
182                 c = new GridBagConstraints();
183                 c.gridx = 4; c.gridy = row;
184                 c.gridwidth = 4;
185                 c.fill = GridBagConstraints.HORIZONTAL;
186                 c.weightx = 1;
187                 c.anchor = GridBagConstraints.LINE_START;
188                 c.insets = ir;
189                 product_value = new JLabel("");
190                 pane.add(product_value, c);
191                 row++;
192
193                 /* Version */
194                 c = new GridBagConstraints();
195                 c.gridx = 0; c.gridy = row;
196                 c.gridwidth = 4;
197                 c.fill = GridBagConstraints.NONE;
198                 c.anchor = GridBagConstraints.LINE_START;
199                 c.insets = il;
200                 c.ipady = 5;
201                 version_label = new JLabel("Software version:");
202                 pane.add(version_label, c);
203
204                 c = new GridBagConstraints();
205                 c.gridx = 4; c.gridy = row;
206                 c.gridwidth = 4;
207                 c.fill = GridBagConstraints.HORIZONTAL;
208                 c.weightx = 1;
209                 c.anchor = GridBagConstraints.LINE_START;
210                 c.insets = ir;
211                 c.ipady = 5;
212                 version_value = new JLabel("");
213                 pane.add(version_value, c);
214                 row++;
215
216                 /* Serial */
217                 c = new GridBagConstraints();
218                 c.gridx = 0; c.gridy = row;
219                 c.gridwidth = 4;
220                 c.fill = GridBagConstraints.NONE;
221                 c.anchor = GridBagConstraints.LINE_START;
222                 c.insets = il;
223                 c.ipady = 5;
224                 serial_label = new JLabel("Serial:");
225                 pane.add(serial_label, c);
226
227                 c = new GridBagConstraints();
228                 c.gridx = 4; c.gridy = row;
229                 c.gridwidth = 4;
230                 c.fill = GridBagConstraints.HORIZONTAL;
231                 c.weightx = 1;
232                 c.anchor = GridBagConstraints.LINE_START;
233                 c.insets = ir;
234                 c.ipady = 5;
235                 serial_value = new JLabel("");
236                 pane.add(serial_value, c);
237                 row++;
238
239                 /* Frequency */
240                 c = new GridBagConstraints();
241                 c.gridx = 0; c.gridy = row;
242                 c.gridwidth = 4;
243                 c.fill = GridBagConstraints.NONE;
244                 c.anchor = GridBagConstraints.LINE_START;
245                 c.insets = il;
246                 c.ipady = 5;
247                 radio_frequency_label = new JLabel("Frequency:");
248                 pane.add(radio_frequency_label, c);
249
250                 c = new GridBagConstraints();
251                 c.gridx = 4; c.gridy = row;
252                 c.gridwidth = 4;
253                 c.fill = GridBagConstraints.HORIZONTAL;
254                 c.weightx = 1;
255                 c.anchor = GridBagConstraints.LINE_START;
256                 c.insets = ir;
257                 c.ipady = 5;
258                 radio_frequency_value = new AltosFreqList();
259                 radio_frequency_value.addItemListener(this);
260                 pane.add(radio_frequency_value, c);
261                 radio_frequency_value.setToolTipText("Telemetry, RDF and packet frequency");
262                 row++;
263
264                 /* Radio Calibration */
265                 c = new GridBagConstraints();
266                 c.gridx = 0; c.gridy = row;
267                 c.gridwidth = 4;
268                 c.fill = GridBagConstraints.NONE;
269                 c.anchor = GridBagConstraints.LINE_START;
270                 c.insets = il;
271                 c.ipady = 5;
272                 radio_calibration_label = new JLabel("RF Calibration:");
273                 pane.add(radio_calibration_label, c);
274
275                 c = new GridBagConstraints();
276                 c.gridx = 4; c.gridy = row;
277                 c.gridwidth = 4;
278                 c.fill = GridBagConstraints.HORIZONTAL;
279                 c.weightx = 1;
280                 c.anchor = GridBagConstraints.LINE_START;
281                 c.insets = ir;
282                 c.ipady = 5;
283                 radio_calibration_value = new JTextField(String.format("%d", 1186611));
284                 radio_calibration_value.getDocument().addDocumentListener(this);
285                 pane.add(radio_calibration_value, c);
286                 set_radio_calibration_tool_tip();
287                 row++;
288
289                 /* Radio Enable */
290                 c = new GridBagConstraints();
291                 c.gridx = 0; c.gridy = row;
292                 c.gridwidth = 4;
293                 c.fill = GridBagConstraints.NONE;
294                 c.anchor = GridBagConstraints.LINE_START;
295                 c.insets = il;
296                 c.ipady = 5;
297                 radio_enable_label = new JLabel("Telemetry/RDF/APRS Enable:");
298                 pane.add(radio_enable_label, c);
299
300                 c = new GridBagConstraints();
301                 c.gridx = 4; c.gridy = row;
302                 c.gridwidth = 4;
303                 c.fill = GridBagConstraints.HORIZONTAL;
304                 c.weightx = 1;
305                 c.anchor = GridBagConstraints.LINE_START;
306                 c.insets = ir;
307                 c.ipady = 5;
308                 radio_enable_value = new JRadioButton("Enabled");
309                 radio_enable_value.addItemListener(this);
310                 pane.add(radio_enable_value, c);
311                 set_radio_enable_tool_tip();
312                 row++;
313
314                 /* APRS interval */
315                 c = new GridBagConstraints();
316                 c.gridx = 0; c.gridy = row;
317                 c.gridwidth = 4;
318                 c.fill = GridBagConstraints.NONE;
319                 c.anchor = GridBagConstraints.LINE_START;
320                 c.insets = il;
321                 c.ipady = 5;
322                 aprs_interval_label = new JLabel("APRS Interval(s):");
323                 pane.add(aprs_interval_label, c);
324
325                 c = new GridBagConstraints();
326                 c.gridx = 4; c.gridy = row;
327                 c.gridwidth = 4;
328                 c.fill = GridBagConstraints.HORIZONTAL;
329                 c.weightx = 1;
330                 c.anchor = GridBagConstraints.LINE_START;
331                 c.insets = ir;
332                 c.ipady = 5;
333                 aprs_interval_value = new JComboBox<String>(aprs_interval_values);
334                 aprs_interval_value.setEditable(true);
335                 aprs_interval_value.addItemListener(this);
336                 pane.add(aprs_interval_value, c);
337                 set_aprs_interval_tool_tip();
338                 row++;
339
340                 /* Callsign */
341                 c = new GridBagConstraints();
342                 c.gridx = 0; c.gridy = row;
343                 c.gridwidth = 4;
344                 c.fill = GridBagConstraints.NONE;
345                 c.anchor = GridBagConstraints.LINE_START;
346                 c.insets = il;
347                 c.ipady = 5;
348                 callsign_label = new JLabel("Callsign:");
349                 pane.add(callsign_label, c);
350
351                 c = new GridBagConstraints();
352                 c.gridx = 4; c.gridy = row;
353                 c.gridwidth = 4;
354                 c.fill = GridBagConstraints.HORIZONTAL;
355                 c.weightx = 1;
356                 c.anchor = GridBagConstraints.LINE_START;
357                 c.insets = ir;
358                 c.ipady = 5;
359                 callsign_value = new JTextField(AltosUIPreferences.callsign());
360                 callsign_value.getDocument().addDocumentListener(this);
361                 pane.add(callsign_value, c);
362                 callsign_value.setToolTipText("Callsign reported in telemetry data");
363                 row++;
364
365                 /* Flight log max */
366                 c = new GridBagConstraints();
367                 c.gridx = 0; c.gridy = row;
368                 c.gridwidth = 4;
369                 c.fill = GridBagConstraints.NONE;
370                 c.anchor = GridBagConstraints.LINE_START;
371                 c.insets = il;
372                 c.ipady = 5;
373                 flight_log_max_label = new JLabel("Maximum Log Size (kB):");
374                 pane.add(flight_log_max_label, c);
375
376                 c = new GridBagConstraints();
377                 c.gridx = 4; c.gridy = row;
378                 c.gridwidth = 4;
379                 c.fill = GridBagConstraints.HORIZONTAL;
380                 c.weightx = 1;
381                 c.anchor = GridBagConstraints.LINE_START;
382                 c.insets = ir;
383                 c.ipady = 5;
384                 flight_log_max_value = new JComboBox<String>();
385                 flight_log_max_value.setEditable(true);
386                 flight_log_max_value.addItemListener(this);
387                 pane.add(flight_log_max_value, c);
388                 set_flight_log_max_tool_tip();
389                 row++;
390
391                 /* Tracker triger horiz distances */
392                 c = new GridBagConstraints();
393                 c.gridx = 0; c.gridy = row;
394                 c.gridwidth = 4;
395                 c.fill = GridBagConstraints.NONE;
396                 c.anchor = GridBagConstraints.LINE_START;
397                 c.insets = il;
398                 c.ipady = 5;
399                 tracker_motion_label = new JLabel(get_tracker_motion_label());
400                 pane.add(tracker_motion_label, c);
401
402                 c = new GridBagConstraints();
403                 c.gridx = 4; c.gridy = row;
404                 c.gridwidth = 4;
405                 c.fill = GridBagConstraints.HORIZONTAL;
406                 c.weightx = 1;
407                 c.anchor = GridBagConstraints.LINE_START;
408                 c.insets = ir;
409                 c.ipady = 5;
410                 tracker_motion_value = new JComboBox<String>(tracker_motion_values());
411                 tracker_motion_value.setEditable(true);
412                 tracker_motion_value.addItemListener(this);
413                 pane.add(tracker_motion_value, c);
414                 row++;
415
416                 /* Tracker triger vert distances */
417                 c = new GridBagConstraints();
418                 c.gridx = 0; c.gridy = row;
419                 c.gridwidth = 4;
420                 c.fill = GridBagConstraints.NONE;
421                 c.anchor = GridBagConstraints.LINE_START;
422                 c.insets = il;
423                 c.ipady = 5;
424                 tracker_interval_label = new JLabel("Position Reporting Interval (s):");
425                 pane.add(tracker_interval_label, c);
426
427                 c = new GridBagConstraints();
428                 c.gridx = 4; c.gridy = row;
429                 c.gridwidth = 4;
430                 c.fill = GridBagConstraints.HORIZONTAL;
431                 c.weightx = 1;
432                 c.anchor = GridBagConstraints.LINE_START;
433                 c.insets = ir;
434                 c.ipady = 5;
435                 tracker_interval_value = new JComboBox<String>(tracker_interval_values);
436                 tracker_interval_value.setEditable(true);
437                 tracker_interval_value.addItemListener(this);
438                 pane.add(tracker_interval_value, c);
439                 set_tracker_tool_tip();
440                 row++;
441
442                 /* Buttons */
443                 c = new GridBagConstraints();
444                 c.gridx = 0; c.gridy = row;
445                 c.gridwidth = 2;
446                 c.fill = GridBagConstraints.NONE;
447                 c.anchor = GridBagConstraints.LINE_START;
448                 c.insets = il;
449                 save = new JButton("Save");
450                 pane.add(save, c);
451                 save.addActionListener(this);
452                 save.setActionCommand("Save");
453
454                 c = new GridBagConstraints();
455                 c.gridx = 2; c.gridy = row;
456                 c.gridwidth = 2;
457                 c.fill = GridBagConstraints.NONE;
458                 c.anchor = GridBagConstraints.CENTER;
459                 c.insets = il;
460                 reset = new JButton("Reset");
461                 pane.add(reset, c);
462                 reset.addActionListener(this);
463                 reset.setActionCommand("Reset");
464
465                 c = new GridBagConstraints();
466                 c.gridx = 4; c.gridy = row;
467                 c.gridwidth = 2;
468                 c.fill = GridBagConstraints.NONE;
469                 c.anchor = GridBagConstraints.CENTER;
470                 c.insets = il;
471                 reboot = new JButton("Reboot");
472                 pane.add(reboot, c);
473                 reboot.addActionListener(this);
474                 reboot.setActionCommand("Reboot");
475
476                 c = new GridBagConstraints();
477                 c.gridx = 6; c.gridy = row;
478                 c.gridwidth = 2;
479                 c.fill = GridBagConstraints.NONE;
480                 c.anchor = GridBagConstraints.LINE_END;
481                 c.insets = il;
482                 close = new JButton("Close");
483                 pane.add(close, c);
484                 close.addActionListener(this);
485                 close.setActionCommand("Close");
486
487                 addWindowListener(new ConfigListener(this));
488                 AltosPreferences.register_units_listener(this);
489         }
490
491         /* Once the initial values are set, the config code will show the dialog */
492         public void make_visible() {
493                 pack();
494                 setLocationRelativeTo(owner);
495                 setVisible(true);
496         }
497
498         /* If any values have been changed, confirm before closing */
499         public boolean check_dirty(String operation) {
500                 if (dirty) {
501                         Object[] options = { String.format("%s anyway", operation), "Keep editing" };
502                         int i;
503                         i = JOptionPane.showOptionDialog(this,
504                                                          String.format("Configuration modified. %s anyway?", operation),
505                                                          "Configuration Modified",
506                                                          JOptionPane.DEFAULT_OPTION,
507                                                          JOptionPane.WARNING_MESSAGE,
508                                                          null, options, options[1]);
509                         if (i != 0)
510                                 return false;
511                 }
512                 return true;
513         }
514
515         void set_dirty() {
516                 dirty = true;
517                 save.setEnabled(true);
518         }
519
520         public void set_clean() {
521                 dirty = false;
522                 save.setEnabled(false);
523         }
524
525         public void dispose() {
526                 AltosPreferences.unregister_units_listener(this);
527                 super.dispose();
528         }
529
530         /* Listen for events from our buttons */
531         public void actionPerformed(ActionEvent e) {
532                 String  cmd = e.getActionCommand();
533
534                 if (cmd.equals("Close") || cmd.equals("Reboot"))
535                         if (!check_dirty(cmd))
536                                 return;
537                 listener.actionPerformed(e);
538                 if (cmd.equals("Close") || cmd.equals("Reboot")) {
539                         setVisible(false);
540                         dispose();
541                 }
542                 set_clean();
543         }
544
545         /* ItemListener interface method */
546         public void itemStateChanged(ItemEvent e) {
547                 set_dirty();
548         }
549
550         /* DocumentListener interface methods */
551         public void changedUpdate(DocumentEvent e) {
552                 set_dirty();
553         }
554
555         public void insertUpdate(DocumentEvent e) {
556                 set_dirty();
557         }
558
559         public void removeUpdate(DocumentEvent e) {
560                 set_dirty();
561         }
562
563         /* Let the config code hook on a listener */
564         public void addActionListener(ActionListener l) {
565                 listener = l;
566         }
567
568         public void units_changed(boolean imperial_units) {
569                 if (tracker_motion_value.isEnabled()) {
570                         String motion = tracker_motion_value.getSelectedItem().toString();
571                         tracker_motion_label.setText(get_tracker_motion_label());
572                         set_tracker_motion_values();
573                         set_tracker_motion((int) (AltosConvert.height.parse(motion, !imperial_units) + 0.5));
574                 }
575         }
576
577         /* set and get all of the dialog values */
578         public void set_product(String product) {
579                 radio_frequency_value.set_product(product);
580                 product_value.setText(product);
581                 set_flight_log_max_tool_tip();
582         }
583
584         public void set_version(String version) {
585                 version_value.setText(version);
586         }
587
588         public void set_serial(int serial) {
589                 radio_frequency_value.set_serial(serial);
590                 serial_value.setText(String.format("%d", serial));
591         }
592
593         public void set_main_deploy(int new_main_deploy) {
594         }
595
596         public int main_deploy() {
597                 return -1;
598         }
599
600         public void set_apogee_delay(int new_apogee_delay) { }
601
602         public int apogee_delay() {
603                 return -1;
604         }
605
606         public void set_apogee_lockout(int new_apogee_lockout) { }
607
608         public int apogee_lockout() { return -1; }
609
610         public void set_radio_frequency(double new_radio_frequency) {
611                 radio_frequency_value.set_frequency(new_radio_frequency);
612         }
613
614         public double radio_frequency() {
615                 return radio_frequency_value.frequency();
616         }
617
618         public void set_radio_calibration(int new_radio_calibration) {
619                 radio_calibration_value.setVisible(new_radio_calibration >= 0);
620                 if (new_radio_calibration < 0)
621                         radio_calibration_value.setText("Disabled");
622                 else
623                         radio_calibration_value.setText(String.format("%d", new_radio_calibration));
624         }
625
626         private int parse_int(String name, String s, boolean split) throws AltosConfigDataException {
627                 String v = s;
628                 if (split)
629                         v = s.split("\\s+")[0];
630                 try {
631                         return Integer.parseInt(v);
632                 } catch (NumberFormatException ne) {
633                         throw new AltosConfigDataException("Invalid %s \"%s\"", name, s);
634                 }
635         }
636
637         public int radio_calibration() throws AltosConfigDataException {
638                 return parse_int("radio calibration", radio_calibration_value.getText(), false);
639         }
640
641         public void set_radio_enable(int new_radio_enable) {
642                 if (new_radio_enable >= 0) {
643                         radio_enable_value.setSelected(new_radio_enable > 0);
644                         radio_enable_value.setEnabled(true);
645                 } else {
646                         radio_enable_value.setSelected(true);
647                         radio_enable_value.setVisible(radio_frequency() > 0);
648                         radio_enable_value.setEnabled(false);
649                 }
650                 set_radio_enable_tool_tip();
651         }
652
653         public int radio_enable() {
654                 if (radio_enable_value.isEnabled())
655                         return radio_enable_value.isSelected() ? 1 : 0;
656                 else
657                         return -1;
658         }
659
660         public void set_callsign(String new_callsign) {
661                 callsign_value.setVisible(new_callsign != null);
662                 callsign_value.setText(new_callsign);
663         }
664
665         public String callsign() {
666                 return callsign_value.getText();
667         }
668
669         int     flight_log_max_limit;
670         int     flight_log_max;
671
672         public String flight_log_max_label(int flight_log_max) {
673                 if (flight_log_max_limit != 0) {
674                         int     nflight = flight_log_max_limit / flight_log_max;
675                         String  plural = nflight > 1 ? "s" : "";
676
677                         return String.format("%d (%d flight%s)", flight_log_max, nflight, plural);
678                 }
679                 return String.format("%d", flight_log_max);
680         }
681
682         public void set_flight_log_max(int new_flight_log_max) {
683                 flight_log_max_value.setSelectedItem(flight_log_max_label(new_flight_log_max));
684                 flight_log_max = new_flight_log_max;
685                 set_flight_log_max_tool_tip();
686         }
687
688         public void set_flight_log_max_enabled(boolean enable) {
689                 flight_log_max_value.setEnabled(enable);
690                 set_flight_log_max_tool_tip();
691         }
692
693         public int flight_log_max() throws AltosConfigDataException {
694                 return parse_int("flight log max", flight_log_max_value.getSelectedItem().toString(), true);
695         }
696
697         public void set_flight_log_max_limit(int new_flight_log_max_limit) {
698                 flight_log_max_limit = new_flight_log_max_limit;
699                 flight_log_max_value.removeAllItems();
700                 for (int i = 8; i >= 1; i--) {
701                         int     size = flight_log_max_limit / i;
702                         flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
703                 }
704                 if (flight_log_max != 0)
705                         set_flight_log_max(flight_log_max);
706         }
707
708         public void set_ignite_mode(int new_ignite_mode) { }
709         public int ignite_mode() { return -1; }
710
711
712         public void set_pad_orientation(int new_pad_orientation) { }
713         public int pad_orientation() { return -1; }
714
715         public void set_beep(int new_beep) { }
716
717         public int beep() { return -1; }
718
719         String[] tracker_motion_values() {
720                 if (AltosConvert.imperial_units)
721                         return tracker_motion_values_ft;
722                 else
723                         return tracker_motion_values_m;
724         }
725
726         void set_tracker_motion_values() {
727                 String[]        v = tracker_motion_values();
728                 while (tracker_motion_value.getItemCount() > 0)
729                         tracker_motion_value.removeItemAt(0);
730                 for (int i = 0; i < v.length; i++)
731                         tracker_motion_value.addItem(v[i]);
732                 tracker_motion_value.setMaximumRowCount(v.length);
733         }
734
735         String get_tracker_motion_label() {
736                 return String.format("Logging Trigger Motion (%s):", AltosConvert.height.show_units());
737         }
738
739         void set_tracker_tool_tip() {
740                 if (tracker_motion_value.isEnabled())
741                         tracker_motion_value.setToolTipText("How far the device must move before logging");
742                 else
743                         tracker_motion_value.setToolTipText("This device doesn't disable logging when stationary");
744                 if (tracker_interval_value.isEnabled())
745                         tracker_interval_value.setToolTipText("How often to report GPS position");
746                 else
747                         tracker_interval_value.setToolTipText("This device can't configure interval");
748         }
749
750         public void set_tracker_motion(int tracker_motion) {
751                 tracker_motion_value.setSelectedItem(AltosConvert.height.say(tracker_motion));
752         }
753
754         public int tracker_motion() throws AltosConfigDataException {
755                 return (int) AltosConvert.height.parse(tracker_motion_value.getSelectedItem().toString());
756         }
757
758         public void set_tracker_interval(int tracker_interval) {
759                 tracker_interval_value.setSelectedItem(String.format("%d", tracker_interval));
760         }
761
762         public int tracker_interval() throws AltosConfigDataException {
763                 return parse_int ("tracker interval", tracker_interval_value.getSelectedItem().toString(), false);
764         }
765
766         public void set_aprs_interval(int new_aprs_interval) {
767                 String  s;
768
769                 if (new_aprs_interval <= 0)
770                         s = "Disabled";
771                 else
772                         s = Integer.toString(new_aprs_interval);
773                 aprs_interval_value.setSelectedItem(s);
774                 aprs_interval_value.setVisible(new_aprs_interval >= 0);
775                 set_aprs_interval_tool_tip();
776         }
777
778         public int aprs_interval() throws AltosConfigDataException {
779                 String  s = aprs_interval_value.getSelectedItem().toString();
780
781                 if (s.equals("Disabled"))
782                         return 0;
783                 return parse_int("aprs interval", s, false);
784         }
785 }