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[] ignite_mode_values = {
130 "Separation & Apogee",
133 static String[] aprs_interval_values = {
140 static Integer[] aprs_ssid_values = {
141 0, 1, 2 ,3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
144 static Integer[] aprs_offset_values = {
145 0, 2, 4, 6, 8, 10, 12, 14, 16, 18
148 static String[] beep_values = {
157 static String[] pad_orientation_values_radio = {
162 static String[] pad_orientation_values_no_radio = {
167 String[] pad_orientation_values;
169 static String[] tracker_motion_values_m = {
176 static String[] tracker_motion_values_ft = {
183 static String[] tracker_interval_values = {
190 static String[] report_feet_values = {
195 /* A window listener to catch closing events and tell the config code */
196 class ConfigListener extends WindowAdapter {
199 public ConfigListener(AltosConfigFCUI this_ui) {
203 public void windowClosing(WindowEvent e) {
204 ui.actionPerformed(new ActionEvent(e.getSource(),
205 ActionEvent.ACTION_PERFORMED,
210 boolean is_telemini_v1() {
211 String product = product_value.getText();
212 return product != null && product.startsWith("TeleMini-v1");
215 boolean is_telemini() {
216 String product = product_value.getText();
217 return product != null && product.startsWith("TeleMini");
220 boolean is_easymini() {
221 String product = product_value.getText();
222 return product != null && product.startsWith("EasyMini");
225 boolean is_telemetrum() {
226 String product = product_value.getText();
227 return product != null && product.startsWith("TeleMetrum");
230 boolean is_telemega() {
231 String product = product_value.getText();
232 return product != null && product.startsWith("TeleMega");
235 boolean is_easymega() {
236 String product = product_value.getText();
237 return product != null && product.startsWith("EasyMega");
240 boolean is_easytimer() {
241 String product = product_value.getText();
242 return product != null && product.startsWith("EasyTimer");
245 public boolean has_radio() {
246 return is_telemega() || is_telemetrum() || is_telemini();
249 void set_radio_enable_tool_tip() {
250 if (radio_enable_value.isVisible())
251 radio_enable_value.setToolTipText("Enable/Disable telemetry and RDF transmissions");
253 radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
256 void set_rate_tool_tip() {
257 if (rate_value.isVisible())
258 rate_value.setToolTipText("Select telemetry baud rate");
260 rate_value.setToolTipText("Firmware version does not support variable telemetry rates");
263 void set_aprs_interval_tool_tip() {
264 if (aprs_interval_value.isVisible())
265 aprs_interval_value.setToolTipText("Enable APRS and set the interval between APRS reports");
267 aprs_interval_value.setToolTipText("Hardware doesn't support APRS");
270 void set_aprs_ssid_tool_tip() {
271 if (aprs_ssid_value.isVisible())
272 aprs_ssid_value.setToolTipText("Set the APRS SSID (secondary station identifier)");
273 else if (aprs_ssid_value.isVisible())
274 aprs_ssid_value.setToolTipText("Software version doesn't support setting the APRS SSID");
276 aprs_ssid_value.setToolTipText("Hardware doesn't support APRS");
279 void set_aprs_format_tool_tip() {
280 if (aprs_format_value.isVisible())
281 aprs_format_value.setToolTipText("Set the APRS format (compressed/uncompressed)");
282 else if (aprs_format_value.isVisible())
283 aprs_format_value.setToolTipText("Software version doesn't support setting the APRS format");
285 aprs_format_value.setToolTipText("Hardware doesn't support APRS");
288 void set_aprs_offset_tool_tip() {
289 if (aprs_offset_value.isVisible())
290 aprs_offset_value.setToolTipText("Set the APRS offset from top of minute");
291 else if (aprs_offset_value.isVisible())
292 aprs_offset_value.setToolTipText("Software version doesn't support setting the APRS offset");
294 aprs_offset_value.setToolTipText("Hardware doesn't support APRS");
297 void set_flight_log_max_tool_tip() {
298 if (flight_log_max_value.isVisible())
299 flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)");
301 if (is_telemini_v1())
302 flight_log_max_value.setToolTipText("TeleMini-v1 stores only one flight");
304 flight_log_max_value.setToolTipText("Cannot set max value with flight logs in memory");
308 void set_ignite_mode_tool_tip() {
309 if (ignite_mode_value.isVisible())
310 ignite_mode_value.setToolTipText("Select when igniters will be fired");
312 ignite_mode_value.setToolTipText("Older firmware could not select ignite mode");
315 void set_pad_orientation_tool_tip() {
316 if (pad_orientation_value.isVisible()) {
317 pad_orientation_value.setToolTipText("How will the computer be mounted in the airframe");
320 pad_orientation_value.setToolTipText("Older TeleMetrum firmware must fly antenna forward");
321 else if (is_telemini() || is_easymini())
322 pad_orientation_value.setToolTipText("TeleMini and EasyMini don't care how they are mounted");
323 else if (is_easytimer())
324 pad_orientation_value.setToolTipText("EasyTimer can be mounted in any of six orientations");
326 pad_orientation_value.setToolTipText("Can't select orientation");
330 void set_pad_orientation_values() {
331 String [] new_values;
333 new_values = pad_orientation_values_radio;
335 new_values = pad_orientation_values_no_radio;
336 if (new_values != pad_orientation_values) {
337 int id = pad_orientation_value.getSelectedIndex();
338 pad_orientation_value.removeAllItems();
339 pad_orientation_values = new_values;
340 for (int i = 0; i < new_values.length; i++)
341 pad_orientation_value.addItem(pad_orientation_values[i]);
342 pad_orientation_value.setSelectedIndex(id);
346 void set_accel_tool_tips() {
347 if (accel_plus_value.isVisible()) {
348 accel_plus_value.setToolTipText("Pad acceleration value in flight orientation");
349 accel_minus_value.setToolTipText("Upside-down acceleration value");
351 accel_plus_value.setToolTipText("No accelerometer");
352 accel_minus_value.setToolTipText("No accelerometer");
356 void set_beep_tool_tip() {
357 if (beep_value.isVisible())
358 beep_value.setToolTipText("What frequency the beeper will sound at (0 for off)");
360 beep_value.setToolTipText("Older firmware could not select beeper frequency");
363 void set_radio_10mw_tool_tip() {
364 if (radio_10mw_value.isVisible())
365 radio_10mw_value.setToolTipText("Should transmitter power be limited to 10mW");
367 radio_10mw_value.setToolTipText("Older firmware could not limit radio power");
370 void set_report_feet_tool_tip() {
371 if (report_feet_value.isVisible())
372 report_feet_value.setToolTipText("Units used after landing to beep max height");
374 report_feet_value.setToolTipText("Older firmware always beeps max height in meters");
377 void set_gps_receiver_tool_tip() {
378 if (gps_receiver_value.isVisible())
379 gps_receiver_value.setToolTipText("GPS receiver selection");
381 gps_receiver_value.setToolTipText("Only TeleMega with new firmware supports alternate GPS receivers");
384 /* Build the UI using a grid bag */
385 public AltosConfigFCUI(JFrame in_owner, boolean remote) {
386 super (in_owner, title, false);
389 GridBagConstraints c;
392 Insets il = new Insets(4,4,4,4);
393 Insets ir = new Insets(4,4,4,4);
395 pane = getScrollablePane();
397 pane.setLayout(new GridBagLayout());
400 c = new GridBagConstraints();
401 c.gridx = 0; c.gridy = row;
403 c.fill = GridBagConstraints.NONE;
404 c.anchor = GridBagConstraints.LINE_START;
406 product_label = new JLabel("Product:");
407 pane.add(product_label, c);
409 c = new GridBagConstraints();
410 c.gridx = 4; c.gridy = row;
412 c.fill = GridBagConstraints.HORIZONTAL;
414 c.anchor = GridBagConstraints.LINE_START;
416 product_value = new JLabel("");
417 pane.add(product_value, c);
421 c = new GridBagConstraints();
422 c.gridx = 0; c.gridy = row;
424 c.fill = GridBagConstraints.NONE;
425 c.anchor = GridBagConstraints.LINE_START;
428 version_label = new JLabel("Software version:");
429 pane.add(version_label, c);
431 c = new GridBagConstraints();
432 c.gridx = 4; c.gridy = row;
434 c.fill = GridBagConstraints.HORIZONTAL;
436 c.anchor = GridBagConstraints.LINE_START;
439 version_value = new JLabel("");
440 pane.add(version_value, c);
444 c = new GridBagConstraints();
445 c.gridx = 0; c.gridy = row;
447 c.fill = GridBagConstraints.NONE;
448 c.anchor = GridBagConstraints.LINE_START;
451 serial_label = new JLabel("Serial:");
452 pane.add(serial_label, c);
454 c = new GridBagConstraints();
455 c.gridx = 4; c.gridy = row;
457 c.fill = GridBagConstraints.HORIZONTAL;
459 c.anchor = GridBagConstraints.LINE_START;
462 serial_value = new JLabel("");
463 pane.add(serial_value, c);
467 c = new GridBagConstraints();
468 c.gridx = 0; c.gridy = row;
470 c.fill = GridBagConstraints.NONE;
471 c.anchor = GridBagConstraints.LINE_START;
474 main_deploy_label = new JLabel(get_main_deploy_label());
475 pane.add(main_deploy_label, c);
477 c = new GridBagConstraints();
478 c.gridx = 4; c.gridy = row;
480 c.fill = GridBagConstraints.HORIZONTAL;
482 c.anchor = GridBagConstraints.LINE_START;
485 main_deploy_value = new JComboBox<String>(main_deploy_values());
486 main_deploy_value.setEditable(true);
487 main_deploy_value.addItemListener(this);
488 pane.add(main_deploy_value, c);
489 main_deploy_value.setToolTipText("Height above pad altitude to fire main charge");
493 c = new GridBagConstraints();
494 c.gridx = 0; c.gridy = row;
496 c.fill = GridBagConstraints.NONE;
497 c.anchor = GridBagConstraints.LINE_START;
500 apogee_delay_label = new JLabel("Apogee Delay(s):");
501 pane.add(apogee_delay_label, c);
503 c = new GridBagConstraints();
504 c.gridx = 4; c.gridy = row;
506 c.fill = GridBagConstraints.HORIZONTAL;
508 c.anchor = GridBagConstraints.LINE_START;
511 apogee_delay_value = new JComboBox<String>(apogee_delay_values);
512 apogee_delay_value.setEditable(true);
513 apogee_delay_value.addItemListener(this);
514 pane.add(apogee_delay_value, c);
515 apogee_delay_value.setToolTipText("Delay after apogee before charge fires");
519 c = new GridBagConstraints();
520 c.gridx = 0; c.gridy = row;
522 c.fill = GridBagConstraints.NONE;
523 c.anchor = GridBagConstraints.LINE_START;
526 apogee_lockout_label = new JLabel("Apogee Lockout(s):");
527 pane.add(apogee_lockout_label, c);
529 c = new GridBagConstraints();
530 c.gridx = 4; c.gridy = row;
532 c.fill = GridBagConstraints.HORIZONTAL;
534 c.anchor = GridBagConstraints.LINE_START;
537 apogee_lockout_value = new JComboBox<String>(apogee_lockout_values);
538 apogee_lockout_value.setEditable(true);
539 apogee_lockout_value.addItemListener(this);
540 pane.add(apogee_lockout_value, c);
541 apogee_lockout_value.setToolTipText("Time after launch while apogee detection is locked out");
545 c = new GridBagConstraints();
546 c.gridx = 0; c.gridy = row;
548 c.fill = GridBagConstraints.NONE;
549 c.anchor = GridBagConstraints.LINE_START;
552 radio_frequency_label = new JLabel("Frequency:");
553 pane.add(radio_frequency_label, c);
555 c = new GridBagConstraints();
556 c.gridx = 4; c.gridy = row;
558 c.fill = GridBagConstraints.HORIZONTAL;
560 c.anchor = GridBagConstraints.LINE_START;
563 radio_frequency_value = new AltosUIFreqList();
564 radio_frequency_value.addItemListener(this);
565 pane.add(radio_frequency_value, c);
566 radio_frequency_value.setToolTipText("Telemetry, RDF and packet frequency");
569 /* Radio Calibration */
570 c = new GridBagConstraints();
571 c.gridx = 0; c.gridy = row;
573 c.fill = GridBagConstraints.NONE;
574 c.anchor = GridBagConstraints.LINE_START;
577 radio_calibration_label = new JLabel("RF Calibration:");
578 pane.add(radio_calibration_label, c);
580 c = new GridBagConstraints();
581 c.gridx = 4; c.gridy = row;
583 c.fill = GridBagConstraints.HORIZONTAL;
585 c.anchor = GridBagConstraints.LINE_START;
588 radio_calibration_value = new JLabel(String.format("%d", 1186611));
589 pane.add(radio_calibration_value, c);
593 c = new GridBagConstraints();
594 c.gridx = 0; c.gridy = row;
596 c.fill = GridBagConstraints.NONE;
597 c.anchor = GridBagConstraints.LINE_START;
600 radio_enable_label = new JLabel("Telemetry/RDF/APRS Enable:");
601 pane.add(radio_enable_label, c);
603 c = new GridBagConstraints();
604 c.gridx = 4; c.gridy = row;
606 c.fill = GridBagConstraints.HORIZONTAL;
608 c.anchor = GridBagConstraints.LINE_START;
611 radio_enable_value = new JRadioButton("Enabled");
612 radio_enable_value.addItemListener(this);
613 pane.add(radio_enable_value, c);
614 set_radio_enable_tool_tip();
617 /* Radio 10mW limit */
618 c = new GridBagConstraints();
619 c.gridx = 0; c.gridy = row;
621 c.fill = GridBagConstraints.NONE;
622 c.anchor = GridBagConstraints.LINE_START;
625 radio_10mw_label = new JLabel("Limit transmit to 10mW:");
626 pane.add(radio_10mw_label, c);
628 c = new GridBagConstraints();
629 c.gridx = 4; c.gridy = row;
631 c.fill = GridBagConstraints.HORIZONTAL;
633 c.anchor = GridBagConstraints.LINE_START;
636 radio_10mw_value = new JRadioButton("Limited");
637 radio_10mw_value.addItemListener(this);
638 pane.add(radio_10mw_value, c);
639 set_radio_10mw_tool_tip();
643 c = new GridBagConstraints();
644 c.gridx = 0; c.gridy = row;
646 c.fill = GridBagConstraints.NONE;
647 c.anchor = GridBagConstraints.LINE_START;
650 report_feet_label = new JLabel("Beep max height in:");
651 pane.add(report_feet_label, c);
653 c = new GridBagConstraints();
654 c.gridx = 4; c.gridy = row;
656 c.fill = GridBagConstraints.HORIZONTAL;
658 c.anchor = GridBagConstraints.LINE_START;
661 report_feet_value = new JComboBox<String>(report_feet_values);
662 report_feet_value.setEditable(false);
663 report_feet_value.addItemListener(this);
664 pane.add(report_feet_value, c);
665 set_report_feet_tool_tip();
669 c = new GridBagConstraints();
670 c.gridx = 0; c.gridy = row;
672 c.fill = GridBagConstraints.NONE;
673 c.anchor = GridBagConstraints.LINE_START;
676 gps_receiver_label = new JLabel("GPS Receiver:");
677 pane.add(gps_receiver_label, c);
679 c = new GridBagConstraints();
680 c.gridx = 4; c.gridy = row;
682 c.fill = GridBagConstraints.HORIZONTAL;
684 c.anchor = GridBagConstraints.LINE_START;
687 gps_receiver_value = new JComboBox<String>(AltosLib.gps_receiver_names);
688 gps_receiver_value.setEditable(false);
689 gps_receiver_value.addItemListener(this);
690 pane.add(gps_receiver_value, c);
691 set_gps_receiver_tool_tip();
695 c = new GridBagConstraints();
696 c.gridx = 0; c.gridy = row;
698 c.fill = GridBagConstraints.NONE;
699 c.anchor = GridBagConstraints.LINE_START;
702 rate_label = new JLabel("Telemetry baud rate:");
703 pane.add(rate_label, c);
705 c = new GridBagConstraints();
706 c.gridx = 4; c.gridy = row;
708 c.fill = GridBagConstraints.HORIZONTAL;
710 c.anchor = GridBagConstraints.LINE_START;
713 rate_value = new AltosUIRateList();
714 rate_value.addItemListener(this);
715 pane.add(rate_value, c);
720 c = new GridBagConstraints();
721 c.gridx = 0; c.gridy = row;
723 c.fill = GridBagConstraints.NONE;
724 c.anchor = GridBagConstraints.LINE_START;
727 aprs_interval_label = new JLabel("APRS Interval(s):");
728 pane.add(aprs_interval_label, c);
730 c = new GridBagConstraints();
731 c.gridx = 4; c.gridy = row;
733 c.fill = GridBagConstraints.HORIZONTAL;
735 c.anchor = GridBagConstraints.LINE_START;
738 aprs_interval_value = new JComboBox<String>(aprs_interval_values);
739 aprs_interval_value.setEditable(true);
740 aprs_interval_value.addItemListener(this);
741 pane.add(aprs_interval_value, c);
742 set_aprs_interval_tool_tip();
746 c = new GridBagConstraints();
747 c.gridx = 0; c.gridy = row;
749 c.fill = GridBagConstraints.NONE;
750 c.anchor = GridBagConstraints.LINE_START;
753 aprs_ssid_label = new JLabel("APRS SSID:");
754 pane.add(aprs_ssid_label, c);
756 c = new GridBagConstraints();
757 c.gridx = 4; c.gridy = row;
759 c.fill = GridBagConstraints.HORIZONTAL;
761 c.anchor = GridBagConstraints.LINE_START;
764 aprs_ssid_value = new JComboBox<Integer>(aprs_ssid_values);
765 aprs_ssid_value.setEditable(false);
766 aprs_ssid_value.addItemListener(this);
767 aprs_ssid_value.setMaximumRowCount(aprs_ssid_values.length);
768 pane.add(aprs_ssid_value, c);
769 set_aprs_ssid_tool_tip();
773 c = new GridBagConstraints();
774 c.gridx = 0; c.gridy = row;
776 c.fill = GridBagConstraints.NONE;
777 c.anchor = GridBagConstraints.LINE_START;
780 aprs_format_label = new JLabel("APRS format:");
781 pane.add(aprs_format_label, c);
783 c = new GridBagConstraints();
784 c.gridx = 4; c.gridy = row;
786 c.fill = GridBagConstraints.HORIZONTAL;
788 c.anchor = GridBagConstraints.LINE_START;
791 aprs_format_value = new JComboBox<String>(AltosLib.ao_aprs_format_name);
792 aprs_format_value.setEditable(false);
793 aprs_format_value.addItemListener(this);
794 aprs_format_value.setMaximumRowCount(AltosLib.ao_aprs_format_name.length);
795 pane.add(aprs_format_value, c);
796 set_aprs_format_tool_tip();
800 c = new GridBagConstraints();
801 c.gridx = 0; c.gridy = row;
803 c.fill = GridBagConstraints.NONE;
804 c.anchor = GridBagConstraints.LINE_START;
807 aprs_offset_label = new JLabel("APRS offset:");
808 pane.add(aprs_offset_label, c);
810 c = new GridBagConstraints();
811 c.gridx = 4; c.gridy = row;
813 c.fill = GridBagConstraints.HORIZONTAL;
815 c.anchor = GridBagConstraints.LINE_START;
818 aprs_offset_value = new JComboBox<Integer>(aprs_offset_values);
819 aprs_offset_value.setEditable(false);
820 aprs_offset_value.addItemListener(this);
821 aprs_offset_value.setMaximumRowCount(aprs_offset_values.length);
822 pane.add(aprs_offset_value, c);
823 set_aprs_offset_tool_tip();
827 c = new GridBagConstraints();
828 c.gridx = 0; c.gridy = row;
830 c.fill = GridBagConstraints.NONE;
831 c.anchor = GridBagConstraints.LINE_START;
834 callsign_label = new JLabel("Callsign:");
835 pane.add(callsign_label, c);
837 c = new GridBagConstraints();
838 c.gridx = 4; c.gridy = row;
840 c.fill = GridBagConstraints.HORIZONTAL;
842 c.anchor = GridBagConstraints.LINE_START;
845 callsign_value = new JTextField(AltosUIPreferences.callsign());
846 callsign_value.getDocument().addDocumentListener(this);
847 pane.add(callsign_value, c);
848 callsign_value.setToolTipText("Callsign reported in telemetry data");
852 c = new GridBagConstraints();
853 c.gridx = 0; c.gridy = row;
855 c.fill = GridBagConstraints.NONE;
856 c.anchor = GridBagConstraints.LINE_START;
859 flight_log_max_label = new JLabel("Maximum Flight Log Size (kB):");
860 pane.add(flight_log_max_label, c);
862 c = new GridBagConstraints();
863 c.gridx = 4; c.gridy = row;
865 c.fill = GridBagConstraints.HORIZONTAL;
867 c.anchor = GridBagConstraints.LINE_START;
870 flight_log_max_value = new JComboBox<String>();
871 flight_log_max_value.setEditable(true);
872 flight_log_max_value.addItemListener(this);
873 pane.add(flight_log_max_value, c);
874 set_flight_log_max_tool_tip();
878 c = new GridBagConstraints();
879 c.gridx = 0; c.gridy = row;
881 c.fill = GridBagConstraints.NONE;
882 c.anchor = GridBagConstraints.LINE_START;
885 ignite_mode_label = new JLabel("Igniter Firing Mode:");
886 pane.add(ignite_mode_label, c);
888 c = new GridBagConstraints();
889 c.gridx = 4; c.gridy = row;
891 c.fill = GridBagConstraints.HORIZONTAL;
893 c.anchor = GridBagConstraints.LINE_START;
896 ignite_mode_value = new JComboBox<String>(ignite_mode_values);
897 ignite_mode_value.setEditable(false);
898 ignite_mode_value.addItemListener(this);
899 pane.add(ignite_mode_value, c);
900 set_ignite_mode_tool_tip();
903 /* Pad orientation */
904 c = new GridBagConstraints();
905 c.gridx = 0; c.gridy = row;
907 c.fill = GridBagConstraints.NONE;
908 c.anchor = GridBagConstraints.LINE_START;
911 pad_orientation_label = new JLabel("Pad Orientation:");
912 pane.add(pad_orientation_label, c);
914 c = new GridBagConstraints();
915 c.gridx = 4; c.gridy = row;
917 c.fill = GridBagConstraints.HORIZONTAL;
919 c.anchor = GridBagConstraints.LINE_START;
922 pad_orientation_values = pad_orientation_values_no_radio;
924 pad_orientation_value = new JComboBox<String>(pad_orientation_values);
925 pad_orientation_value.setEditable(false);
926 pad_orientation_value.addItemListener(this);
927 pane.add(pad_orientation_value, c);
928 set_pad_orientation_tool_tip();
932 c = new GridBagConstraints();
933 c.gridx = 0; c.gridy = row;
935 c.fill = GridBagConstraints.NONE;
936 c.anchor = GridBagConstraints.LINE_START;
939 accel_plus_label = new JLabel("Accel Plus:");
940 pane.add(accel_plus_label, c);
942 c = new GridBagConstraints();
943 c.gridx = 4; c.gridy = row;
945 c.fill = GridBagConstraints.HORIZONTAL;
947 c.anchor = GridBagConstraints.LINE_START;
950 accel_plus_value = new JTextField(10);
951 accel_plus_value.setEditable(true);
952 accel_plus_value.getDocument().addDocumentListener(this);
953 pane.add(accel_plus_value, c);
957 c = new GridBagConstraints();
958 c.gridx = 0; c.gridy = row;
960 c.fill = GridBagConstraints.NONE;
961 c.anchor = GridBagConstraints.LINE_START;
964 accel_minus_label = new JLabel("Accel Minus:");
965 pane.add(accel_minus_label, c);
967 c = new GridBagConstraints();
968 c.gridx = 4; c.gridy = row;
970 c.fill = GridBagConstraints.HORIZONTAL;
972 c.anchor = GridBagConstraints.LINE_START;
975 accel_minus_value = new JTextField(10);
976 accel_minus_value.setEditable(true);
977 accel_minus_value.getDocument().addDocumentListener(this);
978 pane.add(accel_minus_value, c);
980 set_accel_tool_tips();
983 c = new GridBagConstraints();
984 c.gridx = 0; c.gridy = row;
986 c.fill = GridBagConstraints.NONE;
987 c.anchor = GridBagConstraints.LINE_START;
990 beep_label = new JLabel("Beeper Frequency:");
991 pane.add(beep_label, c);
993 c = new GridBagConstraints();
994 c.gridx = 4; c.gridy = row;
996 c.fill = GridBagConstraints.HORIZONTAL;
998 c.anchor = GridBagConstraints.LINE_START;
1001 beep_value = new JComboBox<String>(beep_values);
1002 beep_value.setEditable(true);
1003 beep_value.addItemListener(this);
1004 pane.add(beep_value, c);
1005 set_beep_tool_tip();
1008 /* Tracker triger horiz distances */
1009 c = new GridBagConstraints();
1010 c.gridx = 0; c.gridy = row;
1012 c.fill = GridBagConstraints.NONE;
1013 c.anchor = GridBagConstraints.LINE_START;
1016 tracker_motion_label = new JLabel(get_tracker_motion_label());
1017 pane.add(tracker_motion_label, c);
1019 c = new GridBagConstraints();
1020 c.gridx = 4; c.gridy = row;
1022 c.fill = GridBagConstraints.HORIZONTAL;
1024 c.anchor = GridBagConstraints.LINE_START;
1027 tracker_motion_value = new JComboBox<String>(tracker_motion_values());
1028 tracker_motion_value.setEditable(true);
1029 tracker_motion_value.addItemListener(this);
1030 pane.add(tracker_motion_value, c);
1033 /* Tracker triger vert distances */
1034 c = new GridBagConstraints();
1035 c.gridx = 0; c.gridy = row;
1037 c.fill = GridBagConstraints.NONE;
1038 c.anchor = GridBagConstraints.LINE_START;
1041 tracker_interval_label = new JLabel("Position Reporting Interval(s):");
1042 pane.add(tracker_interval_label, c);
1044 c = new GridBagConstraints();
1045 c.gridx = 4; c.gridy = row;
1047 c.fill = GridBagConstraints.HORIZONTAL;
1049 c.anchor = GridBagConstraints.LINE_START;
1052 tracker_interval_value = new JComboBox<String>(tracker_interval_values);
1053 tracker_interval_value.setEditable(true);
1054 tracker_interval_value.addItemListener(this);
1055 pane.add(tracker_interval_value, c);
1056 set_tracker_tool_tip();
1060 c = new GridBagConstraints();
1061 c.gridx = 4; c.gridy = row;
1063 c.fill = GridBagConstraints.HORIZONTAL;
1064 c.anchor = GridBagConstraints.LINE_START;
1067 pyro = new JButton("Configure Pyro Channels");
1069 pyro.addActionListener(this);
1070 pyro.setActionCommand("Pyro");
1074 c = new GridBagConstraints();
1075 c.gridx = 5; c.gridy = row;
1077 c.fill = GridBagConstraints.HORIZONTAL;
1078 c.anchor = GridBagConstraints.LINE_START;
1081 accel_cal = new JButton("Calibrate Accelerometer");
1082 pane.add(accel_cal, c);
1083 accel_cal.addActionListener(this);
1084 accel_cal.setActionCommand("Accel");
1088 c = new GridBagConstraints();
1089 c.gridx = 0; c.gridy = row;
1091 c.fill = GridBagConstraints.NONE;
1092 c.anchor = GridBagConstraints.LINE_START;
1094 save = new JButton("Save");
1096 save.addActionListener(this);
1097 save.setActionCommand("Save");
1099 c = new GridBagConstraints();
1100 c.gridx = 2; c.gridy = row;
1102 c.fill = GridBagConstraints.NONE;
1103 c.anchor = GridBagConstraints.CENTER;
1105 reset = new JButton("Reset");
1107 reset.addActionListener(this);
1108 reset.setActionCommand("Reset");
1110 c = new GridBagConstraints();
1111 c.gridx = 4; c.gridy = row;
1113 c.fill = GridBagConstraints.NONE;
1114 c.anchor = GridBagConstraints.CENTER;
1116 reboot = new JButton("Reboot");
1117 pane.add(reboot, c);
1118 reboot.addActionListener(this);
1119 reboot.setActionCommand("Reboot");
1121 c = new GridBagConstraints();
1122 c.gridx = 6; c.gridy = row;
1124 c.fill = GridBagConstraints.NONE;
1125 c.anchor = GridBagConstraints.LINE_END;
1127 close = new JButton("Close");
1129 close.addActionListener(this);
1130 close.setActionCommand("Close");
1132 addWindowListener(new ConfigListener(this));
1133 AltosPreferences.register_units_listener(this);
1136 /* Once the initial values are set, the config code will show the dialog */
1137 public void make_visible() {
1139 setLocationRelativeTo(owner);
1143 /* If any values have been changed, confirm before closing */
1144 public boolean check_dirty(String operation) {
1146 Object[] options = { String.format("%s anyway", operation), "Keep editing" };
1148 i = JOptionPane.showOptionDialog(this,
1149 String.format("Configuration modified. %s anyway?", operation),
1150 "Configuration Modified",
1151 JOptionPane.DEFAULT_OPTION,
1152 JOptionPane.WARNING_MESSAGE,
1153 null, options, options[1]);
1160 public void set_dirty() {
1162 setTitle(title + " (modified)");
1163 save.setEnabled(true);
1166 public void set_clean() {
1169 save.setEnabled(false);
1172 AltosConfigPyroUI pyro_ui;
1174 public void dispose() {
1175 if (pyro_ui != null)
1177 AltosPreferences.unregister_units_listener(this);
1181 /* Listen for events from our buttons */
1182 public void actionPerformed(ActionEvent e) {
1183 String cmd = e.getActionCommand();
1185 if (cmd.equals("Pyro")) {
1186 if (pyro_ui == null && pyros != null)
1187 pyro_ui = new AltosConfigPyroUI(this, pyros, pyro_firing_time);
1188 if (pyro_ui != null)
1189 pyro_ui.make_visible();
1193 if (cmd.equals("Close") || cmd.equals("Reboot"))
1194 if (!check_dirty(cmd))
1196 if (cmd.equals("Save"))
1197 save.setEnabled(false);
1198 listener.actionPerformed(e);
1199 if (cmd.equals("Close") || cmd.equals("Reboot")) {
1205 /* ItemListener interface method */
1206 public void itemStateChanged(ItemEvent e) {
1210 /* DocumentListener interface methods */
1211 public void changedUpdate(DocumentEvent e) {
1215 public void insertUpdate(DocumentEvent e) {
1219 public void removeUpdate(DocumentEvent e) {
1223 /* Let the config code hook on a listener */
1224 public void addActionListener(ActionListener l) {
1228 /* set and get all of the dialog values */
1229 public void set_product(String product) {
1230 radio_frequency_value.set_product(product);
1231 product_value.setText(product);
1232 set_pad_orientation_tool_tip();
1233 set_accel_tool_tips();
1234 set_flight_log_max_tool_tip();
1235 set_pad_orientation_values();
1238 public void set_version(String version) {
1239 version_value.setText(version);
1242 public void set_serial(int serial) {
1243 radio_frequency_value.set_serial(serial);
1244 serial_value.setText(String.format("%d", serial));
1247 public void set_altitude_32(int altitude_32) {
1250 public void set_main_deploy(int new_main_deploy) {
1251 if (new_main_deploy != AltosLib.MISSING)
1252 main_deploy_value.setSelectedItem(AltosConvert.height.say(new_main_deploy));
1253 main_deploy_value.setVisible(new_main_deploy != AltosLib.MISSING);
1254 main_deploy_label.setVisible(new_main_deploy != AltosLib.MISSING);
1257 public int main_deploy() throws AltosConfigDataException {
1258 String str = main_deploy_value.getSelectedItem().toString();
1260 return (int) (AltosConvert.height.parse_locale(str) + 0.5);
1261 } catch (ParseException pe) {
1262 throw new AltosConfigDataException("invalid main deploy height %s", str);
1266 String get_main_deploy_label() {
1267 return String.format("Main Deploy Altitude(%s):", AltosConvert.height.parse_units());
1270 String[] main_deploy_values() {
1271 if (AltosConvert.imperial_units)
1272 return main_deploy_values_ft;
1274 return main_deploy_values_m;
1277 void set_main_deploy_values() {
1278 String[] v = main_deploy_values();
1279 while (main_deploy_value.getItemCount() > 0)
1280 main_deploy_value.removeItemAt(0);
1281 for (int i = 0; i < v.length; i++)
1282 main_deploy_value.addItem(v[i]);
1283 main_deploy_value.setMaximumRowCount(v.length);
1286 public void units_changed(boolean imperial_units) {
1287 boolean was_dirty = dirty;
1289 String v = main_deploy_value.getSelectedItem().toString();
1290 main_deploy_label.setText(get_main_deploy_label());
1291 set_main_deploy_values();
1293 int m = (int) (AltosConvert.height.parse_locale(v, !imperial_units) + 0.5);
1295 } catch (ParseException pe) {
1298 if (tracker_motion_value.isVisible()) {
1299 String motion = tracker_motion_value.getSelectedItem().toString();
1300 tracker_motion_label.setText(get_tracker_motion_label());
1301 set_tracker_motion_values();
1303 int m = (int) (AltosConvert.height.parse_locale(motion, !imperial_units) + 0.5);
1304 set_tracker_motion(m);
1305 } catch (ParseException pe) {
1313 public void set_apogee_delay(int new_apogee_delay) {
1314 if (new_apogee_delay != AltosLib.MISSING)
1315 apogee_delay_value.setSelectedItem(Integer.toString(new_apogee_delay));
1316 apogee_delay_value.setVisible(new_apogee_delay != AltosLib.MISSING);
1317 apogee_delay_label.setVisible(new_apogee_delay != AltosLib.MISSING);
1320 private int parse_int(String name, String s, boolean split) throws AltosConfigDataException {
1323 v = s.split("\\s+")[0];
1325 return Integer.parseInt(v);
1326 } catch (NumberFormatException ne) {
1327 throw new AltosConfigDataException("Invalid %s \"%s\"", name, s);
1331 public int apogee_delay() throws AltosConfigDataException {
1332 return parse_int("apogee delay", apogee_delay_value.getSelectedItem().toString(), false);
1335 public void set_apogee_lockout(int new_apogee_lockout) {
1336 if (new_apogee_lockout != AltosLib.MISSING)
1337 apogee_lockout_value.setSelectedItem(Integer.toString(new_apogee_lockout));
1339 apogee_lockout_value.setVisible(new_apogee_lockout != AltosLib.MISSING);
1340 apogee_lockout_label.setVisible(new_apogee_lockout != AltosLib.MISSING);
1343 public int apogee_lockout() throws AltosConfigDataException {
1344 return parse_int("apogee lockout", apogee_lockout_value.getSelectedItem().toString(), false);
1347 public void set_radio_frequency(double new_radio_frequency) {
1348 if (new_radio_frequency != AltosLib.MISSING)
1349 radio_frequency_value.set_frequency(new_radio_frequency);
1350 radio_frequency_label.setVisible(new_radio_frequency != AltosLib.MISSING);
1351 radio_frequency_value.setVisible(new_radio_frequency != AltosLib.MISSING);
1354 public double radio_frequency() {
1355 return radio_frequency_value.frequency();
1358 public void set_radio_calibration(int new_radio_calibration) {
1359 if (new_radio_calibration != AltosLib.MISSING)
1360 radio_calibration_value.setText(String.format("%d", new_radio_calibration));
1361 radio_calibration_value.setVisible(new_radio_calibration != AltosLib.MISSING);
1362 radio_calibration_label.setVisible(new_radio_calibration != AltosLib.MISSING);
1365 public void set_radio_enable(int new_radio_enable) {
1366 if (new_radio_enable != AltosLib.MISSING)
1367 radio_enable_value.setSelected(new_radio_enable != 0);
1368 radio_enable_label.setVisible(new_radio_enable != AltosLib.MISSING);
1369 radio_enable_value.setVisible(new_radio_enable != AltosLib.MISSING);
1370 set_radio_enable_tool_tip();
1373 public int radio_enable() {
1374 if (radio_enable_value.isVisible())
1375 return radio_enable_value.isSelected() ? 1 : 0;
1377 return AltosLib.MISSING;
1380 public void set_telemetry_rate(int new_rate) {
1381 if (new_rate != AltosLib.MISSING)
1382 rate_value.set_rate(new_rate);
1383 rate_label.setVisible(new_rate != AltosLib.MISSING);
1384 rate_value.setVisible(new_rate != AltosLib.MISSING);
1385 set_rate_tool_tip();
1388 public int telemetry_rate() {
1389 return rate_value.rate();
1392 public void set_callsign(String new_callsign) {
1393 if (new_callsign != null)
1394 callsign_value.setText(new_callsign);
1395 callsign_value.setVisible(new_callsign != null);
1396 callsign_label.setVisible(new_callsign != null);
1399 public String callsign() {
1400 if (callsign_value.isVisible())
1401 return callsign_value.getText();
1405 int flight_log_max_limit;
1408 public String flight_log_max_label(int flight_log_max) {
1409 if (flight_log_max_limit != 0) {
1410 int nflight = flight_log_max_limit / flight_log_max;
1411 String plural = nflight > 1 ? "s" : "";
1413 return String.format("%d (%d flight%s)", flight_log_max, nflight, plural);
1415 return String.format("%d", flight_log_max);
1418 public void set_flight_log_max(int new_flight_log_max) {
1419 if (new_flight_log_max != AltosLib.MISSING) {
1420 flight_log_max_value.setSelectedItem(flight_log_max_label(new_flight_log_max));
1421 flight_log_max = new_flight_log_max;
1423 flight_log_max_value.setVisible(new_flight_log_max != AltosLib.MISSING);
1424 flight_log_max_label.setVisible(new_flight_log_max != AltosLib.MISSING);
1425 set_flight_log_max_tool_tip();
1428 public void set_flight_log_max_enabled(boolean enable) {
1429 flight_log_max_value.setEnabled(enable);
1430 set_flight_log_max_tool_tip();
1433 public int flight_log_max() throws AltosConfigDataException {
1434 if (flight_log_max_value.isVisible())
1435 return parse_int("flight log max", flight_log_max_value.getSelectedItem().toString(), true);
1436 return AltosLib.MISSING;
1439 public void set_flight_log_max_limit(int new_flight_log_max_limit, int new_storage_erase_unit) {
1440 flight_log_max_limit = new_flight_log_max_limit;
1441 if (new_flight_log_max_limit != AltosLib.MISSING) {
1442 flight_log_max_value.removeAllItems();
1443 for (int i = 8; i >= 1; i--) {
1444 int size = flight_log_max_limit / i;
1445 if (new_storage_erase_unit != 0)
1446 size &= ~(new_storage_erase_unit - 1);
1447 flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
1450 if (flight_log_max != 0 && flight_log_max != AltosLib.MISSING)
1451 set_flight_log_max(flight_log_max);
1454 public void set_ignite_mode(int new_ignite_mode) {
1455 if (new_ignite_mode != AltosLib.MISSING) {
1456 if (new_ignite_mode >= ignite_mode_values.length)
1457 new_ignite_mode = 0;
1458 if (new_ignite_mode < 0) {
1459 ignite_mode_value.setEnabled(false);
1460 new_ignite_mode = 0;
1462 ignite_mode_value.setEnabled(true);
1464 ignite_mode_value.setSelectedIndex(new_ignite_mode);
1466 ignite_mode_value.setVisible(new_ignite_mode != AltosLib.MISSING);
1467 ignite_mode_label.setVisible(new_ignite_mode != AltosLib.MISSING);
1469 set_ignite_mode_tool_tip();
1472 public int ignite_mode() {
1473 if (ignite_mode_value.isVisible())
1474 return ignite_mode_value.getSelectedIndex();
1476 return AltosLib.MISSING;
1480 public void set_pad_orientation(int new_pad_orientation) {
1481 if (new_pad_orientation != AltosLib.MISSING) {
1482 if (new_pad_orientation >= pad_orientation_values.length)
1483 new_pad_orientation = 0;
1484 if (new_pad_orientation < 0)
1485 new_pad_orientation = 0;
1486 pad_orientation_value.setSelectedIndex(new_pad_orientation);
1488 pad_orientation_value.setVisible(new_pad_orientation != AltosLib.MISSING);
1489 pad_orientation_label.setVisible(new_pad_orientation != AltosLib.MISSING);
1490 accel_cal.setVisible(new_pad_orientation != AltosLib.MISSING);
1492 set_pad_orientation_tool_tip();
1495 public int pad_orientation() {
1496 if (pad_orientation_value.isVisible())
1497 return pad_orientation_value.getSelectedIndex();
1499 return AltosLib.MISSING;
1502 public void set_accel_cal(int accel_plus, int accel_minus) {
1503 if (accel_plus != AltosLib.MISSING) {
1504 accel_plus_value.setText(String.format("%d", accel_plus));
1505 accel_minus_value.setText(String.format("%d", accel_minus));
1507 accel_plus_value.setVisible(accel_plus != AltosLib.MISSING);
1508 accel_plus_label.setVisible(accel_plus != AltosLib.MISSING);
1509 accel_minus_value.setVisible(accel_minus != AltosLib.MISSING);
1510 accel_minus_label.setVisible(accel_minus != AltosLib.MISSING);
1512 set_accel_tool_tips();
1515 public int accel_cal_plus() {
1516 if (accel_plus_value.isVisible())
1517 return Integer.parseInt(accel_plus_value.getText());
1518 return AltosLib.MISSING;
1521 public int accel_cal_minus() {
1522 if (accel_minus_value.isVisible())
1523 return Integer.parseInt(accel_minus_value.getText());
1524 return AltosLib.MISSING;
1527 public void set_beep(int new_beep) {
1528 if (new_beep != AltosLib.MISSING) {
1529 int new_freq = (int) Math.floor (AltosConvert.beep_value_to_freq(new_beep) + 0.5);
1530 for (int i = 0; i < beep_values.length; i++)
1531 if (new_beep == AltosConvert.beep_freq_to_value(Integer.parseInt(beep_values[i]))) {
1532 beep_value.setSelectedIndex(i);
1533 set_beep_tool_tip();
1536 beep_value.setSelectedItem(String.format("%d", new_freq));
1538 beep_value.setVisible(new_beep != AltosLib.MISSING);
1539 beep_label.setVisible(new_beep != AltosLib.MISSING);
1540 set_beep_tool_tip();
1544 if (beep_value.isVisible())
1545 return AltosConvert.beep_freq_to_value(Integer.parseInt(beep_value.getSelectedItem().toString()));
1547 return AltosLib.MISSING;
1550 public void set_radio_10mw(int new_radio_10mw) {
1551 if (new_radio_10mw != AltosLib.MISSING) {
1552 radio_10mw_value.setSelected(new_radio_10mw != 0);
1554 radio_10mw_value.setVisible(new_radio_10mw != AltosLib.MISSING);
1555 radio_10mw_label.setVisible(new_radio_10mw != AltosLib.MISSING);
1556 set_radio_10mw_tool_tip();
1559 public int radio_10mw() {
1560 if (radio_10mw_value.isVisible())
1561 return radio_10mw_value.isSelected() ? 1 : 0;
1563 return AltosLib.MISSING;
1566 public void set_report_feet(int new_report_feet) {
1567 if (new_report_feet != AltosLib.MISSING) {
1568 if (new_report_feet >= report_feet_values.length)
1569 new_report_feet = 0;
1570 if (new_report_feet < 0) {
1571 report_feet_value.setEnabled(false);
1572 new_report_feet = 0;
1574 report_feet_value.setEnabled(true);
1576 report_feet_value.setSelectedIndex(new_report_feet);
1578 report_feet_value.setVisible(new_report_feet != AltosLib.MISSING);
1579 report_feet_label.setVisible(new_report_feet != AltosLib.MISSING);
1581 set_report_feet_tool_tip();
1584 public int report_feet() {
1585 if (report_feet_value.isVisible())
1586 return report_feet_value.getSelectedIndex();
1588 return AltosLib.MISSING;
1591 public void set_gps_receiver(int new_gps_receiver) {
1592 System.out.printf("set_gps_receiver %d\n", new_gps_receiver);
1593 if (new_gps_receiver != AltosLib.MISSING) {
1594 if (new_gps_receiver >= AltosLib.gps_receiver_names.length)
1595 new_gps_receiver = 0;
1596 if (new_gps_receiver < 0) {
1597 gps_receiver_value.setEnabled(false);
1598 new_gps_receiver = 0;
1600 gps_receiver_value.setEnabled(true);
1602 gps_receiver_value.setSelectedIndex(new_gps_receiver);
1604 gps_receiver_value.setVisible(new_gps_receiver != AltosLib.MISSING);
1605 gps_receiver_label.setVisible(new_gps_receiver != AltosLib.MISSING);
1607 set_gps_receiver_tool_tip();
1610 public int gps_receiver() {
1611 if (gps_receiver_value.isVisible())
1612 return gps_receiver_value.getSelectedIndex();
1614 return AltosLib.MISSING;
1617 String[] tracker_motion_values() {
1618 if (AltosConvert.imperial_units)
1619 return tracker_motion_values_ft;
1621 return tracker_motion_values_m;
1624 void set_tracker_motion_values() {
1625 String[] v = tracker_motion_values();
1626 while (tracker_motion_value.getItemCount() > 0)
1627 tracker_motion_value.removeItemAt(0);
1628 for (int i = 0; i < v.length; i++)
1629 tracker_motion_value.addItem(v[i]);
1630 tracker_motion_value.setMaximumRowCount(v.length);
1633 String get_tracker_motion_label() {
1634 return String.format("Logging Trigger Motion (%s):", AltosConvert.height.parse_units());
1637 void set_tracker_tool_tip() {
1638 if (tracker_motion_value.isVisible())
1639 tracker_motion_value.setToolTipText("How far the device must move before logging");
1641 tracker_motion_value.setToolTipText("This device doesn't disable logging when stationary");
1642 if (tracker_interval_value.isVisible())
1643 tracker_interval_value.setToolTipText("How often to report GPS position");
1645 tracker_interval_value.setToolTipText("This device can't configure interval");
1648 public void set_tracker_motion(int tracker_motion) {
1649 if (tracker_motion != AltosLib.MISSING)
1650 tracker_motion_value.setSelectedItem(AltosConvert.height.say(tracker_motion));
1651 tracker_motion_label.setVisible(tracker_motion != AltosLib.MISSING);
1652 tracker_motion_value.setVisible(tracker_motion != AltosLib.MISSING);
1655 public int tracker_motion() throws AltosConfigDataException {
1656 if (tracker_motion_value.isVisible()) {
1657 String str = tracker_motion_value.getSelectedItem().toString();
1659 return (int) (AltosConvert.height.parse_locale(str) + 0.5);
1660 } catch (ParseException pe) {
1661 throw new AltosConfigDataException("invalid tracker motion %s", str);
1664 return AltosLib.MISSING;
1667 public void set_tracker_interval(int tracker_interval) {
1668 if (tracker_interval != AltosLib.MISSING)
1669 tracker_interval_value.setSelectedItem(String.format("%d", tracker_interval));
1670 tracker_interval_label.setVisible(tracker_interval != AltosLib.MISSING);
1671 tracker_interval_value.setVisible(tracker_interval != AltosLib.MISSING);
1674 public int tracker_interval() throws AltosConfigDataException {
1675 if (tracker_interval_value.isVisible())
1676 return parse_int ("tracker interval", tracker_interval_value.getSelectedItem().toString(), false);
1677 return AltosLib.MISSING;
1680 public void set_pyros(AltosPyro[] new_pyros) {
1682 if (pyros != null && pyro_ui != null)
1683 pyro_ui.set_pyros(pyros);
1684 pyro.setVisible(pyros != null);
1687 public AltosPyro[] pyros() throws AltosConfigDataException {
1688 if (pyro_ui != null)
1689 pyros = pyro_ui.get_pyros();
1693 public void set_pyro_firing_time(double new_pyro_firing_time) {
1694 pyro_firing_time = new_pyro_firing_time;
1695 if (pyro_firing_time != AltosLib.MISSING && pyro_ui != null)
1696 pyro_ui.set_pyro_firing_time(pyro_firing_time);
1697 pyro.setVisible(pyro_firing_time != AltosLib.MISSING);
1700 public double pyro_firing_time() throws AltosConfigDataException {
1701 if (pyro_ui != null)
1702 pyro_firing_time = pyro_ui.get_pyro_firing_time();
1703 return pyro_firing_time;
1706 private String aprs_interval_string(int interval) {
1709 return Integer.toString(interval);
1712 private int aprs_interval_value(String interval) throws AltosConfigDataException {
1713 if (interval.equalsIgnoreCase("Disabled"))
1715 return parse_int("aprs interval", interval, false);
1718 public void set_aprs_interval(int new_aprs_interval) {
1719 if (new_aprs_interval != AltosLib.MISSING)
1720 aprs_interval_value.setSelectedItem(aprs_interval_string(new_aprs_interval));
1721 aprs_interval_value.setVisible(new_aprs_interval != AltosLib.MISSING);
1722 aprs_interval_label.setVisible(new_aprs_interval != AltosLib.MISSING);
1723 set_aprs_interval_tool_tip();
1726 public int aprs_interval() throws AltosConfigDataException {
1727 if (aprs_interval_value.isVisible())
1728 return aprs_interval_value(aprs_interval_value.getSelectedItem().toString());
1729 return AltosLib.MISSING;
1732 public void set_aprs_ssid(int new_aprs_ssid) {
1733 if (new_aprs_ssid != AltosLib.MISSING)
1734 aprs_ssid_value.setSelectedItem(new_aprs_ssid);
1735 aprs_ssid_value.setVisible(new_aprs_ssid != AltosLib.MISSING);
1736 aprs_ssid_label.setVisible(new_aprs_ssid != AltosLib.MISSING);
1737 set_aprs_ssid_tool_tip();
1740 public int aprs_ssid() throws AltosConfigDataException {
1741 if (aprs_ssid_value.isVisible()) {
1742 Integer i = (Integer) aprs_ssid_value.getSelectedItem();
1745 return AltosLib.MISSING;
1748 public void set_aprs_format(int new_aprs_format) {
1749 if (new_aprs_format != AltosLib.MISSING)
1750 aprs_format_value.setSelectedIndex(new_aprs_format);
1751 aprs_format_value.setVisible(new_aprs_format != AltosLib.MISSING);
1752 aprs_format_label.setVisible(new_aprs_format != AltosLib.MISSING);
1753 set_aprs_format_tool_tip();
1756 public int aprs_format() throws AltosConfigDataException {
1757 if (aprs_format_value.isVisible())
1758 return aprs_format_value.getSelectedIndex();
1759 return AltosLib.MISSING;
1762 public void set_aprs_offset(int new_aprs_offset) {
1763 if (new_aprs_offset != AltosLib.MISSING)
1764 aprs_offset_value.setSelectedItem(new_aprs_offset);
1765 aprs_offset_value.setVisible(new_aprs_offset != AltosLib.MISSING);
1766 aprs_offset_label.setVisible(new_aprs_offset != AltosLib.MISSING);
1767 set_aprs_offset_tool_tip();
1770 public int aprs_offset() throws AltosConfigDataException {
1771 if (aprs_offset_value.isVisible()) {
1772 Integer i = (Integer) aprs_offset_value.getSelectedItem();
1775 return AltosLib.MISSING;