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; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 import java.awt.event.*;
23 import javax.swing.event.*;
24 import org.altusmetrum.altoslib_4.*;
25 import org.altusmetrum.altosuilib_2.*;
27 public class AltosConfigUI
29 implements ActionListener, ItemListener, DocumentListener, AltosConfigValues, AltosUnitsListener
36 JLabel main_deploy_label;
37 JLabel apogee_delay_label;
38 JLabel apogee_lockout_label;
39 JLabel frequency_label;
40 JLabel radio_calibration_label;
41 JLabel radio_frequency_label;
42 JLabel radio_enable_label;
43 JLabel aprs_interval_label;
44 JLabel flight_log_max_label;
45 JLabel ignite_mode_label;
46 JLabel pad_orientation_label;
47 JLabel callsign_label;
49 JLabel tracker_horiz_label;
50 JLabel tracker_vert_label;
58 JComboBox<String> main_deploy_value;
59 JComboBox<String> apogee_delay_value;
60 JComboBox<String> apogee_lockout_value;
61 AltosFreqList radio_frequency_value;
62 JTextField radio_calibration_value;
63 JRadioButton radio_enable_value;
64 JComboBox<String> aprs_interval_value;
65 JComboBox<String> flight_log_max_value;
66 JComboBox<String> ignite_mode_value;
67 JComboBox<String> pad_orientation_value;
68 JTextField callsign_value;
69 JComboBox<String> beep_value;
70 JComboBox<String> tracker_horiz_value;
71 JComboBox<String> tracker_vert_value;
82 ActionListener listener;
84 static String[] main_deploy_values_m = {
85 "100", "150", "200", "250", "300", "350",
89 static String[] main_deploy_values_ft = {
90 "250", "500", "750", "1000", "1250", "1500",
94 static String[] apogee_delay_values = {
95 "0", "1", "2", "3", "4", "5"
98 static String[] apogee_lockout_values = {
99 "0", "5", "10", "15", "20"
102 static String[] flight_log_max_values = {
103 "64", "128", "192", "256", "320",
104 "384", "448", "512", "576", "640",
105 "704", "768", "832", "896", "960",
108 static String[] ignite_mode_values = {
114 static String[] aprs_interval_values = {
121 static String[] beep_values = {
127 static String[] pad_orientation_values = {
132 static String[] tracker_horiz_values_m = {
139 static String[] tracker_horiz_values_ft = {
146 static String[] tracker_vert_values_m = {
153 static String[] tracker_vert_values_ft = {
160 /* A window listener to catch closing events and tell the config code */
161 class ConfigListener extends WindowAdapter {
164 public ConfigListener(AltosConfigUI this_ui) {
168 public void windowClosing(WindowEvent e) {
169 ui.actionPerformed(new ActionEvent(e.getSource(),
170 ActionEvent.ACTION_PERFORMED,
175 boolean is_telemini_v1() {
176 String product = product_value.getText();
177 return product != null && product.startsWith("TeleMini-v1");
180 boolean is_telemini() {
181 String product = product_value.getText();
182 return product != null && product.startsWith("TeleMini");
185 boolean is_easymini() {
186 String product = product_value.getText();
187 return product != null && product.startsWith("EasyMini");
190 boolean is_telemetrum() {
191 String product = product_value.getText();
192 return product != null && product.startsWith("TeleMetrum");
195 void set_radio_calibration_tool_tip() {
196 if (radio_calibration_value.isEnabled())
197 radio_calibration_value.setToolTipText("Tune radio output to match desired frequency");
199 radio_calibration_value.setToolTipText("Cannot tune radio while connected over packet mode");
202 void set_radio_enable_tool_tip() {
203 if (radio_enable_value.isEnabled())
204 radio_enable_value.setToolTipText("Enable/Disable telemetry and RDF transmissions");
206 radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
209 void set_aprs_interval_tool_tip() {
210 if (aprs_interval_value.isEnabled())
211 aprs_interval_value.setToolTipText("Enable APRS and set the interval between APRS reports");
213 aprs_interval_value.setToolTipText("Hardware doesn't support APRS");
216 void set_flight_log_max_tool_tip() {
217 if (flight_log_max_value.isEnabled())
218 flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)");
220 if (is_telemini_v1())
221 flight_log_max_value.setToolTipText("TeleMini-v1 stores only one flight");
223 flight_log_max_value.setToolTipText("Cannot set max value with flight logs in memory");
227 void set_ignite_mode_tool_tip() {
228 if (ignite_mode_value.isEnabled())
229 ignite_mode_value.setToolTipText("Select when igniters will be fired");
231 ignite_mode_value.setToolTipText("Older firmware could not select ignite mode");
234 void set_pad_orientation_tool_tip() {
235 if (pad_orientation_value.isEnabled())
236 pad_orientation_value.setToolTipText("How will the computer be mounted in the airframe");
239 pad_orientation_value.setToolTipText("Older TeleMetrum firmware must fly antenna forward");
240 else if (is_telemini() || is_easymini())
241 pad_orientation_value.setToolTipText("TeleMini and EasyMini don't care how they are mounted");
243 pad_orientation_value.setToolTipText("Can't select orientation");
247 void set_beep_tool_tip() {
248 if (beep_value.isEnabled())
249 beep_value.setToolTipText("What frequency the beeper will sound at");
251 beep_value.setToolTipText("Older firmware could not select beeper frequency");
254 /* Build the UI using a grid bag */
255 public AltosConfigUI(JFrame in_owner, boolean remote) {
256 super (in_owner, "Configure Flight Computer", false);
259 GridBagConstraints c;
262 Insets il = new Insets(4,4,4,4);
263 Insets ir = new Insets(4,4,4,4);
265 pane = getContentPane();
266 pane.setLayout(new GridBagLayout());
269 c = new GridBagConstraints();
270 c.gridx = 0; c.gridy = row;
272 c.fill = GridBagConstraints.NONE;
273 c.anchor = GridBagConstraints.LINE_START;
275 product_label = new JLabel("Product:");
276 pane.add(product_label, c);
278 c = new GridBagConstraints();
279 c.gridx = 4; c.gridy = row;
281 c.fill = GridBagConstraints.HORIZONTAL;
283 c.anchor = GridBagConstraints.LINE_START;
285 product_value = new JLabel("");
286 pane.add(product_value, c);
290 c = new GridBagConstraints();
291 c.gridx = 0; c.gridy = row;
293 c.fill = GridBagConstraints.NONE;
294 c.anchor = GridBagConstraints.LINE_START;
297 version_label = new JLabel("Software version:");
298 pane.add(version_label, c);
300 c = new GridBagConstraints();
301 c.gridx = 4; c.gridy = row;
303 c.fill = GridBagConstraints.HORIZONTAL;
305 c.anchor = GridBagConstraints.LINE_START;
308 version_value = new JLabel("");
309 pane.add(version_value, c);
313 c = new GridBagConstraints();
314 c.gridx = 0; c.gridy = row;
316 c.fill = GridBagConstraints.NONE;
317 c.anchor = GridBagConstraints.LINE_START;
320 serial_label = new JLabel("Serial:");
321 pane.add(serial_label, c);
323 c = new GridBagConstraints();
324 c.gridx = 4; c.gridy = row;
326 c.fill = GridBagConstraints.HORIZONTAL;
328 c.anchor = GridBagConstraints.LINE_START;
331 serial_value = new JLabel("");
332 pane.add(serial_value, c);
336 c = new GridBagConstraints();
337 c.gridx = 0; c.gridy = row;
339 c.fill = GridBagConstraints.NONE;
340 c.anchor = GridBagConstraints.LINE_START;
343 main_deploy_label = new JLabel(get_main_deploy_label());
344 pane.add(main_deploy_label, c);
346 c = new GridBagConstraints();
347 c.gridx = 4; c.gridy = row;
349 c.fill = GridBagConstraints.HORIZONTAL;
351 c.anchor = GridBagConstraints.LINE_START;
354 main_deploy_value = new JComboBox<String>(main_deploy_values());
355 main_deploy_value.setEditable(true);
356 main_deploy_value.addItemListener(this);
357 pane.add(main_deploy_value, c);
358 main_deploy_value.setToolTipText("Height above pad altitude to fire main charge");
362 c = new GridBagConstraints();
363 c.gridx = 0; c.gridy = row;
365 c.fill = GridBagConstraints.NONE;
366 c.anchor = GridBagConstraints.LINE_START;
369 apogee_delay_label = new JLabel("Apogee Delay(s):");
370 pane.add(apogee_delay_label, c);
372 c = new GridBagConstraints();
373 c.gridx = 4; c.gridy = row;
375 c.fill = GridBagConstraints.HORIZONTAL;
377 c.anchor = GridBagConstraints.LINE_START;
380 apogee_delay_value = new JComboBox<String>(apogee_delay_values);
381 apogee_delay_value.setEditable(true);
382 apogee_delay_value.addItemListener(this);
383 pane.add(apogee_delay_value, c);
384 apogee_delay_value.setToolTipText("Delay after apogee before charge fires");
388 c = new GridBagConstraints();
389 c.gridx = 0; c.gridy = row;
391 c.fill = GridBagConstraints.NONE;
392 c.anchor = GridBagConstraints.LINE_START;
395 apogee_lockout_label = new JLabel("Apogee Lockout(s):");
396 pane.add(apogee_lockout_label, c);
398 c = new GridBagConstraints();
399 c.gridx = 4; c.gridy = row;
401 c.fill = GridBagConstraints.HORIZONTAL;
403 c.anchor = GridBagConstraints.LINE_START;
406 apogee_lockout_value = new JComboBox<String>(apogee_lockout_values);
407 apogee_lockout_value.setEditable(true);
408 apogee_lockout_value.addItemListener(this);
409 pane.add(apogee_lockout_value, c);
410 apogee_lockout_value.setToolTipText("Time after boost while apogee detection is locked out");
414 c = new GridBagConstraints();
415 c.gridx = 0; c.gridy = row;
417 c.fill = GridBagConstraints.NONE;
418 c.anchor = GridBagConstraints.LINE_START;
421 radio_frequency_label = new JLabel("Frequency:");
422 pane.add(radio_frequency_label, c);
424 c = new GridBagConstraints();
425 c.gridx = 4; c.gridy = row;
427 c.fill = GridBagConstraints.HORIZONTAL;
429 c.anchor = GridBagConstraints.LINE_START;
432 radio_frequency_value = new AltosFreqList();
433 radio_frequency_value.addItemListener(this);
434 pane.add(radio_frequency_value, c);
435 radio_frequency_value.setToolTipText("Telemetry, RDF and packet frequency");
438 /* Radio Calibration */
439 c = new GridBagConstraints();
440 c.gridx = 0; c.gridy = row;
442 c.fill = GridBagConstraints.NONE;
443 c.anchor = GridBagConstraints.LINE_START;
446 radio_calibration_label = new JLabel("RF Calibration:");
447 pane.add(radio_calibration_label, c);
449 c = new GridBagConstraints();
450 c.gridx = 4; c.gridy = row;
452 c.fill = GridBagConstraints.HORIZONTAL;
454 c.anchor = GridBagConstraints.LINE_START;
457 radio_calibration_value = new JTextField(String.format("%d", 1186611));
458 radio_calibration_value.getDocument().addDocumentListener(this);
460 radio_calibration_value.setEnabled(false);
461 pane.add(radio_calibration_value, c);
462 set_radio_calibration_tool_tip();
466 c = new GridBagConstraints();
467 c.gridx = 0; c.gridy = row;
469 c.fill = GridBagConstraints.NONE;
470 c.anchor = GridBagConstraints.LINE_START;
473 radio_enable_label = new JLabel("Telemetry/RDF/APRS Enable:");
474 pane.add(radio_enable_label, c);
476 c = new GridBagConstraints();
477 c.gridx = 4; c.gridy = row;
479 c.fill = GridBagConstraints.HORIZONTAL;
481 c.anchor = GridBagConstraints.LINE_START;
484 radio_enable_value = new JRadioButton("Enabled");
485 radio_enable_value.addItemListener(this);
486 pane.add(radio_enable_value, c);
487 set_radio_enable_tool_tip();
491 c = new GridBagConstraints();
492 c.gridx = 0; c.gridy = row;
494 c.fill = GridBagConstraints.NONE;
495 c.anchor = GridBagConstraints.LINE_START;
498 aprs_interval_label = new JLabel("APRS Interval(s):");
499 pane.add(aprs_interval_label, c);
501 c = new GridBagConstraints();
502 c.gridx = 4; c.gridy = row;
504 c.fill = GridBagConstraints.HORIZONTAL;
506 c.anchor = GridBagConstraints.LINE_START;
509 aprs_interval_value = new JComboBox<String>(aprs_interval_values);
510 aprs_interval_value.setEditable(true);
511 aprs_interval_value.addItemListener(this);
512 pane.add(aprs_interval_value, c);
513 set_aprs_interval_tool_tip();
517 c = new GridBagConstraints();
518 c.gridx = 0; c.gridy = row;
520 c.fill = GridBagConstraints.NONE;
521 c.anchor = GridBagConstraints.LINE_START;
524 callsign_label = new JLabel("Callsign:");
525 pane.add(callsign_label, c);
527 c = new GridBagConstraints();
528 c.gridx = 4; c.gridy = row;
530 c.fill = GridBagConstraints.HORIZONTAL;
532 c.anchor = GridBagConstraints.LINE_START;
535 callsign_value = new JTextField(AltosUIPreferences.callsign());
536 callsign_value.getDocument().addDocumentListener(this);
537 pane.add(callsign_value, c);
538 callsign_value.setToolTipText("Callsign reported in telemetry data");
542 c = new GridBagConstraints();
543 c.gridx = 0; c.gridy = row;
545 c.fill = GridBagConstraints.NONE;
546 c.anchor = GridBagConstraints.LINE_START;
549 flight_log_max_label = new JLabel("Maximum Flight Log Size:");
550 pane.add(flight_log_max_label, c);
552 c = new GridBagConstraints();
553 c.gridx = 4; c.gridy = row;
555 c.fill = GridBagConstraints.HORIZONTAL;
557 c.anchor = GridBagConstraints.LINE_START;
560 flight_log_max_value = new JComboBox<String>(flight_log_max_values);
561 flight_log_max_value.setEditable(true);
562 flight_log_max_value.addItemListener(this);
563 pane.add(flight_log_max_value, c);
564 set_flight_log_max_tool_tip();
568 c = new GridBagConstraints();
569 c.gridx = 0; c.gridy = row;
571 c.fill = GridBagConstraints.NONE;
572 c.anchor = GridBagConstraints.LINE_START;
575 ignite_mode_label = new JLabel("Igniter Firing Mode:");
576 pane.add(ignite_mode_label, c);
578 c = new GridBagConstraints();
579 c.gridx = 4; c.gridy = row;
581 c.fill = GridBagConstraints.HORIZONTAL;
583 c.anchor = GridBagConstraints.LINE_START;
586 ignite_mode_value = new JComboBox<String>(ignite_mode_values);
587 ignite_mode_value.setEditable(false);
588 ignite_mode_value.addItemListener(this);
589 pane.add(ignite_mode_value, c);
590 set_ignite_mode_tool_tip();
593 /* Pad orientation */
594 c = new GridBagConstraints();
595 c.gridx = 0; c.gridy = row;
597 c.fill = GridBagConstraints.NONE;
598 c.anchor = GridBagConstraints.LINE_START;
601 pad_orientation_label = new JLabel("Pad Orientation:");
602 pane.add(pad_orientation_label, c);
604 c = new GridBagConstraints();
605 c.gridx = 4; c.gridy = row;
607 c.fill = GridBagConstraints.HORIZONTAL;
609 c.anchor = GridBagConstraints.LINE_START;
612 pad_orientation_value = new JComboBox<String>(pad_orientation_values);
613 pad_orientation_value.setEditable(false);
614 pad_orientation_value.addItemListener(this);
615 pane.add(pad_orientation_value, c);
616 set_pad_orientation_tool_tip();
620 c = new GridBagConstraints();
621 c.gridx = 0; c.gridy = row;
623 c.fill = GridBagConstraints.NONE;
624 c.anchor = GridBagConstraints.LINE_START;
627 beep_label = new JLabel("Beeper Frequency:");
628 pane.add(beep_label, c);
630 c = new GridBagConstraints();
631 c.gridx = 4; c.gridy = row;
633 c.fill = GridBagConstraints.HORIZONTAL;
635 c.anchor = GridBagConstraints.LINE_START;
638 beep_value = new JComboBox<String>(beep_values);
639 beep_value.setEditable(true);
640 beep_value.addItemListener(this);
641 pane.add(beep_value, c);
645 /* Tracker triger horiz distances */
646 c = new GridBagConstraints();
647 c.gridx = 0; c.gridy = row;
649 c.fill = GridBagConstraints.NONE;
650 c.anchor = GridBagConstraints.LINE_START;
653 tracker_horiz_label = new JLabel(get_tracker_horiz_label());
654 pane.add(tracker_horiz_label, c);
656 c = new GridBagConstraints();
657 c.gridx = 4; c.gridy = row;
659 c.fill = GridBagConstraints.HORIZONTAL;
661 c.anchor = GridBagConstraints.LINE_START;
664 tracker_horiz_value = new JComboBox<String>(tracker_horiz_values());
665 tracker_horiz_value.setEditable(true);
666 tracker_horiz_value.addItemListener(this);
667 pane.add(tracker_horiz_value, c);
670 /* Tracker triger vert distances */
671 c = new GridBagConstraints();
672 c.gridx = 0; c.gridy = row;
674 c.fill = GridBagConstraints.NONE;
675 c.anchor = GridBagConstraints.LINE_START;
678 tracker_vert_label = new JLabel(get_tracker_vert_label());
679 pane.add(tracker_vert_label, c);
681 c = new GridBagConstraints();
682 c.gridx = 4; c.gridy = row;
684 c.fill = GridBagConstraints.HORIZONTAL;
686 c.anchor = GridBagConstraints.LINE_START;
689 tracker_vert_value = new JComboBox<String>(tracker_vert_values());
690 tracker_vert_value.setEditable(true);
691 tracker_vert_value.addItemListener(this);
692 pane.add(tracker_vert_value, c);
693 set_tracker_tool_tip();
697 c = new GridBagConstraints();
698 c.gridx = 4; c.gridy = row;
700 c.fill = GridBagConstraints.HORIZONTAL;
701 c.anchor = GridBagConstraints.LINE_START;
704 pyro = new JButton("Configure Pyro Channels");
706 pyro.addActionListener(this);
707 pyro.setActionCommand("Pyro");
711 c = new GridBagConstraints();
712 c.gridx = 0; c.gridy = row;
714 c.fill = GridBagConstraints.NONE;
715 c.anchor = GridBagConstraints.LINE_START;
717 save = new JButton("Save");
719 save.addActionListener(this);
720 save.setActionCommand("Save");
722 c = new GridBagConstraints();
723 c.gridx = 2; c.gridy = row;
725 c.fill = GridBagConstraints.NONE;
726 c.anchor = GridBagConstraints.CENTER;
728 reset = new JButton("Reset");
730 reset.addActionListener(this);
731 reset.setActionCommand("Reset");
733 c = new GridBagConstraints();
734 c.gridx = 4; c.gridy = row;
736 c.fill = GridBagConstraints.NONE;
737 c.anchor = GridBagConstraints.CENTER;
739 reboot = new JButton("Reboot");
741 reboot.addActionListener(this);
742 reboot.setActionCommand("Reboot");
744 c = new GridBagConstraints();
745 c.gridx = 6; c.gridy = row;
747 c.fill = GridBagConstraints.NONE;
748 c.anchor = GridBagConstraints.LINE_END;
750 close = new JButton("Close");
752 close.addActionListener(this);
753 close.setActionCommand("Close");
755 addWindowListener(new ConfigListener(this));
756 AltosPreferences.register_units_listener(this);
759 /* Once the initial values are set, the config code will show the dialog */
760 public void make_visible() {
762 setLocationRelativeTo(owner);
766 /* If any values have been changed, confirm before closing */
767 public boolean check_dirty(String operation) {
769 Object[] options = { String.format("%s anyway", operation), "Keep editing" };
771 i = JOptionPane.showOptionDialog(this,
772 String.format("Configuration modified. %s anyway?", operation),
773 "Configuration Modified",
774 JOptionPane.DEFAULT_OPTION,
775 JOptionPane.WARNING_MESSAGE,
776 null, options, options[1]);
785 save.setEnabled(true);
788 public void set_clean() {
790 save.setEnabled(false);
793 AltosConfigPyroUI pyro_ui;
795 public void dispose() {
798 AltosPreferences.unregister_units_listener(this);
802 /* Listen for events from our buttons */
803 public void actionPerformed(ActionEvent e) {
804 String cmd = e.getActionCommand();
806 if (cmd.equals("Pyro")) {
807 if (pyro_ui == null && pyros != null)
808 pyro_ui = new AltosConfigPyroUI(this, pyros);
810 pyro_ui.make_visible();
814 if (cmd.equals("Close") || cmd.equals("Reboot"))
815 if (!check_dirty(cmd))
817 listener.actionPerformed(e);
818 if (cmd.equals("Close") || cmd.equals("Reboot")) {
825 /* ItemListener interface method */
826 public void itemStateChanged(ItemEvent e) {
830 /* DocumentListener interface methods */
831 public void changedUpdate(DocumentEvent e) {
835 public void insertUpdate(DocumentEvent e) {
839 public void removeUpdate(DocumentEvent e) {
843 /* Let the config code hook on a listener */
844 public void addActionListener(ActionListener l) {
848 /* set and get all of the dialog values */
849 public void set_product(String product) {
850 radio_frequency_value.set_product(product);
851 product_value.setText(product);
852 set_pad_orientation_tool_tip();
853 set_flight_log_max_tool_tip();
856 public void set_version(String version) {
857 version_value.setText(version);
860 public void set_serial(int serial) {
861 radio_frequency_value.set_serial(serial);
862 serial_value.setText(String.format("%d", serial));
865 public void set_main_deploy(int new_main_deploy) {
866 main_deploy_value.setSelectedItem(AltosConvert.height.say(new_main_deploy));
867 main_deploy_value.setEnabled(new_main_deploy >= 0);
870 public int main_deploy() {
871 return (int) (AltosConvert.height.parse(main_deploy_value.getSelectedItem().toString()) + 0.5);
874 String get_main_deploy_label() {
875 return String.format("Main Deploy Altitude(%s):", AltosConvert.height.show_units());
878 String[] main_deploy_values() {
879 if (AltosConvert.imperial_units)
880 return main_deploy_values_ft;
882 return main_deploy_values_m;
885 void set_main_deploy_values() {
886 String[] v = main_deploy_values();
887 while (main_deploy_value.getItemCount() > 0)
888 main_deploy_value.removeItemAt(0);
889 for (int i = 0; i < v.length; i++)
890 main_deploy_value.addItem(v[i]);
891 main_deploy_value.setMaximumRowCount(v.length);
894 public void units_changed(boolean imperial_units) {
895 String v = main_deploy_value.getSelectedItem().toString();
896 main_deploy_label.setText(get_main_deploy_label());
897 set_main_deploy_values();
898 int m = (int) (AltosConvert.height.parse(v, !imperial_units) + 0.5);
901 if (tracker_horiz_value.isEnabled() && tracker_vert_value.isEnabled()) {
902 String th = tracker_horiz_value.getSelectedItem().toString();
903 String tv = tracker_vert_value.getSelectedItem().toString();
904 tracker_horiz_label.setText(get_tracker_horiz_label());
905 tracker_vert_label.setText(get_tracker_vert_label());
906 set_tracker_horiz_values();
907 set_tracker_vert_values();
909 (int) (AltosConvert.height.parse(th, !imperial_units) + 0.5),
910 (int) (AltosConvert.height.parse(tv, !imperial_units) + 0.5)
912 set_tracker_distances(t);
916 public void set_apogee_delay(int new_apogee_delay) {
917 apogee_delay_value.setSelectedItem(Integer.toString(new_apogee_delay));
918 apogee_delay_value.setEnabled(new_apogee_delay >= 0);
921 public int apogee_delay() {
922 return Integer.parseInt(apogee_delay_value.getSelectedItem().toString());
925 public void set_apogee_lockout(int new_apogee_lockout) {
926 apogee_lockout_value.setSelectedItem(Integer.toString(new_apogee_lockout));
927 apogee_lockout_value.setEnabled(new_apogee_lockout >= 0);
930 public int apogee_lockout() {
931 return Integer.parseInt(apogee_lockout_value.getSelectedItem().toString());
934 public void set_radio_frequency(double new_radio_frequency) {
935 radio_frequency_value.set_frequency(new_radio_frequency);
938 public double radio_frequency() {
939 return radio_frequency_value.frequency();
942 public void set_radio_calibration(int new_radio_calibration) {
943 radio_calibration_value.setVisible(new_radio_calibration >= 0);
944 if (new_radio_calibration < 0)
945 radio_calibration_value.setText("Disabled");
947 radio_calibration_value.setText(String.format("%d", new_radio_calibration));
950 public int radio_calibration() {
951 return Integer.parseInt(radio_calibration_value.getText());
954 public void set_radio_enable(int new_radio_enable) {
955 if (new_radio_enable >= 0) {
956 radio_enable_value.setSelected(new_radio_enable > 0);
957 radio_enable_value.setEnabled(true);
959 radio_enable_value.setSelected(true);
960 radio_enable_value.setVisible(radio_frequency() > 0);
961 radio_enable_value.setEnabled(false);
963 set_radio_enable_tool_tip();
966 public int radio_enable() {
967 if (radio_enable_value.isEnabled())
968 return radio_enable_value.isSelected() ? 1 : 0;
973 public void set_callsign(String new_callsign) {
974 callsign_value.setVisible(new_callsign != null);
975 callsign_value.setText(new_callsign);
978 public String callsign() {
979 return callsign_value.getText();
982 public void set_flight_log_max(int new_flight_log_max) {
983 flight_log_max_value.setSelectedItem(Integer.toString(new_flight_log_max));
984 set_flight_log_max_tool_tip();
987 public void set_flight_log_max_enabled(boolean enable) {
988 flight_log_max_value.setEnabled(enable);
989 set_flight_log_max_tool_tip();
992 public int flight_log_max() {
993 return Integer.parseInt(flight_log_max_value.getSelectedItem().toString());
996 public void set_flight_log_max_limit(int flight_log_max_limit) {
997 //boolean any_added = false;
998 flight_log_max_value.removeAllItems();
999 for (int i = 0; i < flight_log_max_values.length; i++) {
1000 if (Integer.parseInt(flight_log_max_values[i]) < flight_log_max_limit){
1001 flight_log_max_value.addItem(flight_log_max_values[i]);
1005 flight_log_max_value.addItem(String.format("%d", flight_log_max_limit));
1008 public void set_ignite_mode(int new_ignite_mode) {
1009 if (new_ignite_mode >= ignite_mode_values.length)
1010 new_ignite_mode = 0;
1011 if (new_ignite_mode < 0) {
1012 ignite_mode_value.setEnabled(false);
1013 new_ignite_mode = 0;
1015 ignite_mode_value.setEnabled(true);
1017 ignite_mode_value.setSelectedIndex(new_ignite_mode);
1018 set_ignite_mode_tool_tip();
1021 public int ignite_mode() {
1022 if (ignite_mode_value.isEnabled())
1023 return ignite_mode_value.getSelectedIndex();
1029 public void set_pad_orientation(int new_pad_orientation) {
1030 if (new_pad_orientation >= pad_orientation_values.length)
1031 new_pad_orientation = 0;
1032 if (new_pad_orientation < 0) {
1033 pad_orientation_value.setVisible(false);
1034 new_pad_orientation = 0;
1036 pad_orientation_value.setVisible(true);
1038 pad_orientation_value.setSelectedIndex(new_pad_orientation);
1039 set_pad_orientation_tool_tip();
1042 public int pad_orientation() {
1043 if (pad_orientation_value.isEnabled())
1044 return pad_orientation_value.getSelectedIndex();
1049 public void set_beep(int new_beep) {
1050 int new_freq = (int) Math.floor (AltosConvert.beep_value_to_freq(new_beep) + 0.5);
1051 for (int i = 0; i < beep_values.length; i++)
1052 if (new_beep == AltosConvert.beep_freq_to_value(Integer.parseInt(beep_values[i]))) {
1053 beep_value.setSelectedIndex(i);
1054 set_beep_tool_tip();
1057 beep_value.setSelectedItem(String.format("%d", new_freq));
1058 beep_value.setEnabled(new_beep >= 0);
1059 set_beep_tool_tip();
1063 if (beep_value.isEnabled())
1064 return AltosConvert.beep_freq_to_value(Integer.parseInt(beep_value.getSelectedItem().toString()));
1069 String[] tracker_horiz_values() {
1070 if (AltosConvert.imperial_units)
1071 return tracker_horiz_values_ft;
1073 return tracker_horiz_values_m;
1076 void set_tracker_horiz_values() {
1077 String[] v = tracker_horiz_values();
1078 while (tracker_horiz_value.getItemCount() > 0)
1079 tracker_horiz_value.removeItemAt(0);
1080 for (int i = 0; i < v.length; i++)
1081 tracker_horiz_value.addItem(v[i]);
1082 tracker_horiz_value.setMaximumRowCount(v.length);
1085 String get_tracker_horiz_label() {
1086 return String.format("Logging Trigger Horizontal (%s):", AltosConvert.height.show_units());
1089 String[] tracker_vert_values() {
1090 if (AltosConvert.imperial_units)
1091 return tracker_vert_values_ft;
1093 return tracker_vert_values_m;
1096 void set_tracker_vert_values() {
1097 String[] v = tracker_vert_values();
1098 while (tracker_vert_value.getItemCount() > 0)
1099 tracker_vert_value.removeItemAt(0);
1100 for (int i = 0; i < v.length; i++)
1101 tracker_vert_value.addItem(v[i]);
1102 tracker_vert_value.setMaximumRowCount(v.length);
1105 void set_tracker_tool_tip() {
1106 if (tracker_horiz_value.isEnabled())
1107 tracker_horiz_value.setToolTipText("How far the device must move before logging is enabled");
1109 tracker_horiz_value.setToolTipText("This device doesn't disable logging before motion");
1110 if (tracker_vert_value.isEnabled())
1111 tracker_vert_value.setToolTipText("How far the device must move before logging is enabled");
1113 tracker_vert_value.setToolTipText("This device doesn't disable logging before motion");
1116 String get_tracker_vert_label() {
1117 return String.format("Logging Trigger Vertical (%s):", AltosConvert.height.show_units());
1120 public void set_tracker_distances(int[] tracker_distances) {
1121 if (tracker_distances != null) {
1122 tracker_horiz_value.setSelectedItem(AltosConvert.height.say(tracker_distances[0]));
1123 tracker_vert_value.setSelectedItem(AltosConvert.height.say(tracker_distances[1]));
1124 tracker_horiz_value.setEnabled(true);
1125 tracker_vert_value.setEnabled(true);
1127 tracker_horiz_value.setEnabled(false);
1128 tracker_vert_value.setEnabled(false);
1132 public int[] tracker_distances() {
1133 if (tracker_horiz_value.isEnabled() && tracker_vert_value.isEnabled()) {
1135 (int) (AltosConvert.height.parse(tracker_horiz_value.getSelectedItem().toString()) + 0.5),
1136 (int) (AltosConvert.height.parse(tracker_vert_value.getSelectedItem().toString()) + 0.5),
1143 public void set_pyros(AltosPyro[] new_pyros) {
1145 pyro.setVisible(pyros != null);
1146 if (pyros != null && pyro_ui != null)
1147 pyro_ui.set_pyros(pyros);
1150 public AltosPyro[] pyros() throws AltosConfigDataException {
1151 if (pyro_ui != null)
1152 pyros = pyro_ui.get_pyros();
1156 public void set_aprs_interval(int new_aprs_interval) {
1159 if (new_aprs_interval <= 0)
1162 s = Integer.toString(new_aprs_interval);
1163 aprs_interval_value.setSelectedItem(s);
1164 aprs_interval_value.setVisible(new_aprs_interval >= 0);
1165 set_aprs_interval_tool_tip();
1168 public int aprs_interval() {
1169 String s = aprs_interval_value.getSelectedItem().toString();
1171 if (s.equals("Disabled"))
1173 return Integer.parseInt(s);