2 * Copyright © 2010 Keith Packard <keithp@keithp.com>
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.
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.
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.
19 package org.altusmetrum.telegps;
23 import java.awt.event.*;
25 import javax.swing.event.*;
26 import org.altusmetrum.altoslib_14.*;
27 import org.altusmetrum.altosuilib_14.*;
29 public class TeleGPSConfigUI
31 implements ActionListener, ItemListener, DocumentListener, AltosConfigValues, AltosUnitsListener
38 JLabel frequency_label;
39 JLabel radio_calibration_label;
40 JLabel radio_frequency_label;
41 JLabel radio_enable_label;
43 JLabel aprs_interval_label;
44 JLabel aprs_ssid_label;
45 JLabel aprs_format_label;
46 JLabel aprs_offset_label;
47 JLabel flight_log_max_label;
48 JLabel callsign_label;
49 JLabel tracker_motion_label;
50 JLabel tracker_interval_label;
58 AltosUIFreqList radio_frequency_value;
59 JLabel radio_calibration_value;
60 JRadioButton radio_enable_value;
61 AltosUIRateList rate_value;
62 JComboBox<String> aprs_interval_value;
63 JComboBox<Integer> aprs_ssid_value;
64 JComboBox<String> aprs_format_value;
65 JComboBox<Integer> aprs_offset_value;
66 JComboBox<String> flight_log_max_value;
67 JTextField callsign_value;
68 JComboBox<String> tracker_motion_value;
69 JComboBox<String> tracker_interval_value;
76 ActionListener listener;
78 static String[] aprs_interval_values = {
85 static Integer[] aprs_ssid_values = {
86 0, 1, 2 ,3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
89 static Integer[] aprs_offset_values = {
90 0, 2, 4, 6, 8, 10, 12, 14, 16, 18
93 static String[] tracker_motion_values_m = {
100 static String[] tracker_motion_values_ft = {
107 static String[] tracker_interval_values = {
114 /* A window listener to catch closing events and tell the config code */
115 class ConfigListener extends WindowAdapter {
118 public ConfigListener(TeleGPSConfigUI this_ui) {
122 public void windowClosing(WindowEvent e) {
123 ui.actionPerformed(new ActionEvent(e.getSource(),
124 ActionEvent.ACTION_PERFORMED,
129 public void set_pyros(AltosPyro[] new_pyros) {
132 public AltosPyro[] pyros() {
136 public void set_pyro_firing_time(double new_pyro_firing_time) {
139 public double pyro_firing_time() {
140 return AltosLib.MISSING;
143 boolean is_telemetrum() {
144 String product = product_value.getText();
145 return product != null && product.startsWith("TeleGPS");
148 void set_radio_enable_tool_tip() {
149 if (radio_enable_value.isVisible())
150 radio_enable_value.setToolTipText("Enable/Disable telemetry and RDF transmissions");
152 radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
155 void set_rate_tool_tip() {
156 if (rate_value.isVisible())
157 rate_value.setToolTipText("Select telemetry baud rate");
159 rate_value.setToolTipText("Firmware version does not support variable telemetry rates");
162 void set_aprs_interval_tool_tip() {
163 if (aprs_interval_value.isVisible())
164 aprs_interval_value.setToolTipText("Enable APRS and set the interval between APRS reports");
166 aprs_interval_value.setToolTipText("Hardware doesn't support APRS");
169 void set_aprs_ssid_tool_tip() {
170 if (aprs_ssid_value.isVisible())
171 aprs_ssid_value.setToolTipText("Set the APRS SSID (secondary station identifier)");
172 else if (aprs_ssid_value.isVisible())
173 aprs_ssid_value.setToolTipText("Software version doesn't support setting the APRS SSID");
175 aprs_ssid_value.setToolTipText("Hardware doesn't support APRS");
178 void set_aprs_format_tool_tip() {
179 if (aprs_format_value.isVisible())
180 aprs_format_value.setToolTipText("Set the APRS format (compressed/uncompressed)");
181 else if (aprs_format_value.isVisible())
182 aprs_format_value.setToolTipText("Software version doesn't support setting the APRS format");
184 aprs_format_value.setToolTipText("Hardware doesn't support APRS");
187 void set_aprs_offset_tool_tip() {
188 if (aprs_offset_value.isVisible())
189 aprs_offset_value.setToolTipText("Set the APRS offset from top of minute");
190 else if (aprs_offset_value.isVisible())
191 aprs_offset_value.setToolTipText("Software version doesn't support setting the APRS offset");
193 aprs_offset_value.setToolTipText("Hardware doesn't support APRS");
196 void set_flight_log_max_tool_tip() {
197 if (flight_log_max_value.isVisible())
198 flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)");
200 flight_log_max_value.setToolTipText("Cannot set max value with flight logs in memory");
203 /* Build the UI using a grid bag */
204 public TeleGPSConfigUI(JFrame in_owner) {
205 super (in_owner, "Configure Device", false);
208 GridBagConstraints c;
211 Insets il = new Insets(4,4,4,4);
212 Insets ir = new Insets(4,4,4,4);
214 pane = getContentPane();
215 pane.setLayout(new GridBagLayout());
218 c = new GridBagConstraints();
219 c.gridx = 0; c.gridy = row;
221 c.fill = GridBagConstraints.NONE;
222 c.anchor = GridBagConstraints.LINE_START;
224 product_label = new JLabel("Product:");
225 pane.add(product_label, c);
227 c = new GridBagConstraints();
228 c.gridx = 4; c.gridy = row;
230 c.fill = GridBagConstraints.HORIZONTAL;
232 c.anchor = GridBagConstraints.LINE_START;
234 product_value = new JLabel("");
235 pane.add(product_value, c);
239 c = new GridBagConstraints();
240 c.gridx = 0; c.gridy = row;
242 c.fill = GridBagConstraints.NONE;
243 c.anchor = GridBagConstraints.LINE_START;
246 version_label = new JLabel("Software version:");
247 pane.add(version_label, c);
249 c = new GridBagConstraints();
250 c.gridx = 4; c.gridy = row;
252 c.fill = GridBagConstraints.HORIZONTAL;
254 c.anchor = GridBagConstraints.LINE_START;
257 version_value = new JLabel("");
258 pane.add(version_value, c);
262 c = new GridBagConstraints();
263 c.gridx = 0; c.gridy = row;
265 c.fill = GridBagConstraints.NONE;
266 c.anchor = GridBagConstraints.LINE_START;
269 serial_label = new JLabel("Serial:");
270 pane.add(serial_label, c);
272 c = new GridBagConstraints();
273 c.gridx = 4; c.gridy = row;
275 c.fill = GridBagConstraints.HORIZONTAL;
277 c.anchor = GridBagConstraints.LINE_START;
280 serial_value = new JLabel("");
281 pane.add(serial_value, c);
285 c = new GridBagConstraints();
286 c.gridx = 0; c.gridy = row;
288 c.fill = GridBagConstraints.NONE;
289 c.anchor = GridBagConstraints.LINE_START;
292 radio_frequency_label = new JLabel("Frequency:");
293 pane.add(radio_frequency_label, c);
295 c = new GridBagConstraints();
296 c.gridx = 4; c.gridy = row;
298 c.fill = GridBagConstraints.HORIZONTAL;
300 c.anchor = GridBagConstraints.LINE_START;
303 radio_frequency_value = new AltosUIFreqList();
304 radio_frequency_value.addItemListener(this);
305 pane.add(radio_frequency_value, c);
306 radio_frequency_value.setToolTipText("Telemetry, RDF and packet frequency");
309 /* Radio Calibration */
310 c = new GridBagConstraints();
311 c.gridx = 0; c.gridy = row;
313 c.fill = GridBagConstraints.NONE;
314 c.anchor = GridBagConstraints.LINE_START;
317 radio_calibration_label = new JLabel("RF Calibration:");
318 pane.add(radio_calibration_label, c);
320 c = new GridBagConstraints();
321 c.gridx = 4; c.gridy = row;
323 c.fill = GridBagConstraints.HORIZONTAL;
325 c.anchor = GridBagConstraints.LINE_START;
328 radio_calibration_value = new JLabel(String.format("%d", 1186611));
329 pane.add(radio_calibration_value, c);
333 c = new GridBagConstraints();
334 c.gridx = 0; c.gridy = row;
336 c.fill = GridBagConstraints.NONE;
337 c.anchor = GridBagConstraints.LINE_START;
340 radio_enable_label = new JLabel("Telemetry/RDF/APRS Enable:");
341 pane.add(radio_enable_label, c);
343 c = new GridBagConstraints();
344 c.gridx = 4; c.gridy = row;
346 c.fill = GridBagConstraints.HORIZONTAL;
348 c.anchor = GridBagConstraints.LINE_START;
351 radio_enable_value = new JRadioButton("Enabled");
352 radio_enable_value.addItemListener(this);
353 pane.add(radio_enable_value, c);
354 set_radio_enable_tool_tip();
358 c = new GridBagConstraints();
359 c.gridx = 0; c.gridy = row;
361 c.fill = GridBagConstraints.NONE;
362 c.anchor = GridBagConstraints.LINE_START;
365 rate_label = new JLabel("Telemetry baud rate:");
366 pane.add(rate_label, c);
368 c = new GridBagConstraints();
369 c.gridx = 4; c.gridy = row;
371 c.fill = GridBagConstraints.HORIZONTAL;
373 c.anchor = GridBagConstraints.LINE_START;
376 rate_value = new AltosUIRateList();
377 rate_value.addItemListener(this);
378 pane.add(rate_value, c);
383 c = new GridBagConstraints();
384 c.gridx = 0; c.gridy = row;
386 c.fill = GridBagConstraints.NONE;
387 c.anchor = GridBagConstraints.LINE_START;
390 aprs_interval_label = new JLabel("APRS Interval(s):");
391 pane.add(aprs_interval_label, c);
393 c = new GridBagConstraints();
394 c.gridx = 4; c.gridy = row;
396 c.fill = GridBagConstraints.HORIZONTAL;
398 c.anchor = GridBagConstraints.LINE_START;
401 aprs_interval_value = new JComboBox<String>(aprs_interval_values);
402 aprs_interval_value.setEditable(true);
403 aprs_interval_value.addItemListener(this);
404 pane.add(aprs_interval_value, c);
405 set_aprs_interval_tool_tip();
409 c = new GridBagConstraints();
410 c.gridx = 0; c.gridy = row;
412 c.fill = GridBagConstraints.NONE;
413 c.anchor = GridBagConstraints.LINE_START;
416 aprs_ssid_label = new JLabel("APRS SSID:");
417 pane.add(aprs_ssid_label, c);
419 c = new GridBagConstraints();
420 c.gridx = 4; c.gridy = row;
422 c.fill = GridBagConstraints.HORIZONTAL;
424 c.anchor = GridBagConstraints.LINE_START;
427 aprs_ssid_value = new JComboBox<Integer>(aprs_ssid_values);
428 aprs_ssid_value.setEditable(false);
429 aprs_ssid_value.addItemListener(this);
430 aprs_ssid_value.setMaximumRowCount(aprs_ssid_values.length);
431 pane.add(aprs_ssid_value, c);
432 set_aprs_ssid_tool_tip();
436 c = new GridBagConstraints();
437 c.gridx = 0; c.gridy = row;
439 c.fill = GridBagConstraints.NONE;
440 c.anchor = GridBagConstraints.LINE_START;
443 aprs_format_label = new JLabel("APRS format:");
444 pane.add(aprs_format_label, c);
446 c = new GridBagConstraints();
447 c.gridx = 4; c.gridy = row;
449 c.fill = GridBagConstraints.HORIZONTAL;
451 c.anchor = GridBagConstraints.LINE_START;
454 aprs_format_value = new JComboBox<String>(AltosLib.ao_aprs_format_name);
455 aprs_format_value.setEditable(false);
456 aprs_format_value.addItemListener(this);
457 aprs_format_value.setMaximumRowCount(AltosLib.ao_aprs_format_name.length);
458 pane.add(aprs_format_value, c);
459 set_aprs_format_tool_tip();
463 c = new GridBagConstraints();
464 c.gridx = 0; c.gridy = row;
466 c.fill = GridBagConstraints.NONE;
467 c.anchor = GridBagConstraints.LINE_START;
470 aprs_offset_label = new JLabel("APRS offset:");
471 pane.add(aprs_offset_label, c);
473 c = new GridBagConstraints();
474 c.gridx = 4; c.gridy = row;
476 c.fill = GridBagConstraints.HORIZONTAL;
478 c.anchor = GridBagConstraints.LINE_START;
481 aprs_offset_value = new JComboBox<Integer>(aprs_offset_values);
482 aprs_offset_value.setEditable(false);
483 aprs_offset_value.addItemListener(this);
484 aprs_offset_value.setMaximumRowCount(aprs_offset_values.length);
485 pane.add(aprs_offset_value, c);
486 set_aprs_offset_tool_tip();
490 c = new GridBagConstraints();
491 c.gridx = 0; c.gridy = row;
493 c.fill = GridBagConstraints.NONE;
494 c.anchor = GridBagConstraints.LINE_START;
497 callsign_label = new JLabel("Callsign:");
498 pane.add(callsign_label, c);
500 c = new GridBagConstraints();
501 c.gridx = 4; c.gridy = row;
503 c.fill = GridBagConstraints.HORIZONTAL;
505 c.anchor = GridBagConstraints.LINE_START;
508 callsign_value = new JTextField(AltosUIPreferences.callsign());
509 callsign_value.getDocument().addDocumentListener(this);
510 pane.add(callsign_value, c);
511 callsign_value.setToolTipText("Callsign reported in telemetry data");
515 c = new GridBagConstraints();
516 c.gridx = 0; c.gridy = row;
518 c.fill = GridBagConstraints.NONE;
519 c.anchor = GridBagConstraints.LINE_START;
522 flight_log_max_label = new JLabel("Maximum Log Size (kB):");
523 pane.add(flight_log_max_label, c);
525 c = new GridBagConstraints();
526 c.gridx = 4; c.gridy = row;
528 c.fill = GridBagConstraints.HORIZONTAL;
530 c.anchor = GridBagConstraints.LINE_START;
533 flight_log_max_value = new JComboBox<String>();
534 flight_log_max_value.setEditable(true);
535 flight_log_max_value.addItemListener(this);
536 pane.add(flight_log_max_value, c);
537 set_flight_log_max_tool_tip();
540 /* Tracker triger horiz distances */
541 c = new GridBagConstraints();
542 c.gridx = 0; c.gridy = row;
544 c.fill = GridBagConstraints.NONE;
545 c.anchor = GridBagConstraints.LINE_START;
548 tracker_motion_label = new JLabel(get_tracker_motion_label());
549 pane.add(tracker_motion_label, c);
551 c = new GridBagConstraints();
552 c.gridx = 4; c.gridy = row;
554 c.fill = GridBagConstraints.HORIZONTAL;
556 c.anchor = GridBagConstraints.LINE_START;
559 tracker_motion_value = new JComboBox<String>(tracker_motion_values());
560 tracker_motion_value.setEditable(true);
561 tracker_motion_value.addItemListener(this);
562 pane.add(tracker_motion_value, c);
565 /* Tracker triger vert distances */
566 c = new GridBagConstraints();
567 c.gridx = 0; c.gridy = row;
569 c.fill = GridBagConstraints.NONE;
570 c.anchor = GridBagConstraints.LINE_START;
573 tracker_interval_label = new JLabel("Position Reporting Interval (s):");
574 pane.add(tracker_interval_label, c);
576 c = new GridBagConstraints();
577 c.gridx = 4; c.gridy = row;
579 c.fill = GridBagConstraints.HORIZONTAL;
581 c.anchor = GridBagConstraints.LINE_START;
584 tracker_interval_value = new JComboBox<String>(tracker_interval_values);
585 tracker_interval_value.setEditable(true);
586 tracker_interval_value.addItemListener(this);
587 pane.add(tracker_interval_value, c);
588 set_tracker_tool_tip();
592 c = new GridBagConstraints();
593 c.gridx = 0; c.gridy = row;
595 c.fill = GridBagConstraints.NONE;
596 c.anchor = GridBagConstraints.LINE_START;
598 save = new JButton("Save");
600 save.addActionListener(this);
601 save.setActionCommand("Save");
603 c = new GridBagConstraints();
604 c.gridx = 2; c.gridy = row;
606 c.fill = GridBagConstraints.NONE;
607 c.anchor = GridBagConstraints.CENTER;
609 reset = new JButton("Reset");
611 reset.addActionListener(this);
612 reset.setActionCommand("Reset");
614 c = new GridBagConstraints();
615 c.gridx = 4; c.gridy = row;
617 c.fill = GridBagConstraints.NONE;
618 c.anchor = GridBagConstraints.CENTER;
620 reboot = new JButton("Reboot");
622 reboot.addActionListener(this);
623 reboot.setActionCommand("Reboot");
625 c = new GridBagConstraints();
626 c.gridx = 6; c.gridy = row;
628 c.fill = GridBagConstraints.NONE;
629 c.anchor = GridBagConstraints.LINE_END;
631 close = new JButton("Close");
633 close.addActionListener(this);
634 close.setActionCommand("Close");
636 addWindowListener(new ConfigListener(this));
637 AltosPreferences.register_units_listener(this);
640 /* Once the initial values are set, the config code will show the dialog */
641 public void make_visible() {
643 setLocationRelativeTo(owner);
647 /* If any values have been changed, confirm before closing */
648 public boolean check_dirty(String operation) {
650 Object[] options = { String.format("%s anyway", operation), "Keep editing" };
652 i = JOptionPane.showOptionDialog(this,
653 String.format("Configuration modified. %s anyway?", operation),
654 "Configuration Modified",
655 JOptionPane.DEFAULT_OPTION,
656 JOptionPane.WARNING_MESSAGE,
657 null, options, options[1]);
664 public void set_dirty() {
666 save.setEnabled(true);
669 public void set_clean() {
671 save.setEnabled(false);
674 public void dispose() {
675 AltosPreferences.unregister_units_listener(this);
679 public int accel_cal_plus() {
680 return AltosLib.MISSING;
683 public int accel_cal_minus() {
684 return AltosLib.MISSING;
687 public void set_accel_cal(int accel_plus, int accel_minus) {
690 /* Listen for events from our buttons */
691 public void actionPerformed(ActionEvent e) {
692 String cmd = e.getActionCommand();
694 if (cmd.equals("Close") || cmd.equals("Reboot"))
695 if (!check_dirty(cmd))
697 listener.actionPerformed(e);
698 if (cmd.equals("Close") || cmd.equals("Reboot")) {
705 /* ItemListener interface method */
706 public void itemStateChanged(ItemEvent e) {
710 /* DocumentListener interface methods */
711 public void changedUpdate(DocumentEvent e) {
715 public void insertUpdate(DocumentEvent e) {
719 public void removeUpdate(DocumentEvent e) {
723 /* Let the config code hook on a listener */
724 public void addActionListener(ActionListener l) {
728 public void units_changed(boolean imperial_units) {
729 boolean was_dirty = dirty;
731 if (tracker_motion_value.isVisible()) {
732 String motion = tracker_motion_value.getSelectedItem().toString();
733 tracker_motion_label.setText(get_tracker_motion_label());
734 set_tracker_motion_values();
736 int m = (int) (AltosConvert.height.parse_locale(motion, !imperial_units) + 0.5);
737 set_tracker_motion(m);
738 } catch (ParseException pe) {
745 /* set and get all of the dialog values */
746 public void set_product(String product) {
747 radio_frequency_value.set_product(product);
748 product_value.setText(product);
749 set_flight_log_max_tool_tip();
752 public void set_version(String version) {
753 version_value.setText(version);
756 public void set_serial(int serial) {
757 radio_frequency_value.set_serial(serial);
758 serial_value.setText(String.format("%d", serial));
761 public void set_altitude_32(int altitude_32) {
764 public void set_main_deploy(int new_main_deploy) {
767 public int main_deploy() {
768 return AltosLib.MISSING;
771 public void set_apogee_delay(int new_apogee_delay) { }
773 public int apogee_delay() {
774 return AltosLib.MISSING;
777 public void set_apogee_lockout(int new_apogee_lockout) { }
779 public int apogee_lockout() { return AltosLib.MISSING; }
781 public void set_radio_frequency(double new_radio_frequency) {
782 if (new_radio_frequency != AltosLib.MISSING)
783 radio_frequency_value.set_frequency(new_radio_frequency);
784 radio_frequency_label.setVisible(new_radio_frequency != AltosLib.MISSING);
785 radio_frequency_value.setVisible(new_radio_frequency != AltosLib.MISSING);
788 public double radio_frequency() {
789 return radio_frequency_value.frequency();
792 public void set_radio_calibration(int new_radio_calibration) {
793 if (new_radio_calibration != AltosLib.MISSING)
794 radio_calibration_value.setText(String.format("%d", new_radio_calibration));
795 radio_calibration_value.setVisible(new_radio_calibration == AltosLib.MISSING);
796 radio_calibration_label.setVisible(new_radio_calibration == AltosLib.MISSING);
799 public void set_radio_enable(int new_radio_enable) {
800 if (new_radio_enable != AltosLib.MISSING)
801 radio_enable_value.setSelected(new_radio_enable != 0);
802 radio_enable_label.setVisible(new_radio_enable != AltosLib.MISSING);
803 radio_enable_value.setVisible(new_radio_enable != AltosLib.MISSING);
804 set_radio_enable_tool_tip();
807 public int radio_enable() {
808 if (radio_enable_value.isVisible())
809 return radio_enable_value.isSelected() ? 1 : 0;
811 return AltosLib.MISSING;
814 public void set_telemetry_rate(int new_rate) {
815 if (new_rate != AltosLib.MISSING)
816 rate_value.set_rate(new_rate);
817 rate_label.setVisible(new_rate != AltosLib.MISSING);
818 rate_value.setVisible(new_rate != AltosLib.MISSING);
821 public int telemetry_rate() {
822 return rate_value.rate();
825 public void set_callsign(String new_callsign) {
826 if (new_callsign != null)
827 callsign_value.setText(new_callsign);
828 callsign_value.setVisible(new_callsign != null);
829 callsign_label.setVisible(new_callsign != null);
832 public String callsign() {
833 if (callsign_value.isVisible())
834 return callsign_value.getText();
838 private int parse_int(String name, String s, boolean split) throws AltosConfigDataException {
841 v = s.split("\\s+")[0];
843 return Integer.parseInt(v);
844 } catch (NumberFormatException ne) {
845 throw new AltosConfigDataException("Invalid %s \"%s\"", name, s);
849 int flight_log_max_limit;
852 public String flight_log_max_label(int flight_log_max) {
853 if (flight_log_max_limit != 0) {
854 int nflight = flight_log_max_limit / flight_log_max;
855 String plural = nflight > 1 ? "s" : "";
857 return String.format("%d (%d flight%s)", flight_log_max, nflight, plural);
859 return String.format("%d", flight_log_max);
862 public void set_flight_log_max(int new_flight_log_max) {
863 flight_log_max_value.setSelectedItem(flight_log_max_label(new_flight_log_max));
864 flight_log_max = new_flight_log_max;
865 set_flight_log_max_tool_tip();
868 public void set_flight_log_max_enabled(boolean enable) {
869 flight_log_max_value.setEnabled(enable);
870 set_flight_log_max_tool_tip();
873 public int flight_log_max() throws AltosConfigDataException {
874 return parse_int("flight log max", flight_log_max_value.getSelectedItem().toString(), true);
877 public void set_flight_log_max_limit(int new_flight_log_max_limit, int new_storage_erase_unit) {
878 flight_log_max_limit = new_flight_log_max_limit;
879 if (new_flight_log_max_limit != AltosLib.MISSING) {
880 flight_log_max_value.removeAllItems();
881 for (int i = 8; i >= 1; i--) {
882 int size = flight_log_max_limit / i;
883 if (new_storage_erase_unit != 0)
884 size &= ~(new_storage_erase_unit - 1);
885 flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
888 if (flight_log_max != 0 && flight_log_max != AltosLib.MISSING)
889 set_flight_log_max(flight_log_max);
892 public void set_ignite_mode(int new_ignite_mode) { }
893 public int ignite_mode() { return AltosLib.MISSING; }
896 public void set_pad_orientation(int new_pad_orientation) { }
897 public int pad_orientation() { return AltosLib.MISSING; }
899 public void set_beep(int new_beep) { }
901 public int beep() { return AltosLib.MISSING; }
903 String[] tracker_motion_values() {
904 if (AltosConvert.imperial_units)
905 return tracker_motion_values_ft;
907 return tracker_motion_values_m;
910 void set_tracker_motion_values() {
911 String[] v = tracker_motion_values();
912 while (tracker_motion_value.getItemCount() > 0)
913 tracker_motion_value.removeItemAt(0);
914 for (int i = 0; i < v.length; i++)
915 tracker_motion_value.addItem(v[i]);
916 tracker_motion_value.setMaximumRowCount(v.length);
919 String get_tracker_motion_label() {
920 return String.format("Logging Trigger Motion (%s):", AltosConvert.height.parse_units());
923 void set_tracker_tool_tip() {
924 if (tracker_motion_value.isVisible())
925 tracker_motion_value.setToolTipText("How far the device must move before logging");
927 tracker_motion_value.setToolTipText("This device doesn't disable logging when stationary");
928 if (tracker_interval_value.isVisible())
929 tracker_interval_value.setToolTipText("How often to report GPS position");
931 tracker_interval_value.setToolTipText("This device can't configure interval");
934 public void set_tracker_motion(int tracker_motion) {
935 if (tracker_motion != AltosLib.MISSING)
936 tracker_motion_value.setSelectedItem(AltosConvert.height.say(tracker_motion));
937 tracker_motion_label.setVisible(tracker_motion != AltosLib.MISSING);
938 tracker_motion_value.setVisible(tracker_motion != AltosLib.MISSING);
941 public int tracker_motion() throws AltosConfigDataException {
942 if (tracker_motion_value.isVisible()) {
943 String str = tracker_motion_value.getSelectedItem().toString();
945 return (int) (AltosConvert.height.parse_locale(str) + 0.5);
946 } catch (ParseException pe) {
947 throw new AltosConfigDataException("invalid tracker motion %s", str);
950 return AltosLib.MISSING;
953 public void set_tracker_interval(int tracker_interval) {
954 if (tracker_interval != AltosLib.MISSING)
955 tracker_interval_value.setSelectedItem(String.format("%d", tracker_interval));
956 tracker_interval_label.setVisible(tracker_interval != AltosLib.MISSING);
957 tracker_interval_value.setVisible(tracker_interval != AltosLib.MISSING);
960 public int tracker_interval() throws AltosConfigDataException {
961 if (tracker_interval_value.isVisible())
962 return parse_int ("tracker interval", tracker_interval_value.getSelectedItem().toString(), false);
963 return AltosLib.MISSING;
966 public void set_aprs_interval(int new_aprs_interval) {
967 if (new_aprs_interval != AltosLib.MISSING)
968 aprs_interval_value.setSelectedItem(Integer.toString(new_aprs_interval));
969 aprs_interval_value.setVisible(new_aprs_interval != AltosLib.MISSING);
970 aprs_interval_label.setVisible(new_aprs_interval != AltosLib.MISSING);
971 set_aprs_interval_tool_tip();
974 public int aprs_interval() throws AltosConfigDataException {
975 if (aprs_interval_value.isVisible()) {
976 String s = aprs_interval_value.getSelectedItem().toString();
978 return parse_int("aprs interval", s, false);
980 return AltosLib.MISSING;
983 public void set_aprs_ssid(int new_aprs_ssid) {
984 if (new_aprs_ssid != AltosLib.MISSING)
985 aprs_ssid_value.setSelectedItem(new_aprs_ssid);
986 aprs_ssid_value.setVisible(new_aprs_ssid != AltosLib.MISSING);
987 aprs_ssid_label.setVisible(new_aprs_ssid != AltosLib.MISSING);
988 set_aprs_ssid_tool_tip();
991 public int aprs_ssid() throws AltosConfigDataException {
992 if (aprs_ssid_value.isVisible()) {
993 Integer i = (Integer) aprs_ssid_value.getSelectedItem();
996 return AltosLib.MISSING;
999 public void set_aprs_format(int new_aprs_format) {
1000 if (new_aprs_format != AltosLib.MISSING)
1001 aprs_format_value.setSelectedIndex(new_aprs_format);
1002 aprs_format_value.setVisible(new_aprs_format != AltosLib.MISSING);
1003 aprs_format_label.setVisible(new_aprs_format != AltosLib.MISSING);
1004 set_aprs_format_tool_tip();
1007 public int aprs_format() throws AltosConfigDataException {
1008 if (aprs_format_value.isVisible())
1009 return aprs_format_value.getSelectedIndex();
1010 return AltosLib.MISSING;
1012 public void set_aprs_offset(int new_aprs_offset) {
1013 if (new_aprs_offset != AltosLib.MISSING)
1014 aprs_offset_value.setSelectedItem(new_aprs_offset);
1015 aprs_offset_value.setVisible(new_aprs_offset != AltosLib.MISSING);
1016 aprs_offset_label.setVisible(new_aprs_offset != AltosLib.MISSING);
1017 set_aprs_offset_tool_tip();
1020 public int aprs_offset() throws AltosConfigDataException {
1021 if (aprs_offset_value.isVisible()) {
1022 Integer i = (Integer) aprs_offset_value.getSelectedItem();
1025 return AltosLib.MISSING;