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.
22 import java.awt.event.*;
24 import javax.swing.event.*;
26 import org.altusmetrum.altoslib_14.*;
27 import org.altusmetrum.altosuilib_14.*;
29 public class AltosConfigFCUI
31 implements ActionListener, ItemListener, DocumentListener, AltosConfigValues, AltosUnitsListener
38 JLabel main_deploy_label;
39 JLabel apogee_delay_label;
40 JLabel apogee_lockout_label;
41 JLabel frequency_label;
42 JLabel radio_calibration_label;
43 JLabel radio_frequency_label;
44 JLabel radio_enable_label;
45 JLabel radio_10mw_label;
46 JLabel report_feet_label;
47 JLabel gps_receiver_label;
49 JLabel aprs_interval_label;
50 JLabel aprs_ssid_label;
51 JLabel aprs_format_label;
52 JLabel aprs_offset_label;
53 JLabel flight_log_max_label;
54 JLabel ignite_mode_label;
55 JLabel pad_orientation_label;
56 JLabel accel_plus_label;
57 JLabel accel_minus_label;
58 JLabel callsign_label;
60 JLabel tracker_motion_label;
61 JLabel tracker_interval_label;
69 JComboBox<String> main_deploy_value;
70 JComboBox<String> apogee_delay_value;
71 JComboBox<String> apogee_lockout_value;
72 AltosUIFreqList radio_frequency_value;
73 JLabel radio_calibration_value;
74 JRadioButton radio_enable_value;
75 JRadioButton radio_10mw_value;
76 JComboBox<String> report_feet_value;
77 JComboBox<String> gps_receiver_value;
78 AltosUIRateList rate_value;
79 JComboBox<String> aprs_interval_value;
80 JComboBox<Integer> aprs_ssid_value;
81 JComboBox<String> aprs_format_value;
82 JComboBox<Integer> aprs_offset_value;
83 JComboBox<String> flight_log_max_value;
84 JComboBox<String> ignite_mode_value;
85 JComboBox<String> pad_orientation_value;
86 JTextField accel_plus_value;
87 JTextField accel_minus_value;
88 JTextField callsign_value;
89 JComboBox<String> beep_value;
90 JComboBox<String> tracker_motion_value;
91 JComboBox<String> tracker_interval_value;
102 double pyro_firing_time;
104 ActionListener listener;
106 static final String title = "Configure Flight Computer";
108 static String[] main_deploy_values_m = {
109 "100", "150", "200", "250", "300", "350",
113 static String[] main_deploy_values_ft = {
114 "250", "500", "750", "1000", "1250", "1500",
118 static String[] apogee_delay_values = {
119 "0", "1", "2", "3", "4", "5"
122 static String[] apogee_lockout_values = {
123 "0", "5", "10", "15", "20"
126 static String[] aprs_interval_values = {
133 static Integer[] aprs_ssid_values = {
134 0, 1, 2 ,3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
137 static Integer[] aprs_offset_values = {
138 0, 2, 4, 6, 8, 10, 12, 14, 16, 18
141 static String[] beep_values = {
150 String[] pad_orientation_values;
152 static String[] tracker_motion_values_m = {
159 static String[] tracker_motion_values_ft = {
166 static String[] tracker_interval_values = {
173 static String[] report_feet_values = {
178 /* A window listener to catch closing events and tell the config code */
179 class ConfigListener extends WindowAdapter {
182 public ConfigListener(AltosConfigFCUI this_ui) {
186 public void windowClosing(WindowEvent e) {
187 ui.actionPerformed(new ActionEvent(e.getSource(),
188 ActionEvent.ACTION_PERFORMED,
193 boolean is_telemini_v1() {
194 String product = product_value.getText();
195 return product != null && product.startsWith("TeleMini-v1");
198 boolean is_telemini() {
199 String product = product_value.getText();
200 return product != null && product.startsWith("TeleMini");
203 boolean is_easymini() {
204 String product = product_value.getText();
205 return product != null && product.startsWith("EasyMini");
208 boolean is_telemetrum() {
209 String product = product_value.getText();
210 return product != null && product.startsWith("TeleMetrum");
213 boolean is_telemega() {
214 String product = product_value.getText();
215 return product != null && product.startsWith("TeleMega");
218 boolean is_easymega() {
219 String product = product_value.getText();
220 return product != null && product.startsWith("EasyMega");
223 boolean is_easytimer() {
224 String product = product_value.getText();
225 return product != null && product.startsWith("EasyTimer");
228 public boolean has_radio() {
229 return is_telemega() || is_telemetrum() || is_telemini();
232 void set_radio_enable_tool_tip() {
233 if (radio_enable_value.isVisible())
234 radio_enable_value.setToolTipText("Enable/Disable telemetry and RDF transmissions");
236 radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
239 void set_rate_tool_tip() {
240 if (rate_value.isVisible())
241 rate_value.setToolTipText("Select telemetry baud rate");
243 rate_value.setToolTipText("Firmware version does not support variable telemetry rates");
246 void set_aprs_interval_tool_tip() {
247 if (aprs_interval_value.isVisible())
248 aprs_interval_value.setToolTipText("Enable APRS and set the interval between APRS reports");
250 aprs_interval_value.setToolTipText("Hardware doesn't support APRS");
253 void set_aprs_ssid_tool_tip() {
254 if (aprs_ssid_value.isVisible())
255 aprs_ssid_value.setToolTipText("Set the APRS SSID (secondary station identifier)");
256 else if (aprs_ssid_value.isVisible())
257 aprs_ssid_value.setToolTipText("Software version doesn't support setting the APRS SSID");
259 aprs_ssid_value.setToolTipText("Hardware doesn't support APRS");
262 void set_aprs_format_tool_tip() {
263 if (aprs_format_value.isVisible())
264 aprs_format_value.setToolTipText("Set the APRS format (compressed/uncompressed)");
265 else if (aprs_format_value.isVisible())
266 aprs_format_value.setToolTipText("Software version doesn't support setting the APRS format");
268 aprs_format_value.setToolTipText("Hardware doesn't support APRS");
271 void set_aprs_offset_tool_tip() {
272 if (aprs_offset_value.isVisible())
273 aprs_offset_value.setToolTipText("Set the APRS offset from top of minute");
274 else if (aprs_offset_value.isVisible())
275 aprs_offset_value.setToolTipText("Software version doesn't support setting the APRS offset");
277 aprs_offset_value.setToolTipText("Hardware doesn't support APRS");
280 void set_flight_log_max_tool_tip() {
281 if (flight_log_max_value.isVisible())
282 flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)");
284 if (is_telemini_v1())
285 flight_log_max_value.setToolTipText("TeleMini-v1 stores only one flight");
287 flight_log_max_value.setToolTipText("Cannot set max value with flight logs in memory");
291 void set_ignite_mode_tool_tip() {
292 if (ignite_mode_value.isVisible())
293 ignite_mode_value.setToolTipText("Select when igniters will be fired");
295 ignite_mode_value.setToolTipText("Older firmware could not select ignite mode");
298 void set_pad_orientation_tool_tip() {
299 if (pad_orientation_value.isVisible()) {
300 pad_orientation_value.setToolTipText("How will the computer be mounted in the airframe");
303 pad_orientation_value.setToolTipText("Older TeleMetrum firmware must fly antenna forward");
304 else if (is_telemini() || is_easymini())
305 pad_orientation_value.setToolTipText("TeleMini and EasyMini don't care how they are mounted");
306 else if (is_easytimer())
307 pad_orientation_value.setToolTipText("EasyTimer can be mounted in any of six orientations");
309 pad_orientation_value.setToolTipText("Can't select orientation");
313 void set_pad_orientation_values() {
314 String [] new_values = AltosLib.pad_orientation_values(has_radio());
315 if (new_values != pad_orientation_values) {
316 int id = pad_orientation_value.getSelectedIndex();
317 pad_orientation_value.removeAllItems();
318 pad_orientation_values = new_values;
319 for (int i = 0; i < new_values.length; i++)
320 pad_orientation_value.addItem(pad_orientation_values[i]);
321 pad_orientation_value.setSelectedIndex(id);
325 void set_accel_tool_tips() {
326 if (accel_plus_value.isVisible()) {
327 accel_plus_value.setToolTipText("Pad acceleration value in flight orientation");
328 accel_minus_value.setToolTipText("Upside-down acceleration value");
330 accel_plus_value.setToolTipText("No accelerometer");
331 accel_minus_value.setToolTipText("No accelerometer");
335 void set_beep_tool_tip() {
336 if (beep_value.isVisible())
337 beep_value.setToolTipText("What frequency the beeper will sound at (0 for off)");
339 beep_value.setToolTipText("Older firmware could not select beeper frequency");
342 void set_radio_10mw_tool_tip() {
343 if (radio_10mw_value.isVisible())
344 radio_10mw_value.setToolTipText("Should transmitter power be limited to 10mW");
346 radio_10mw_value.setToolTipText("Older firmware could not limit radio power");
349 void set_report_feet_tool_tip() {
350 if (report_feet_value.isVisible())
351 report_feet_value.setToolTipText("Units used after landing to beep max height");
353 report_feet_value.setToolTipText("Older firmware always beeps max height in meters");
356 void set_gps_receiver_tool_tip() {
357 if (gps_receiver_value.isVisible())
358 gps_receiver_value.setToolTipText("GPS receiver selection");
360 gps_receiver_value.setToolTipText("Only TeleMega with new firmware supports alternate GPS receivers");
363 /* Build the UI using a grid bag */
364 public AltosConfigFCUI(JFrame in_owner, boolean remote) {
365 super (in_owner, title, false);
368 GridBagConstraints c;
371 Insets il = new Insets(4,4,4,4);
372 Insets ir = new Insets(4,4,4,4);
374 pane = getScrollablePane();
376 pane.setLayout(new GridBagLayout());
379 c = new GridBagConstraints();
380 c.gridx = 0; c.gridy = row;
382 c.fill = GridBagConstraints.NONE;
383 c.anchor = GridBagConstraints.LINE_START;
385 product_label = new JLabel("Product:");
386 pane.add(product_label, c);
388 c = new GridBagConstraints();
389 c.gridx = 4; c.gridy = row;
391 c.fill = GridBagConstraints.HORIZONTAL;
393 c.anchor = GridBagConstraints.LINE_START;
395 product_value = new JLabel("");
396 pane.add(product_value, c);
400 c = new GridBagConstraints();
401 c.gridx = 0; c.gridy = row;
403 c.fill = GridBagConstraints.NONE;
404 c.anchor = GridBagConstraints.LINE_START;
407 version_label = new JLabel("Software version:");
408 pane.add(version_label, c);
410 c = new GridBagConstraints();
411 c.gridx = 4; c.gridy = row;
413 c.fill = GridBagConstraints.HORIZONTAL;
415 c.anchor = GridBagConstraints.LINE_START;
418 version_value = new JLabel("");
419 pane.add(version_value, c);
423 c = new GridBagConstraints();
424 c.gridx = 0; c.gridy = row;
426 c.fill = GridBagConstraints.NONE;
427 c.anchor = GridBagConstraints.LINE_START;
430 serial_label = new JLabel("Serial:");
431 pane.add(serial_label, c);
433 c = new GridBagConstraints();
434 c.gridx = 4; c.gridy = row;
436 c.fill = GridBagConstraints.HORIZONTAL;
438 c.anchor = GridBagConstraints.LINE_START;
441 serial_value = new JLabel("");
442 pane.add(serial_value, c);
446 c = new GridBagConstraints();
447 c.gridx = 0; c.gridy = row;
449 c.fill = GridBagConstraints.NONE;
450 c.anchor = GridBagConstraints.LINE_START;
453 main_deploy_label = new JLabel(get_main_deploy_label());
454 pane.add(main_deploy_label, c);
456 c = new GridBagConstraints();
457 c.gridx = 4; c.gridy = row;
459 c.fill = GridBagConstraints.HORIZONTAL;
461 c.anchor = GridBagConstraints.LINE_START;
464 main_deploy_value = new JComboBox<String>(main_deploy_values());
465 main_deploy_value.setEditable(true);
466 main_deploy_value.addItemListener(this);
467 pane.add(main_deploy_value, c);
468 main_deploy_value.setToolTipText("Height above pad altitude to fire main charge");
472 c = new GridBagConstraints();
473 c.gridx = 0; c.gridy = row;
475 c.fill = GridBagConstraints.NONE;
476 c.anchor = GridBagConstraints.LINE_START;
479 apogee_delay_label = new JLabel("Apogee Delay(s):");
480 pane.add(apogee_delay_label, c);
482 c = new GridBagConstraints();
483 c.gridx = 4; c.gridy = row;
485 c.fill = GridBagConstraints.HORIZONTAL;
487 c.anchor = GridBagConstraints.LINE_START;
490 apogee_delay_value = new JComboBox<String>(apogee_delay_values);
491 apogee_delay_value.setEditable(true);
492 apogee_delay_value.addItemListener(this);
493 pane.add(apogee_delay_value, c);
494 apogee_delay_value.setToolTipText("Delay after apogee before charge fires");
498 c = new GridBagConstraints();
499 c.gridx = 0; c.gridy = row;
501 c.fill = GridBagConstraints.NONE;
502 c.anchor = GridBagConstraints.LINE_START;
505 apogee_lockout_label = new JLabel("Apogee Lockout(s):");
506 pane.add(apogee_lockout_label, c);
508 c = new GridBagConstraints();
509 c.gridx = 4; c.gridy = row;
511 c.fill = GridBagConstraints.HORIZONTAL;
513 c.anchor = GridBagConstraints.LINE_START;
516 apogee_lockout_value = new JComboBox<String>(apogee_lockout_values);
517 apogee_lockout_value.setEditable(true);
518 apogee_lockout_value.addItemListener(this);
519 pane.add(apogee_lockout_value, c);
520 apogee_lockout_value.setToolTipText("Time after launch while apogee detection is locked out");
524 c = new GridBagConstraints();
525 c.gridx = 0; c.gridy = row;
527 c.fill = GridBagConstraints.NONE;
528 c.anchor = GridBagConstraints.LINE_START;
531 radio_frequency_label = new JLabel("Frequency:");
532 pane.add(radio_frequency_label, c);
534 c = new GridBagConstraints();
535 c.gridx = 4; c.gridy = row;
537 c.fill = GridBagConstraints.HORIZONTAL;
539 c.anchor = GridBagConstraints.LINE_START;
542 radio_frequency_value = new AltosUIFreqList();
543 radio_frequency_value.addItemListener(this);
544 pane.add(radio_frequency_value, c);
545 radio_frequency_value.setToolTipText("Telemetry, RDF and packet frequency");
548 /* Radio Calibration */
549 c = new GridBagConstraints();
550 c.gridx = 0; c.gridy = row;
552 c.fill = GridBagConstraints.NONE;
553 c.anchor = GridBagConstraints.LINE_START;
556 radio_calibration_label = new JLabel("RF Calibration:");
557 pane.add(radio_calibration_label, c);
559 c = new GridBagConstraints();
560 c.gridx = 4; c.gridy = row;
562 c.fill = GridBagConstraints.HORIZONTAL;
564 c.anchor = GridBagConstraints.LINE_START;
567 radio_calibration_value = new JLabel(String.format("%d", 1186611));
568 pane.add(radio_calibration_value, c);
572 c = new GridBagConstraints();
573 c.gridx = 0; c.gridy = row;
575 c.fill = GridBagConstraints.NONE;
576 c.anchor = GridBagConstraints.LINE_START;
579 radio_enable_label = new JLabel("Telemetry/RDF/APRS Enable:");
580 pane.add(radio_enable_label, c);
582 c = new GridBagConstraints();
583 c.gridx = 4; c.gridy = row;
585 c.fill = GridBagConstraints.HORIZONTAL;
587 c.anchor = GridBagConstraints.LINE_START;
590 radio_enable_value = new JRadioButton("Enabled");
591 radio_enable_value.addItemListener(this);
592 pane.add(radio_enable_value, c);
593 set_radio_enable_tool_tip();
596 /* Radio 10mW limit */
597 c = new GridBagConstraints();
598 c.gridx = 0; c.gridy = row;
600 c.fill = GridBagConstraints.NONE;
601 c.anchor = GridBagConstraints.LINE_START;
604 radio_10mw_label = new JLabel("Limit transmit to 10mW:");
605 pane.add(radio_10mw_label, c);
607 c = new GridBagConstraints();
608 c.gridx = 4; c.gridy = row;
610 c.fill = GridBagConstraints.HORIZONTAL;
612 c.anchor = GridBagConstraints.LINE_START;
615 radio_10mw_value = new JRadioButton("Limited");
616 radio_10mw_value.addItemListener(this);
617 pane.add(radio_10mw_value, c);
618 set_radio_10mw_tool_tip();
622 c = new GridBagConstraints();
623 c.gridx = 0; c.gridy = row;
625 c.fill = GridBagConstraints.NONE;
626 c.anchor = GridBagConstraints.LINE_START;
629 report_feet_label = new JLabel("Beep max height in:");
630 pane.add(report_feet_label, c);
632 c = new GridBagConstraints();
633 c.gridx = 4; c.gridy = row;
635 c.fill = GridBagConstraints.HORIZONTAL;
637 c.anchor = GridBagConstraints.LINE_START;
640 report_feet_value = new JComboBox<String>(report_feet_values);
641 report_feet_value.setEditable(false);
642 report_feet_value.addItemListener(this);
643 pane.add(report_feet_value, c);
644 set_report_feet_tool_tip();
648 c = new GridBagConstraints();
649 c.gridx = 0; c.gridy = row;
651 c.fill = GridBagConstraints.NONE;
652 c.anchor = GridBagConstraints.LINE_START;
655 gps_receiver_label = new JLabel("GPS Receiver:");
656 pane.add(gps_receiver_label, c);
658 c = new GridBagConstraints();
659 c.gridx = 4; c.gridy = row;
661 c.fill = GridBagConstraints.HORIZONTAL;
663 c.anchor = GridBagConstraints.LINE_START;
666 gps_receiver_value = new JComboBox<String>(AltosLib.gps_receiver_names);
667 gps_receiver_value.setEditable(false);
668 gps_receiver_value.addItemListener(this);
669 pane.add(gps_receiver_value, c);
670 set_gps_receiver_tool_tip();
674 c = new GridBagConstraints();
675 c.gridx = 0; c.gridy = row;
677 c.fill = GridBagConstraints.NONE;
678 c.anchor = GridBagConstraints.LINE_START;
681 rate_label = new JLabel("Telemetry baud rate:");
682 pane.add(rate_label, c);
684 c = new GridBagConstraints();
685 c.gridx = 4; c.gridy = row;
687 c.fill = GridBagConstraints.HORIZONTAL;
689 c.anchor = GridBagConstraints.LINE_START;
692 rate_value = new AltosUIRateList();
693 rate_value.addItemListener(this);
694 pane.add(rate_value, c);
699 c = new GridBagConstraints();
700 c.gridx = 0; c.gridy = row;
702 c.fill = GridBagConstraints.NONE;
703 c.anchor = GridBagConstraints.LINE_START;
706 aprs_interval_label = new JLabel("APRS Interval(s):");
707 pane.add(aprs_interval_label, c);
709 c = new GridBagConstraints();
710 c.gridx = 4; c.gridy = row;
712 c.fill = GridBagConstraints.HORIZONTAL;
714 c.anchor = GridBagConstraints.LINE_START;
717 aprs_interval_value = new JComboBox<String>(aprs_interval_values);
718 aprs_interval_value.setEditable(true);
719 aprs_interval_value.addItemListener(this);
720 pane.add(aprs_interval_value, c);
721 set_aprs_interval_tool_tip();
725 c = new GridBagConstraints();
726 c.gridx = 0; c.gridy = row;
728 c.fill = GridBagConstraints.NONE;
729 c.anchor = GridBagConstraints.LINE_START;
732 aprs_ssid_label = new JLabel("APRS SSID:");
733 pane.add(aprs_ssid_label, c);
735 c = new GridBagConstraints();
736 c.gridx = 4; c.gridy = row;
738 c.fill = GridBagConstraints.HORIZONTAL;
740 c.anchor = GridBagConstraints.LINE_START;
743 aprs_ssid_value = new JComboBox<Integer>(aprs_ssid_values);
744 aprs_ssid_value.setEditable(false);
745 aprs_ssid_value.addItemListener(this);
746 aprs_ssid_value.setMaximumRowCount(aprs_ssid_values.length);
747 pane.add(aprs_ssid_value, c);
748 set_aprs_ssid_tool_tip();
752 c = new GridBagConstraints();
753 c.gridx = 0; c.gridy = row;
755 c.fill = GridBagConstraints.NONE;
756 c.anchor = GridBagConstraints.LINE_START;
759 aprs_format_label = new JLabel("APRS format:");
760 pane.add(aprs_format_label, c);
762 c = new GridBagConstraints();
763 c.gridx = 4; c.gridy = row;
765 c.fill = GridBagConstraints.HORIZONTAL;
767 c.anchor = GridBagConstraints.LINE_START;
770 aprs_format_value = new JComboBox<String>(AltosLib.ao_aprs_format_name);
771 aprs_format_value.setEditable(false);
772 aprs_format_value.addItemListener(this);
773 aprs_format_value.setMaximumRowCount(AltosLib.ao_aprs_format_name.length);
774 pane.add(aprs_format_value, c);
775 set_aprs_format_tool_tip();
779 c = new GridBagConstraints();
780 c.gridx = 0; c.gridy = row;
782 c.fill = GridBagConstraints.NONE;
783 c.anchor = GridBagConstraints.LINE_START;
786 aprs_offset_label = new JLabel("APRS offset:");
787 pane.add(aprs_offset_label, c);
789 c = new GridBagConstraints();
790 c.gridx = 4; c.gridy = row;
792 c.fill = GridBagConstraints.HORIZONTAL;
794 c.anchor = GridBagConstraints.LINE_START;
797 aprs_offset_value = new JComboBox<Integer>(aprs_offset_values);
798 aprs_offset_value.setEditable(false);
799 aprs_offset_value.addItemListener(this);
800 aprs_offset_value.setMaximumRowCount(aprs_offset_values.length);
801 pane.add(aprs_offset_value, c);
802 set_aprs_offset_tool_tip();
806 c = new GridBagConstraints();
807 c.gridx = 0; c.gridy = row;
809 c.fill = GridBagConstraints.NONE;
810 c.anchor = GridBagConstraints.LINE_START;
813 callsign_label = new JLabel("Callsign:");
814 pane.add(callsign_label, c);
816 c = new GridBagConstraints();
817 c.gridx = 4; c.gridy = row;
819 c.fill = GridBagConstraints.HORIZONTAL;
821 c.anchor = GridBagConstraints.LINE_START;
824 callsign_value = new JTextField(AltosUIPreferences.callsign());
825 callsign_value.getDocument().addDocumentListener(this);
826 pane.add(callsign_value, c);
827 callsign_value.setToolTipText("Callsign reported in telemetry data");
831 c = new GridBagConstraints();
832 c.gridx = 0; c.gridy = row;
834 c.fill = GridBagConstraints.NONE;
835 c.anchor = GridBagConstraints.LINE_START;
838 flight_log_max_label = new JLabel("Maximum Flight Log Size (kB):");
839 pane.add(flight_log_max_label, c);
841 c = new GridBagConstraints();
842 c.gridx = 4; c.gridy = row;
844 c.fill = GridBagConstraints.HORIZONTAL;
846 c.anchor = GridBagConstraints.LINE_START;
849 flight_log_max_value = new JComboBox<String>();
850 flight_log_max_value.setEditable(true);
851 flight_log_max_value.addItemListener(this);
852 pane.add(flight_log_max_value, c);
853 set_flight_log_max_tool_tip();
857 c = new GridBagConstraints();
858 c.gridx = 0; c.gridy = row;
860 c.fill = GridBagConstraints.NONE;
861 c.anchor = GridBagConstraints.LINE_START;
864 ignite_mode_label = new JLabel("Igniter Firing Mode:");
865 pane.add(ignite_mode_label, c);
867 c = new GridBagConstraints();
868 c.gridx = 4; c.gridy = row;
870 c.fill = GridBagConstraints.HORIZONTAL;
872 c.anchor = GridBagConstraints.LINE_START;
875 ignite_mode_value = new JComboBox<String>(AltosLib.ignite_mode_values);
876 ignite_mode_value.setEditable(false);
877 ignite_mode_value.addItemListener(this);
878 pane.add(ignite_mode_value, c);
879 set_ignite_mode_tool_tip();
882 /* Pad orientation */
883 c = new GridBagConstraints();
884 c.gridx = 0; c.gridy = row;
886 c.fill = GridBagConstraints.NONE;
887 c.anchor = GridBagConstraints.LINE_START;
890 pad_orientation_label = new JLabel("Pad Orientation:");
891 pane.add(pad_orientation_label, c);
893 c = new GridBagConstraints();
894 c.gridx = 4; c.gridy = row;
896 c.fill = GridBagConstraints.HORIZONTAL;
898 c.anchor = GridBagConstraints.LINE_START;
901 pad_orientation_values = AltosLib.pad_orientation_values(false);
903 pad_orientation_value = new JComboBox<String>(pad_orientation_values);
904 pad_orientation_value.setEditable(false);
905 pad_orientation_value.addItemListener(this);
906 pane.add(pad_orientation_value, c);
907 set_pad_orientation_tool_tip();
911 c = new GridBagConstraints();
912 c.gridx = 0; c.gridy = row;
914 c.fill = GridBagConstraints.NONE;
915 c.anchor = GridBagConstraints.LINE_START;
918 accel_plus_label = new JLabel("Accel Plus:");
919 pane.add(accel_plus_label, c);
921 c = new GridBagConstraints();
922 c.gridx = 4; c.gridy = row;
924 c.fill = GridBagConstraints.HORIZONTAL;
926 c.anchor = GridBagConstraints.LINE_START;
929 accel_plus_value = new JTextField(10);
930 accel_plus_value.setEditable(true);
931 accel_plus_value.getDocument().addDocumentListener(this);
932 pane.add(accel_plus_value, c);
936 c = new GridBagConstraints();
937 c.gridx = 0; c.gridy = row;
939 c.fill = GridBagConstraints.NONE;
940 c.anchor = GridBagConstraints.LINE_START;
943 accel_minus_label = new JLabel("Accel Minus:");
944 pane.add(accel_minus_label, c);
946 c = new GridBagConstraints();
947 c.gridx = 4; c.gridy = row;
949 c.fill = GridBagConstraints.HORIZONTAL;
951 c.anchor = GridBagConstraints.LINE_START;
954 accel_minus_value = new JTextField(10);
955 accel_minus_value.setEditable(true);
956 accel_minus_value.getDocument().addDocumentListener(this);
957 pane.add(accel_minus_value, c);
959 set_accel_tool_tips();
962 c = new GridBagConstraints();
963 c.gridx = 0; c.gridy = row;
965 c.fill = GridBagConstraints.NONE;
966 c.anchor = GridBagConstraints.LINE_START;
969 beep_label = new JLabel("Beeper Frequency:");
970 pane.add(beep_label, c);
972 c = new GridBagConstraints();
973 c.gridx = 4; c.gridy = row;
975 c.fill = GridBagConstraints.HORIZONTAL;
977 c.anchor = GridBagConstraints.LINE_START;
980 beep_value = new JComboBox<String>(beep_values);
981 beep_value.setEditable(true);
982 beep_value.addItemListener(this);
983 pane.add(beep_value, c);
987 /* Tracker triger horiz distances */
988 c = new GridBagConstraints();
989 c.gridx = 0; c.gridy = row;
991 c.fill = GridBagConstraints.NONE;
992 c.anchor = GridBagConstraints.LINE_START;
995 tracker_motion_label = new JLabel(get_tracker_motion_label());
996 pane.add(tracker_motion_label, c);
998 c = new GridBagConstraints();
999 c.gridx = 4; c.gridy = row;
1001 c.fill = GridBagConstraints.HORIZONTAL;
1003 c.anchor = GridBagConstraints.LINE_START;
1006 tracker_motion_value = new JComboBox<String>(tracker_motion_values());
1007 tracker_motion_value.setEditable(true);
1008 tracker_motion_value.addItemListener(this);
1009 pane.add(tracker_motion_value, c);
1012 /* Tracker triger vert distances */
1013 c = new GridBagConstraints();
1014 c.gridx = 0; c.gridy = row;
1016 c.fill = GridBagConstraints.NONE;
1017 c.anchor = GridBagConstraints.LINE_START;
1020 tracker_interval_label = new JLabel("Position Reporting Interval(s):");
1021 pane.add(tracker_interval_label, c);
1023 c = new GridBagConstraints();
1024 c.gridx = 4; c.gridy = row;
1026 c.fill = GridBagConstraints.HORIZONTAL;
1028 c.anchor = GridBagConstraints.LINE_START;
1031 tracker_interval_value = new JComboBox<String>(tracker_interval_values);
1032 tracker_interval_value.setEditable(true);
1033 tracker_interval_value.addItemListener(this);
1034 pane.add(tracker_interval_value, c);
1035 set_tracker_tool_tip();
1039 c = new GridBagConstraints();
1040 c.gridx = 4; c.gridy = row;
1042 c.fill = GridBagConstraints.HORIZONTAL;
1043 c.anchor = GridBagConstraints.LINE_START;
1046 pyro = new JButton("Configure Pyro Channels");
1048 pyro.addActionListener(this);
1049 pyro.setActionCommand("Pyro");
1053 c = new GridBagConstraints();
1054 c.gridx = 5; c.gridy = row;
1056 c.fill = GridBagConstraints.HORIZONTAL;
1057 c.anchor = GridBagConstraints.LINE_START;
1060 accel_cal = new JButton("Calibrate Accelerometer");
1061 pane.add(accel_cal, c);
1062 accel_cal.addActionListener(this);
1063 accel_cal.setActionCommand("Accel");
1067 c = new GridBagConstraints();
1068 c.gridx = 0; c.gridy = row;
1070 c.fill = GridBagConstraints.NONE;
1071 c.anchor = GridBagConstraints.LINE_START;
1073 save = new JButton("Save");
1075 save.addActionListener(this);
1076 save.setActionCommand("Save");
1078 c = new GridBagConstraints();
1079 c.gridx = 2; c.gridy = row;
1081 c.fill = GridBagConstraints.NONE;
1082 c.anchor = GridBagConstraints.CENTER;
1084 reset = new JButton("Reset");
1086 reset.addActionListener(this);
1087 reset.setActionCommand("Reset");
1089 c = new GridBagConstraints();
1090 c.gridx = 4; c.gridy = row;
1092 c.fill = GridBagConstraints.NONE;
1093 c.anchor = GridBagConstraints.CENTER;
1095 reboot = new JButton("Reboot");
1096 pane.add(reboot, c);
1097 reboot.addActionListener(this);
1098 reboot.setActionCommand("Reboot");
1100 c = new GridBagConstraints();
1101 c.gridx = 6; c.gridy = row;
1103 c.fill = GridBagConstraints.NONE;
1104 c.anchor = GridBagConstraints.LINE_END;
1106 close = new JButton("Close");
1108 close.addActionListener(this);
1109 close.setActionCommand("Close");
1111 addWindowListener(new ConfigListener(this));
1112 AltosPreferences.register_units_listener(this);
1115 /* Once the initial values are set, the config code will show the dialog */
1116 public void make_visible() {
1118 setLocationRelativeTo(owner);
1122 /* If any values have been changed, confirm before closing */
1123 public boolean check_dirty(String operation) {
1125 Object[] options = { String.format("%s anyway", operation), "Keep editing" };
1127 i = JOptionPane.showOptionDialog(this,
1128 String.format("Configuration modified. %s anyway?", operation),
1129 "Configuration Modified",
1130 JOptionPane.DEFAULT_OPTION,
1131 JOptionPane.WARNING_MESSAGE,
1132 null, options, options[1]);
1139 public void set_dirty() {
1141 setTitle(title + " (modified)");
1142 save.setEnabled(true);
1145 public void set_clean() {
1148 save.setEnabled(false);
1151 AltosConfigPyroUI pyro_ui;
1153 public void dispose() {
1154 if (pyro_ui != null)
1156 AltosPreferences.unregister_units_listener(this);
1160 /* Listen for events from our buttons */
1161 public void actionPerformed(ActionEvent e) {
1162 String cmd = e.getActionCommand();
1164 if (cmd.equals("Pyro")) {
1165 if (pyro_ui == null && pyros != null)
1166 pyro_ui = new AltosConfigPyroUI(this, pyros, pyro_firing_time);
1167 if (pyro_ui != null)
1168 pyro_ui.make_visible();
1172 if (cmd.equals("Close") || cmd.equals("Reboot"))
1173 if (!check_dirty(cmd))
1175 if (cmd.equals("Save"))
1176 save.setEnabled(false);
1177 listener.actionPerformed(e);
1178 if (cmd.equals("Close") || cmd.equals("Reboot")) {
1184 /* ItemListener interface method */
1185 public void itemStateChanged(ItemEvent e) {
1189 /* DocumentListener interface methods */
1190 public void changedUpdate(DocumentEvent e) {
1194 public void insertUpdate(DocumentEvent e) {
1198 public void removeUpdate(DocumentEvent e) {
1202 /* Let the config code hook on a listener */
1203 public void addActionListener(ActionListener l) {
1207 /* set and get all of the dialog values */
1208 public void set_product(String product) {
1209 radio_frequency_value.set_product(product);
1210 product_value.setText(product);
1211 set_pad_orientation_tool_tip();
1212 set_accel_tool_tips();
1213 set_flight_log_max_tool_tip();
1214 set_pad_orientation_values();
1217 public void set_version(String version) {
1218 version_value.setText(version);
1221 public void set_serial(int serial) {
1222 radio_frequency_value.set_serial(serial);
1223 serial_value.setText(String.format("%d", serial));
1226 public void set_altitude_32(int altitude_32) {
1229 public void set_main_deploy(int new_main_deploy) {
1230 if (new_main_deploy != AltosLib.MISSING)
1231 main_deploy_value.setSelectedItem(AltosConvert.height.say(new_main_deploy));
1232 main_deploy_value.setVisible(new_main_deploy != AltosLib.MISSING);
1233 main_deploy_label.setVisible(new_main_deploy != AltosLib.MISSING);
1236 public int main_deploy() throws AltosConfigDataException {
1237 String str = main_deploy_value.getSelectedItem().toString();
1239 return (int) (AltosConvert.height.parse_locale(str) + 0.5);
1240 } catch (ParseException pe) {
1241 throw new AltosConfigDataException("invalid main deploy height %s", str);
1245 String get_main_deploy_label() {
1246 return String.format("Main Deploy Altitude(%s):", AltosConvert.height.parse_units());
1249 String[] main_deploy_values() {
1250 if (AltosConvert.imperial_units)
1251 return main_deploy_values_ft;
1253 return main_deploy_values_m;
1256 void set_main_deploy_values() {
1257 String[] v = main_deploy_values();
1258 while (main_deploy_value.getItemCount() > 0)
1259 main_deploy_value.removeItemAt(0);
1260 for (int i = 0; i < v.length; i++)
1261 main_deploy_value.addItem(v[i]);
1262 main_deploy_value.setMaximumRowCount(v.length);
1265 public void units_changed(boolean imperial_units) {
1266 boolean was_dirty = dirty;
1268 String v = main_deploy_value.getSelectedItem().toString();
1269 main_deploy_label.setText(get_main_deploy_label());
1270 set_main_deploy_values();
1272 int m = (int) (AltosConvert.height.parse_locale(v, !imperial_units) + 0.5);
1274 } catch (ParseException pe) {
1277 if (tracker_motion_value.isVisible()) {
1278 String motion = tracker_motion_value.getSelectedItem().toString();
1279 tracker_motion_label.setText(get_tracker_motion_label());
1280 set_tracker_motion_values();
1282 int m = (int) (AltosConvert.height.parse_locale(motion, !imperial_units) + 0.5);
1283 set_tracker_motion(m);
1284 } catch (ParseException pe) {
1292 public void set_apogee_delay(int new_apogee_delay) {
1293 if (new_apogee_delay != AltosLib.MISSING)
1294 apogee_delay_value.setSelectedItem(Integer.toString(new_apogee_delay));
1295 apogee_delay_value.setVisible(new_apogee_delay != AltosLib.MISSING);
1296 apogee_delay_label.setVisible(new_apogee_delay != AltosLib.MISSING);
1299 private int parse_int(String name, String s, boolean split) throws AltosConfigDataException {
1302 v = s.split("\\s+")[0];
1304 return Integer.parseInt(v);
1305 } catch (NumberFormatException ne) {
1306 throw new AltosConfigDataException("Invalid %s \"%s\"", name, s);
1310 public int apogee_delay() throws AltosConfigDataException {
1311 return parse_int("apogee delay", apogee_delay_value.getSelectedItem().toString(), false);
1314 public void set_apogee_lockout(int new_apogee_lockout) {
1315 if (new_apogee_lockout != AltosLib.MISSING)
1316 apogee_lockout_value.setSelectedItem(Integer.toString(new_apogee_lockout));
1318 apogee_lockout_value.setVisible(new_apogee_lockout != AltosLib.MISSING);
1319 apogee_lockout_label.setVisible(new_apogee_lockout != AltosLib.MISSING);
1322 public int apogee_lockout() throws AltosConfigDataException {
1323 return parse_int("apogee lockout", apogee_lockout_value.getSelectedItem().toString(), false);
1326 public void set_radio_frequency(double new_radio_frequency) {
1327 if (new_radio_frequency != AltosLib.MISSING)
1328 radio_frequency_value.set_frequency(new_radio_frequency);
1329 radio_frequency_label.setVisible(new_radio_frequency != AltosLib.MISSING);
1330 radio_frequency_value.setVisible(new_radio_frequency != AltosLib.MISSING);
1333 public double radio_frequency() {
1334 return radio_frequency_value.frequency();
1337 public void set_radio_calibration(int new_radio_calibration) {
1338 if (new_radio_calibration != AltosLib.MISSING)
1339 radio_calibration_value.setText(String.format("%d", new_radio_calibration));
1340 radio_calibration_value.setVisible(new_radio_calibration != AltosLib.MISSING);
1341 radio_calibration_label.setVisible(new_radio_calibration != AltosLib.MISSING);
1344 public void set_radio_enable(int new_radio_enable) {
1345 if (new_radio_enable != AltosLib.MISSING)
1346 radio_enable_value.setSelected(new_radio_enable != 0);
1347 radio_enable_label.setVisible(new_radio_enable != AltosLib.MISSING);
1348 radio_enable_value.setVisible(new_radio_enable != AltosLib.MISSING);
1349 set_radio_enable_tool_tip();
1352 public int radio_enable() {
1353 if (radio_enable_value.isVisible())
1354 return radio_enable_value.isSelected() ? 1 : 0;
1356 return AltosLib.MISSING;
1359 public void set_telemetry_rate(int new_rate) {
1360 if (new_rate != AltosLib.MISSING)
1361 rate_value.set_rate(new_rate);
1362 rate_label.setVisible(new_rate != AltosLib.MISSING);
1363 rate_value.setVisible(new_rate != AltosLib.MISSING);
1364 set_rate_tool_tip();
1367 public int telemetry_rate() {
1368 return rate_value.rate();
1371 public void set_callsign(String new_callsign) {
1372 if (new_callsign != null)
1373 callsign_value.setText(new_callsign);
1374 callsign_value.setVisible(new_callsign != null);
1375 callsign_label.setVisible(new_callsign != null);
1378 public String callsign() {
1379 if (callsign_value.isVisible())
1380 return callsign_value.getText();
1384 int flight_log_max_limit;
1387 public String flight_log_max_label(int flight_log_max) {
1388 if (flight_log_max_limit != 0) {
1389 int nflight = flight_log_max_limit / flight_log_max;
1390 String plural = nflight > 1 ? "s" : "";
1392 return String.format("%d (%d flight%s)", flight_log_max, nflight, plural);
1394 return String.format("%d", flight_log_max);
1397 public void set_flight_log_max(int new_flight_log_max) {
1398 if (new_flight_log_max != AltosLib.MISSING) {
1399 flight_log_max_value.setSelectedItem(flight_log_max_label(new_flight_log_max));
1400 flight_log_max = new_flight_log_max;
1402 flight_log_max_value.setVisible(new_flight_log_max != AltosLib.MISSING);
1403 flight_log_max_label.setVisible(new_flight_log_max != AltosLib.MISSING);
1404 set_flight_log_max_tool_tip();
1407 public void set_flight_log_max_enabled(boolean enable) {
1408 flight_log_max_value.setEnabled(enable);
1409 set_flight_log_max_tool_tip();
1412 public int flight_log_max() throws AltosConfigDataException {
1413 if (flight_log_max_value.isVisible())
1414 return parse_int("flight log max", flight_log_max_value.getSelectedItem().toString(), true);
1415 return AltosLib.MISSING;
1418 public void set_flight_log_max_limit(int new_flight_log_max_limit, int new_storage_erase_unit) {
1419 flight_log_max_limit = new_flight_log_max_limit;
1420 if (new_flight_log_max_limit != AltosLib.MISSING) {
1421 flight_log_max_value.removeAllItems();
1422 for (int i = 8; i >= 1; i--) {
1423 int size = flight_log_max_limit / i;
1424 if (new_storage_erase_unit != 0)
1425 size &= ~(new_storage_erase_unit - 1);
1426 flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
1429 if (flight_log_max != 0 && flight_log_max != AltosLib.MISSING)
1430 set_flight_log_max(flight_log_max);
1433 public void set_ignite_mode(int new_ignite_mode) {
1434 if (new_ignite_mode != AltosLib.MISSING) {
1435 if (new_ignite_mode >= AltosLib.ignite_mode_values.length)
1436 new_ignite_mode = 0;
1437 if (new_ignite_mode < 0) {
1438 ignite_mode_value.setEnabled(false);
1439 new_ignite_mode = 0;
1441 ignite_mode_value.setEnabled(true);
1443 ignite_mode_value.setSelectedIndex(new_ignite_mode);
1445 ignite_mode_value.setVisible(new_ignite_mode != AltosLib.MISSING);
1446 ignite_mode_label.setVisible(new_ignite_mode != AltosLib.MISSING);
1448 set_ignite_mode_tool_tip();
1451 public int ignite_mode() {
1452 if (ignite_mode_value.isVisible())
1453 return ignite_mode_value.getSelectedIndex();
1455 return AltosLib.MISSING;
1459 public void set_pad_orientation(int new_pad_orientation) {
1460 if (new_pad_orientation != AltosLib.MISSING) {
1461 if (new_pad_orientation >= pad_orientation_values.length)
1462 new_pad_orientation = 0;
1463 if (new_pad_orientation < 0)
1464 new_pad_orientation = 0;
1465 pad_orientation_value.setSelectedIndex(new_pad_orientation);
1467 pad_orientation_value.setVisible(new_pad_orientation != AltosLib.MISSING);
1468 pad_orientation_label.setVisible(new_pad_orientation != AltosLib.MISSING);
1469 accel_cal.setVisible(new_pad_orientation != AltosLib.MISSING);
1471 set_pad_orientation_tool_tip();
1474 public int pad_orientation() {
1475 if (pad_orientation_value.isVisible())
1476 return pad_orientation_value.getSelectedIndex();
1478 return AltosLib.MISSING;
1481 public void set_accel_cal(int accel_plus, int accel_minus) {
1482 if (accel_plus != AltosLib.MISSING) {
1483 accel_plus_value.setText(String.format("%d", accel_plus));
1484 accel_minus_value.setText(String.format("%d", accel_minus));
1486 accel_plus_value.setVisible(accel_plus != AltosLib.MISSING);
1487 accel_plus_label.setVisible(accel_plus != AltosLib.MISSING);
1488 accel_minus_value.setVisible(accel_minus != AltosLib.MISSING);
1489 accel_minus_label.setVisible(accel_minus != AltosLib.MISSING);
1491 set_accel_tool_tips();
1494 public int accel_cal_plus() {
1495 if (accel_plus_value.isVisible())
1496 return Integer.parseInt(accel_plus_value.getText());
1497 return AltosLib.MISSING;
1500 public int accel_cal_minus() {
1501 if (accel_minus_value.isVisible())
1502 return Integer.parseInt(accel_minus_value.getText());
1503 return AltosLib.MISSING;
1506 public void set_beep(int new_beep) {
1507 if (new_beep != AltosLib.MISSING) {
1508 int new_freq = (int) Math.floor (AltosConvert.beep_value_to_freq(new_beep) + 0.5);
1509 for (int i = 0; i < beep_values.length; i++)
1510 if (new_beep == AltosConvert.beep_freq_to_value(Integer.parseInt(beep_values[i]))) {
1511 beep_value.setSelectedIndex(i);
1512 set_beep_tool_tip();
1515 beep_value.setSelectedItem(String.format("%d", new_freq));
1517 beep_value.setVisible(new_beep != AltosLib.MISSING);
1518 beep_label.setVisible(new_beep != AltosLib.MISSING);
1519 set_beep_tool_tip();
1523 if (beep_value.isVisible())
1524 return AltosConvert.beep_freq_to_value(Integer.parseInt(beep_value.getSelectedItem().toString()));
1526 return AltosLib.MISSING;
1529 public void set_radio_10mw(int new_radio_10mw) {
1530 if (new_radio_10mw != AltosLib.MISSING) {
1531 radio_10mw_value.setSelected(new_radio_10mw != 0);
1533 radio_10mw_value.setVisible(new_radio_10mw != AltosLib.MISSING);
1534 radio_10mw_label.setVisible(new_radio_10mw != AltosLib.MISSING);
1535 set_radio_10mw_tool_tip();
1538 public int radio_10mw() {
1539 if (radio_10mw_value.isVisible())
1540 return radio_10mw_value.isSelected() ? 1 : 0;
1542 return AltosLib.MISSING;
1545 public void set_report_feet(int new_report_feet) {
1546 if (new_report_feet != AltosLib.MISSING) {
1547 if (new_report_feet >= report_feet_values.length)
1548 new_report_feet = 0;
1549 if (new_report_feet < 0) {
1550 report_feet_value.setEnabled(false);
1551 new_report_feet = 0;
1553 report_feet_value.setEnabled(true);
1555 report_feet_value.setSelectedIndex(new_report_feet);
1557 report_feet_value.setVisible(new_report_feet != AltosLib.MISSING);
1558 report_feet_label.setVisible(new_report_feet != AltosLib.MISSING);
1560 set_report_feet_tool_tip();
1563 public int report_feet() {
1564 if (report_feet_value.isVisible())
1565 return report_feet_value.getSelectedIndex();
1567 return AltosLib.MISSING;
1570 public void set_gps_receiver(int new_gps_receiver) {
1571 System.out.printf("set_gps_receiver %d\n", new_gps_receiver);
1572 if (new_gps_receiver != AltosLib.MISSING) {
1573 if (new_gps_receiver >= AltosLib.gps_receiver_names.length)
1574 new_gps_receiver = 0;
1575 if (new_gps_receiver < 0) {
1576 gps_receiver_value.setEnabled(false);
1577 new_gps_receiver = 0;
1579 gps_receiver_value.setEnabled(true);
1581 gps_receiver_value.setSelectedIndex(new_gps_receiver);
1583 gps_receiver_value.setVisible(new_gps_receiver != AltosLib.MISSING);
1584 gps_receiver_label.setVisible(new_gps_receiver != AltosLib.MISSING);
1586 set_gps_receiver_tool_tip();
1589 public int gps_receiver() {
1590 if (gps_receiver_value.isVisible())
1591 return gps_receiver_value.getSelectedIndex();
1593 return AltosLib.MISSING;
1596 String[] tracker_motion_values() {
1597 if (AltosConvert.imperial_units)
1598 return tracker_motion_values_ft;
1600 return tracker_motion_values_m;
1603 void set_tracker_motion_values() {
1604 String[] v = tracker_motion_values();
1605 while (tracker_motion_value.getItemCount() > 0)
1606 tracker_motion_value.removeItemAt(0);
1607 for (int i = 0; i < v.length; i++)
1608 tracker_motion_value.addItem(v[i]);
1609 tracker_motion_value.setMaximumRowCount(v.length);
1612 String get_tracker_motion_label() {
1613 return String.format("Logging Trigger Motion (%s):", AltosConvert.height.parse_units());
1616 void set_tracker_tool_tip() {
1617 if (tracker_motion_value.isVisible())
1618 tracker_motion_value.setToolTipText("How far the device must move before logging");
1620 tracker_motion_value.setToolTipText("This device doesn't disable logging when stationary");
1621 if (tracker_interval_value.isVisible())
1622 tracker_interval_value.setToolTipText("How often to report GPS position");
1624 tracker_interval_value.setToolTipText("This device can't configure interval");
1627 public void set_tracker_motion(int tracker_motion) {
1628 if (tracker_motion != AltosLib.MISSING)
1629 tracker_motion_value.setSelectedItem(AltosConvert.height.say(tracker_motion));
1630 tracker_motion_label.setVisible(tracker_motion != AltosLib.MISSING);
1631 tracker_motion_value.setVisible(tracker_motion != AltosLib.MISSING);
1634 public int tracker_motion() throws AltosConfigDataException {
1635 if (tracker_motion_value.isVisible()) {
1636 String str = tracker_motion_value.getSelectedItem().toString();
1638 return (int) (AltosConvert.height.parse_locale(str) + 0.5);
1639 } catch (ParseException pe) {
1640 throw new AltosConfigDataException("invalid tracker motion %s", str);
1643 return AltosLib.MISSING;
1646 public void set_tracker_interval(int tracker_interval) {
1647 if (tracker_interval != AltosLib.MISSING)
1648 tracker_interval_value.setSelectedItem(String.format("%d", tracker_interval));
1649 tracker_interval_label.setVisible(tracker_interval != AltosLib.MISSING);
1650 tracker_interval_value.setVisible(tracker_interval != AltosLib.MISSING);
1653 public int tracker_interval() throws AltosConfigDataException {
1654 if (tracker_interval_value.isVisible())
1655 return parse_int ("tracker interval", tracker_interval_value.getSelectedItem().toString(), false);
1656 return AltosLib.MISSING;
1659 public void set_pyros(AltosPyro[] new_pyros) {
1661 if (pyros != null && pyro_ui != null)
1662 pyro_ui.set_pyros(pyros);
1663 pyro.setVisible(pyros != null);
1666 public AltosPyro[] pyros() throws AltosConfigDataException {
1667 if (pyro_ui != null)
1668 pyros = pyro_ui.get_pyros();
1672 public void set_pyro_firing_time(double new_pyro_firing_time) {
1673 pyro_firing_time = new_pyro_firing_time;
1674 if (pyro_firing_time != AltosLib.MISSING && pyro_ui != null)
1675 pyro_ui.set_pyro_firing_time(pyro_firing_time);
1676 pyro.setVisible(pyro_firing_time != AltosLib.MISSING);
1679 public double pyro_firing_time() throws AltosConfigDataException {
1680 if (pyro_ui != null)
1681 pyro_firing_time = pyro_ui.get_pyro_firing_time();
1682 return pyro_firing_time;
1685 private String aprs_interval_string(int interval) {
1688 return Integer.toString(interval);
1691 private int aprs_interval_value(String interval) throws AltosConfigDataException {
1692 if (interval.equalsIgnoreCase("Disabled"))
1694 return parse_int("aprs interval", interval, false);
1697 public void set_aprs_interval(int new_aprs_interval) {
1698 if (new_aprs_interval != AltosLib.MISSING)
1699 aprs_interval_value.setSelectedItem(aprs_interval_string(new_aprs_interval));
1700 aprs_interval_value.setVisible(new_aprs_interval != AltosLib.MISSING);
1701 aprs_interval_label.setVisible(new_aprs_interval != AltosLib.MISSING);
1702 set_aprs_interval_tool_tip();
1705 public int aprs_interval() throws AltosConfigDataException {
1706 if (aprs_interval_value.isVisible())
1707 return aprs_interval_value(aprs_interval_value.getSelectedItem().toString());
1708 return AltosLib.MISSING;
1711 public void set_aprs_ssid(int new_aprs_ssid) {
1712 if (new_aprs_ssid != AltosLib.MISSING)
1713 aprs_ssid_value.setSelectedItem(new_aprs_ssid);
1714 aprs_ssid_value.setVisible(new_aprs_ssid != AltosLib.MISSING);
1715 aprs_ssid_label.setVisible(new_aprs_ssid != AltosLib.MISSING);
1716 set_aprs_ssid_tool_tip();
1719 public int aprs_ssid() throws AltosConfigDataException {
1720 if (aprs_ssid_value.isVisible()) {
1721 Integer i = (Integer) aprs_ssid_value.getSelectedItem();
1724 return AltosLib.MISSING;
1727 public void set_aprs_format(int new_aprs_format) {
1728 if (new_aprs_format != AltosLib.MISSING)
1729 aprs_format_value.setSelectedIndex(new_aprs_format);
1730 aprs_format_value.setVisible(new_aprs_format != AltosLib.MISSING);
1731 aprs_format_label.setVisible(new_aprs_format != AltosLib.MISSING);
1732 set_aprs_format_tool_tip();
1735 public int aprs_format() throws AltosConfigDataException {
1736 if (aprs_format_value.isVisible())
1737 return aprs_format_value.getSelectedIndex();
1738 return AltosLib.MISSING;
1741 public void set_aprs_offset(int new_aprs_offset) {
1742 if (new_aprs_offset != AltosLib.MISSING)
1743 aprs_offset_value.setSelectedItem(new_aprs_offset);
1744 aprs_offset_value.setVisible(new_aprs_offset != AltosLib.MISSING);
1745 aprs_offset_label.setVisible(new_aprs_offset != AltosLib.MISSING);
1746 set_aprs_offset_tool_tip();
1749 public int aprs_offset() throws AltosConfigDataException {
1750 if (aprs_offset_value.isVisible()) {
1751 Integer i = (Integer) aprs_offset_value.getSelectedItem();
1754 return AltosLib.MISSING;