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