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;
56 JComboBox<String> main_deploy_value;
57 JComboBox<String> apogee_delay_value;
58 JComboBox<String> apogee_lockout_value;
59 AltosFreqList radio_frequency_value;
60 JTextField radio_calibration_value;
61 JRadioButton radio_enable_value;
62 JComboBox<String> aprs_interval_value;
63 JComboBox<String> flight_log_max_value;
64 JComboBox<String> ignite_mode_value;
65 JComboBox<String> pad_orientation_value;
66 JTextField callsign_value;
67 JComboBox<String> beep_value;
78 ActionListener listener;
80 static String[] main_deploy_values_m = {
81 "100", "150", "200", "250", "300", "350",
85 static String[] main_deploy_values_ft = {
86 "250", "500", "750", "1000", "1250", "1500",
90 static String[] apogee_delay_values = {
91 "0", "1", "2", "3", "4", "5"
94 static String[] apogee_lockout_values = {
95 "0", "5", "10", "15", "20"
98 static String[] flight_log_max_values = {
99 "64", "128", "192", "256", "320",
100 "384", "448", "512", "576", "640",
101 "704", "768", "832", "896", "960",
104 static String[] ignite_mode_values = {
110 static String[] aprs_interval_values = {
117 static String[] beep_values = {
123 static String[] pad_orientation_values = {
128 /* A window listener to catch closing events and tell the config code */
129 class ConfigListener extends WindowAdapter {
132 public ConfigListener(AltosConfigUI this_ui) {
136 public void windowClosing(WindowEvent e) {
137 ui.actionPerformed(new ActionEvent(e.getSource(),
138 ActionEvent.ACTION_PERFORMED,
143 boolean is_telemini_v1() {
144 String product = product_value.getText();
145 return product != null && product.startsWith("TeleMini-v1");
148 boolean is_telemini() {
149 String product = product_value.getText();
150 return product != null && product.startsWith("TeleMini");
153 boolean is_easymini() {
154 String product = product_value.getText();
155 return product != null && product.startsWith("EasyMini");
158 boolean is_telemetrum() {
159 String product = product_value.getText();
160 return product != null && product.startsWith("TeleMetrum");
163 void set_radio_calibration_tool_tip() {
164 if (radio_calibration_value.isEnabled())
165 radio_calibration_value.setToolTipText("Tune radio output to match desired frequency");
167 radio_calibration_value.setToolTipText("Cannot tune radio while connected over packet mode");
170 void set_radio_enable_tool_tip() {
171 if (radio_enable_value.isEnabled())
172 radio_enable_value.setToolTipText("Enable/Disable telemetry and RDF transmissions");
174 radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
177 void set_aprs_interval_tool_tip() {
178 if (aprs_interval_value.isEnabled())
179 aprs_interval_value.setToolTipText("Enable APRS and set the interval between APRS reports");
181 aprs_interval_value.setToolTipText("Hardware doesn't support APRS");
184 void set_flight_log_max_tool_tip() {
185 if (flight_log_max_value.isEnabled())
186 flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)");
188 if (is_telemini_v1())
189 flight_log_max_value.setToolTipText("TeleMini-v1 stores only one flight");
191 flight_log_max_value.setToolTipText("Cannot set max value with flight logs in memory");
195 void set_ignite_mode_tool_tip() {
196 if (ignite_mode_value.isEnabled())
197 ignite_mode_value.setToolTipText("Select when igniters will be fired");
199 ignite_mode_value.setToolTipText("Older firmware could not select ignite mode");
202 void set_pad_orientation_tool_tip() {
203 if (pad_orientation_value.isEnabled())
204 pad_orientation_value.setToolTipText("How will the computer be mounted in the airframe");
207 pad_orientation_value.setToolTipText("Older TeleMetrum firmware must fly antenna forward");
208 else if (is_telemini() || is_easymini())
209 pad_orientation_value.setToolTipText("TeleMini and EasyMini don't care how they are mounted");
211 pad_orientation_value.setToolTipText("Can't select orientation");
215 void set_beep_tool_tip() {
216 if (beep_value.isEnabled())
217 beep_value.setToolTipText("What frequency the beeper will sound at");
219 beep_value.setToolTipText("Older firmware could not select beeper frequency");
222 /* Build the UI using a grid bag */
223 public AltosConfigUI(JFrame in_owner, boolean remote) {
224 super (in_owner, "Configure Flight Computer", false);
227 GridBagConstraints c;
230 Insets il = new Insets(4,4,4,4);
231 Insets ir = new Insets(4,4,4,4);
233 pane = getContentPane();
234 pane.setLayout(new GridBagLayout());
237 c = new GridBagConstraints();
238 c.gridx = 0; c.gridy = row;
240 c.fill = GridBagConstraints.NONE;
241 c.anchor = GridBagConstraints.LINE_START;
243 product_label = new JLabel("Product:");
244 pane.add(product_label, c);
246 c = new GridBagConstraints();
247 c.gridx = 4; c.gridy = row;
249 c.fill = GridBagConstraints.HORIZONTAL;
251 c.anchor = GridBagConstraints.LINE_START;
253 product_value = new JLabel("");
254 pane.add(product_value, c);
258 c = new GridBagConstraints();
259 c.gridx = 0; c.gridy = row;
261 c.fill = GridBagConstraints.NONE;
262 c.anchor = GridBagConstraints.LINE_START;
265 version_label = new JLabel("Software version:");
266 pane.add(version_label, c);
268 c = new GridBagConstraints();
269 c.gridx = 4; c.gridy = row;
271 c.fill = GridBagConstraints.HORIZONTAL;
273 c.anchor = GridBagConstraints.LINE_START;
276 version_value = new JLabel("");
277 pane.add(version_value, c);
281 c = new GridBagConstraints();
282 c.gridx = 0; c.gridy = row;
284 c.fill = GridBagConstraints.NONE;
285 c.anchor = GridBagConstraints.LINE_START;
288 serial_label = new JLabel("Serial:");
289 pane.add(serial_label, c);
291 c = new GridBagConstraints();
292 c.gridx = 4; c.gridy = row;
294 c.fill = GridBagConstraints.HORIZONTAL;
296 c.anchor = GridBagConstraints.LINE_START;
299 serial_value = new JLabel("");
300 pane.add(serial_value, c);
304 c = new GridBagConstraints();
305 c.gridx = 0; c.gridy = row;
307 c.fill = GridBagConstraints.NONE;
308 c.anchor = GridBagConstraints.LINE_START;
311 main_deploy_label = new JLabel(get_main_deploy_label());
312 pane.add(main_deploy_label, c);
314 c = new GridBagConstraints();
315 c.gridx = 4; c.gridy = row;
317 c.fill = GridBagConstraints.HORIZONTAL;
319 c.anchor = GridBagConstraints.LINE_START;
322 main_deploy_value = new JComboBox<String>(main_deploy_values());
323 main_deploy_value.setEditable(true);
324 main_deploy_value.addItemListener(this);
325 pane.add(main_deploy_value, c);
326 main_deploy_value.setToolTipText("Height above pad altitude to fire main charge");
330 c = new GridBagConstraints();
331 c.gridx = 0; c.gridy = row;
333 c.fill = GridBagConstraints.NONE;
334 c.anchor = GridBagConstraints.LINE_START;
337 apogee_delay_label = new JLabel("Apogee Delay(s):");
338 pane.add(apogee_delay_label, c);
340 c = new GridBagConstraints();
341 c.gridx = 4; c.gridy = row;
343 c.fill = GridBagConstraints.HORIZONTAL;
345 c.anchor = GridBagConstraints.LINE_START;
348 apogee_delay_value = new JComboBox<String>(apogee_delay_values);
349 apogee_delay_value.setEditable(true);
350 apogee_delay_value.addItemListener(this);
351 pane.add(apogee_delay_value, c);
352 apogee_delay_value.setToolTipText("Delay after apogee before charge fires");
356 c = new GridBagConstraints();
357 c.gridx = 0; c.gridy = row;
359 c.fill = GridBagConstraints.NONE;
360 c.anchor = GridBagConstraints.LINE_START;
363 apogee_lockout_label = new JLabel("Apogee Lockout(s):");
364 pane.add(apogee_lockout_label, c);
366 c = new GridBagConstraints();
367 c.gridx = 4; c.gridy = row;
369 c.fill = GridBagConstraints.HORIZONTAL;
371 c.anchor = GridBagConstraints.LINE_START;
374 apogee_lockout_value = new JComboBox<String>(apogee_lockout_values);
375 apogee_lockout_value.setEditable(true);
376 apogee_lockout_value.addItemListener(this);
377 pane.add(apogee_lockout_value, c);
378 apogee_lockout_value.setToolTipText("Time after boost while apogee detection is locked out");
382 c = new GridBagConstraints();
383 c.gridx = 0; c.gridy = row;
385 c.fill = GridBagConstraints.NONE;
386 c.anchor = GridBagConstraints.LINE_START;
389 radio_frequency_label = new JLabel("Frequency:");
390 pane.add(radio_frequency_label, c);
392 c = new GridBagConstraints();
393 c.gridx = 4; c.gridy = row;
395 c.fill = GridBagConstraints.HORIZONTAL;
397 c.anchor = GridBagConstraints.LINE_START;
400 radio_frequency_value = new AltosFreqList();
401 radio_frequency_value.addItemListener(this);
402 pane.add(radio_frequency_value, c);
403 radio_frequency_value.setToolTipText("Telemetry, RDF and packet frequency");
406 /* Radio Calibration */
407 c = new GridBagConstraints();
408 c.gridx = 0; c.gridy = row;
410 c.fill = GridBagConstraints.NONE;
411 c.anchor = GridBagConstraints.LINE_START;
414 radio_calibration_label = new JLabel("RF Calibration:");
415 pane.add(radio_calibration_label, c);
417 c = new GridBagConstraints();
418 c.gridx = 4; c.gridy = row;
420 c.fill = GridBagConstraints.HORIZONTAL;
422 c.anchor = GridBagConstraints.LINE_START;
425 radio_calibration_value = new JTextField(String.format("%d", 1186611));
426 radio_calibration_value.getDocument().addDocumentListener(this);
428 radio_calibration_value.setEnabled(false);
429 pane.add(radio_calibration_value, c);
430 set_radio_calibration_tool_tip();
434 c = new GridBagConstraints();
435 c.gridx = 0; c.gridy = row;
437 c.fill = GridBagConstraints.NONE;
438 c.anchor = GridBagConstraints.LINE_START;
441 radio_enable_label = new JLabel("Telemetry/RDF/APRS Enable:");
442 pane.add(radio_enable_label, c);
444 c = new GridBagConstraints();
445 c.gridx = 4; c.gridy = row;
447 c.fill = GridBagConstraints.HORIZONTAL;
449 c.anchor = GridBagConstraints.LINE_START;
452 radio_enable_value = new JRadioButton("Enabled");
453 radio_enable_value.addItemListener(this);
454 pane.add(radio_enable_value, c);
455 set_radio_enable_tool_tip();
459 c = new GridBagConstraints();
460 c.gridx = 0; c.gridy = row;
462 c.fill = GridBagConstraints.NONE;
463 c.anchor = GridBagConstraints.LINE_START;
466 aprs_interval_label = new JLabel("APRS Interval(s):");
467 pane.add(aprs_interval_label, c);
469 c = new GridBagConstraints();
470 c.gridx = 4; c.gridy = row;
472 c.fill = GridBagConstraints.HORIZONTAL;
474 c.anchor = GridBagConstraints.LINE_START;
477 aprs_interval_value = new JComboBox<String>(aprs_interval_values);
478 aprs_interval_value.setEditable(true);
479 aprs_interval_value.addItemListener(this);
480 pane.add(aprs_interval_value, c);
481 set_aprs_interval_tool_tip();
485 c = new GridBagConstraints();
486 c.gridx = 0; c.gridy = row;
488 c.fill = GridBagConstraints.NONE;
489 c.anchor = GridBagConstraints.LINE_START;
492 callsign_label = new JLabel("Callsign:");
493 pane.add(callsign_label, c);
495 c = new GridBagConstraints();
496 c.gridx = 4; c.gridy = row;
498 c.fill = GridBagConstraints.HORIZONTAL;
500 c.anchor = GridBagConstraints.LINE_START;
503 callsign_value = new JTextField(AltosUIPreferences.callsign());
504 callsign_value.getDocument().addDocumentListener(this);
505 pane.add(callsign_value, c);
506 callsign_value.setToolTipText("Callsign reported in telemetry data");
510 c = new GridBagConstraints();
511 c.gridx = 0; c.gridy = row;
513 c.fill = GridBagConstraints.NONE;
514 c.anchor = GridBagConstraints.LINE_START;
517 flight_log_max_label = new JLabel("Maximum Flight Log Size:");
518 pane.add(flight_log_max_label, c);
520 c = new GridBagConstraints();
521 c.gridx = 4; c.gridy = row;
523 c.fill = GridBagConstraints.HORIZONTAL;
525 c.anchor = GridBagConstraints.LINE_START;
528 flight_log_max_value = new JComboBox<String>(flight_log_max_values);
529 flight_log_max_value.setEditable(true);
530 flight_log_max_value.addItemListener(this);
531 pane.add(flight_log_max_value, c);
532 set_flight_log_max_tool_tip();
536 c = new GridBagConstraints();
537 c.gridx = 0; c.gridy = row;
539 c.fill = GridBagConstraints.NONE;
540 c.anchor = GridBagConstraints.LINE_START;
543 ignite_mode_label = new JLabel("Igniter Firing Mode:");
544 pane.add(ignite_mode_label, c);
546 c = new GridBagConstraints();
547 c.gridx = 4; c.gridy = row;
549 c.fill = GridBagConstraints.HORIZONTAL;
551 c.anchor = GridBagConstraints.LINE_START;
554 ignite_mode_value = new JComboBox<String>(ignite_mode_values);
555 ignite_mode_value.setEditable(false);
556 ignite_mode_value.addItemListener(this);
557 pane.add(ignite_mode_value, c);
558 set_ignite_mode_tool_tip();
561 /* Pad orientation */
562 c = new GridBagConstraints();
563 c.gridx = 0; c.gridy = row;
565 c.fill = GridBagConstraints.NONE;
566 c.anchor = GridBagConstraints.LINE_START;
569 pad_orientation_label = new JLabel("Pad Orientation:");
570 pane.add(pad_orientation_label, c);
572 c = new GridBagConstraints();
573 c.gridx = 4; c.gridy = row;
575 c.fill = GridBagConstraints.HORIZONTAL;
577 c.anchor = GridBagConstraints.LINE_START;
580 pad_orientation_value = new JComboBox<String>(pad_orientation_values);
581 pad_orientation_value.setEditable(false);
582 pad_orientation_value.addItemListener(this);
583 pane.add(pad_orientation_value, c);
584 set_pad_orientation_tool_tip();
588 c = new GridBagConstraints();
589 c.gridx = 0; c.gridy = row;
591 c.fill = GridBagConstraints.NONE;
592 c.anchor = GridBagConstraints.LINE_START;
595 beep_label = new JLabel("Beeper Frequency:");
596 pane.add(beep_label, c);
598 c = new GridBagConstraints();
599 c.gridx = 4; c.gridy = row;
601 c.fill = GridBagConstraints.HORIZONTAL;
603 c.anchor = GridBagConstraints.LINE_START;
606 beep_value = new JComboBox<String>(beep_values);
607 beep_value.setEditable(true);
608 beep_value.addItemListener(this);
609 pane.add(beep_value, c);
614 c = new GridBagConstraints();
615 c.gridx = 4; c.gridy = row;
617 c.fill = GridBagConstraints.HORIZONTAL;
618 c.anchor = GridBagConstraints.LINE_START;
621 pyro = new JButton("Configure Pyro Channels");
623 pyro.addActionListener(this);
624 pyro.setActionCommand("Pyro");
628 c = new GridBagConstraints();
629 c.gridx = 0; c.gridy = row;
631 c.fill = GridBagConstraints.NONE;
632 c.anchor = GridBagConstraints.LINE_START;
634 save = new JButton("Save");
636 save.addActionListener(this);
637 save.setActionCommand("Save");
639 c = new GridBagConstraints();
640 c.gridx = 2; c.gridy = row;
642 c.fill = GridBagConstraints.NONE;
643 c.anchor = GridBagConstraints.CENTER;
645 reset = new JButton("Reset");
647 reset.addActionListener(this);
648 reset.setActionCommand("Reset");
650 c = new GridBagConstraints();
651 c.gridx = 4; c.gridy = row;
653 c.fill = GridBagConstraints.NONE;
654 c.anchor = GridBagConstraints.CENTER;
656 reboot = new JButton("Reboot");
658 reboot.addActionListener(this);
659 reboot.setActionCommand("Reboot");
661 c = new GridBagConstraints();
662 c.gridx = 6; c.gridy = row;
664 c.fill = GridBagConstraints.NONE;
665 c.anchor = GridBagConstraints.LINE_END;
667 close = new JButton("Close");
669 close.addActionListener(this);
670 close.setActionCommand("Close");
672 addWindowListener(new ConfigListener(this));
673 AltosPreferences.register_units_listener(this);
676 /* Once the initial values are set, the config code will show the dialog */
677 public void make_visible() {
679 setLocationRelativeTo(owner);
683 /* If any values have been changed, confirm before closing */
684 public boolean check_dirty(String operation) {
686 Object[] options = { String.format("%s anyway", operation), "Keep editing" };
688 i = JOptionPane.showOptionDialog(this,
689 String.format("Configuration modified. %s anyway?", operation),
690 "Configuration Modified",
691 JOptionPane.DEFAULT_OPTION,
692 JOptionPane.WARNING_MESSAGE,
693 null, options, options[1]);
702 save.setEnabled(true);
705 public void set_clean() {
707 save.setEnabled(false);
710 AltosConfigPyroUI pyro_ui;
712 public void dispose() {
715 AltosPreferences.unregister_units_listener(this);
719 /* Listen for events from our buttons */
720 public void actionPerformed(ActionEvent e) {
721 String cmd = e.getActionCommand();
723 if (cmd.equals("Pyro")) {
724 if (pyro_ui == null && pyros != null)
725 pyro_ui = new AltosConfigPyroUI(this, pyros);
727 pyro_ui.make_visible();
731 if (cmd.equals("Close") || cmd.equals("Reboot"))
732 if (!check_dirty(cmd))
734 listener.actionPerformed(e);
735 if (cmd.equals("Close") || cmd.equals("Reboot")) {
742 /* ItemListener interface method */
743 public void itemStateChanged(ItemEvent e) {
747 /* DocumentListener interface methods */
748 public void changedUpdate(DocumentEvent e) {
752 public void insertUpdate(DocumentEvent e) {
756 public void removeUpdate(DocumentEvent e) {
760 /* Let the config code hook on a listener */
761 public void addActionListener(ActionListener l) {
765 /* set and get all of the dialog values */
766 public void set_product(String product) {
767 radio_frequency_value.set_product(product);
768 product_value.setText(product);
769 set_pad_orientation_tool_tip();
770 set_flight_log_max_tool_tip();
773 public void set_version(String version) {
774 version_value.setText(version);
777 public void set_serial(int serial) {
778 radio_frequency_value.set_serial(serial);
779 serial_value.setText(String.format("%d", serial));
782 public void set_main_deploy(int new_main_deploy) {
783 main_deploy_value.setSelectedItem(AltosConvert.height.say(new_main_deploy));
784 main_deploy_value.setEnabled(new_main_deploy >= 0);
787 public int main_deploy() {
788 return (int) (AltosConvert.height.parse(main_deploy_value.getSelectedItem().toString()) + 0.5);
791 String get_main_deploy_label() {
792 return String.format("Main Deploy Altitude(%s):", AltosConvert.height.show_units());
795 String[] main_deploy_values() {
796 if (AltosConvert.imperial_units)
797 return main_deploy_values_ft;
799 return main_deploy_values_m;
802 void set_main_deploy_values() {
803 String[] v = main_deploy_values();
804 while (main_deploy_value.getItemCount() > 0)
805 main_deploy_value.removeItemAt(0);
806 for (int i = 0; i < v.length; i++)
807 main_deploy_value.addItem(v[i]);
808 main_deploy_value.setMaximumRowCount(v.length);
811 public void units_changed(boolean imperial_units) {
812 String v = main_deploy_value.getSelectedItem().toString();
813 main_deploy_label.setText(get_main_deploy_label());
814 set_main_deploy_values();
815 int m = (int) (AltosConvert.height.parse(v, !imperial_units) + 0.5);
819 public void set_apogee_delay(int new_apogee_delay) {
820 apogee_delay_value.setSelectedItem(Integer.toString(new_apogee_delay));
821 apogee_delay_value.setEnabled(new_apogee_delay >= 0);
824 public int apogee_delay() {
825 return Integer.parseInt(apogee_delay_value.getSelectedItem().toString());
828 public void set_apogee_lockout(int new_apogee_lockout) {
829 apogee_lockout_value.setSelectedItem(Integer.toString(new_apogee_lockout));
830 apogee_lockout_value.setEnabled(new_apogee_lockout >= 0);
833 public int apogee_lockout() {
834 return Integer.parseInt(apogee_lockout_value.getSelectedItem().toString());
837 public void set_radio_frequency(double new_radio_frequency) {
838 radio_frequency_value.set_frequency(new_radio_frequency);
841 public double radio_frequency() {
842 return radio_frequency_value.frequency();
845 public void set_radio_calibration(int new_radio_calibration) {
846 radio_calibration_value.setVisible(new_radio_calibration >= 0);
847 if (new_radio_calibration < 0)
848 radio_calibration_value.setText("Disabled");
850 radio_calibration_value.setText(String.format("%d", new_radio_calibration));
853 public int radio_calibration() {
854 return Integer.parseInt(radio_calibration_value.getText());
857 public void set_radio_enable(int new_radio_enable) {
858 if (new_radio_enable >= 0) {
859 radio_enable_value.setSelected(new_radio_enable > 0);
860 radio_enable_value.setEnabled(true);
862 radio_enable_value.setSelected(true);
863 radio_enable_value.setVisible(radio_frequency() > 0);
864 radio_enable_value.setEnabled(false);
866 set_radio_enable_tool_tip();
869 public int radio_enable() {
870 if (radio_enable_value.isEnabled())
871 return radio_enable_value.isSelected() ? 1 : 0;
876 public void set_callsign(String new_callsign) {
877 callsign_value.setVisible(new_callsign != null);
878 callsign_value.setText(new_callsign);
881 public String callsign() {
882 return callsign_value.getText();
885 public void set_flight_log_max(int new_flight_log_max) {
886 flight_log_max_value.setSelectedItem(Integer.toString(new_flight_log_max));
887 set_flight_log_max_tool_tip();
890 public void set_flight_log_max_enabled(boolean enable) {
891 flight_log_max_value.setEnabled(enable);
892 set_flight_log_max_tool_tip();
895 public int flight_log_max() {
896 return Integer.parseInt(flight_log_max_value.getSelectedItem().toString());
899 public void set_flight_log_max_limit(int flight_log_max_limit) {
900 //boolean any_added = false;
901 flight_log_max_value.removeAllItems();
902 for (int i = 0; i < flight_log_max_values.length; i++) {
903 if (Integer.parseInt(flight_log_max_values[i]) < flight_log_max_limit){
904 flight_log_max_value.addItem(flight_log_max_values[i]);
908 flight_log_max_value.addItem(String.format("%d", flight_log_max_limit));
911 public void set_ignite_mode(int new_ignite_mode) {
912 if (new_ignite_mode >= ignite_mode_values.length)
914 if (new_ignite_mode < 0) {
915 ignite_mode_value.setEnabled(false);
918 ignite_mode_value.setEnabled(true);
920 ignite_mode_value.setSelectedIndex(new_ignite_mode);
921 set_ignite_mode_tool_tip();
924 public int ignite_mode() {
925 if (ignite_mode_value.isEnabled())
926 return ignite_mode_value.getSelectedIndex();
932 public void set_pad_orientation(int new_pad_orientation) {
933 if (new_pad_orientation >= pad_orientation_values.length)
934 new_pad_orientation = 0;
935 if (new_pad_orientation < 0) {
936 pad_orientation_value.setVisible(false);
937 new_pad_orientation = 0;
939 pad_orientation_value.setVisible(true);
941 pad_orientation_value.setSelectedIndex(new_pad_orientation);
942 set_pad_orientation_tool_tip();
945 public int pad_orientation() {
946 if (pad_orientation_value.isEnabled())
947 return pad_orientation_value.getSelectedIndex();
952 public void set_beep(int new_beep) {
953 int new_freq = (int) Math.floor (AltosConvert.beep_value_to_freq(new_beep) + 0.5);
954 for (int i = 0; i < beep_values.length; i++)
955 if (new_beep == AltosConvert.beep_freq_to_value(Integer.parseInt(beep_values[i]))) {
956 beep_value.setSelectedIndex(i);
960 beep_value.setSelectedItem(String.format("%d", new_freq));
961 beep_value.setEnabled(new_beep >= 0);
966 if (beep_value.isEnabled())
967 return AltosConvert.beep_freq_to_value(Integer.parseInt(beep_value.getSelectedItem().toString()));
972 public void set_pyros(AltosPyro[] new_pyros) {
974 pyro.setVisible(pyros != null);
975 if (pyros != null && pyro_ui != null)
976 pyro_ui.set_pyros(pyros);
979 public AltosPyro[] pyros() {
981 pyros = pyro_ui.get_pyros();
985 public void set_aprs_interval(int new_aprs_interval) {
988 if (new_aprs_interval <= 0)
991 s = Integer.toString(new_aprs_interval);
992 aprs_interval_value.setSelectedItem(s);
993 aprs_interval_value.setVisible(new_aprs_interval >= 0);
994 set_aprs_interval_tool_tip();
997 public int aprs_interval() {
998 String s = aprs_interval_value.getSelectedItem().toString();
1000 if (s.equals("Disabled"))
1002 return Integer.parseInt(s);