X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosui%2FAltosConfigFCUI.java;h=2eb6ae752c73f70ba7eed833ebce4ff1ab95eda2;hb=f32488556ce25e439fbab941f8019db639824f98;hp=c0c37254673188fad2026a90cba7d591a062a2b9;hpb=5fdce5b4a70ae59f8ac1ca10d9fadbbbd62412f3;p=fw%2Faltos diff --git a/altosui/AltosConfigFCUI.java b/altosui/AltosConfigFCUI.java index c0c37254..2eb6ae75 100644 --- a/altosui/AltosConfigFCUI.java +++ b/altosui/AltosConfigFCUI.java @@ -23,8 +23,8 @@ import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import java.text.*; -import org.altusmetrum.altoslib_12.*; -import org.altusmetrum.altosuilib_12.*; +import org.altusmetrum.altoslib_14.*; +import org.altusmetrum.altosuilib_14.*; public class AltosConfigFCUI extends AltosUIDialog @@ -46,9 +46,12 @@ public class AltosConfigFCUI JLabel aprs_interval_label; JLabel aprs_ssid_label; JLabel aprs_format_label; + JLabel aprs_offset_label; JLabel flight_log_max_label; JLabel ignite_mode_label; JLabel pad_orientation_label; + JLabel accel_plus_label; + JLabel accel_minus_label; JLabel callsign_label; JLabel beep_label; JLabel tracker_motion_label; @@ -70,15 +73,19 @@ public class AltosConfigFCUI JComboBox aprs_interval_value; JComboBox aprs_ssid_value; JComboBox aprs_format_value; + JComboBox aprs_offset_value; JComboBox flight_log_max_value; JComboBox ignite_mode_value; JComboBox pad_orientation_value; + JTextField accel_plus_value; + JTextField accel_minus_value; JTextField callsign_value; JComboBox beep_value; JComboBox tracker_motion_value; JComboBox tracker_interval_value; JButton pyro; + JButton accel_cal; JButton save; JButton reset; @@ -125,6 +132,10 @@ public class AltosConfigFCUI 0, 1, 2 ,3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + static Integer[] aprs_offset_values = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18 + }; + static String[] beep_values = { "3750", "4000", @@ -231,6 +242,15 @@ public class AltosConfigFCUI aprs_format_value.setToolTipText("Hardware doesn't support APRS"); } + void set_aprs_offset_tool_tip() { + if (aprs_offset_value.isVisible()) + aprs_offset_value.setToolTipText("Set the APRS offset from top of minute"); + else if (aprs_offset_value.isVisible()) + aprs_offset_value.setToolTipText("Software version doesn't support setting the APRS offset"); + else + aprs_offset_value.setToolTipText("Hardware doesn't support APRS"); + } + void set_flight_log_max_tool_tip() { if (flight_log_max_value.isVisible()) flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)"); @@ -250,9 +270,9 @@ public class AltosConfigFCUI } void set_pad_orientation_tool_tip() { - if (pad_orientation_value.isVisible()) + if (pad_orientation_value.isVisible()) { pad_orientation_value.setToolTipText("How will the computer be mounted in the airframe"); - else { + } else { if (is_telemetrum()) pad_orientation_value.setToolTipText("Older TeleMetrum firmware must fly antenna forward"); else if (is_telemini() || is_easymini()) @@ -262,6 +282,16 @@ public class AltosConfigFCUI } } + void set_accel_tool_tips() { + if (accel_plus_value.isVisible()) { + accel_plus_value.setToolTipText("Pad acceleration value in flight orientation"); + accel_minus_value.setToolTipText("Upside-down acceleration value"); + } else { + accel_plus_value.setToolTipText("No accelerometer"); + accel_minus_value.setToolTipText("No accelerometer"); + } + } + void set_beep_tool_tip() { if (beep_value.isVisible()) beep_value.setToolTipText("What frequency the beeper will sound at"); @@ -425,7 +455,7 @@ public class AltosConfigFCUI apogee_lockout_value.setEditable(true); apogee_lockout_value.addItemListener(this); pane.add(apogee_lockout_value, c); - apogee_lockout_value.setToolTipText("Time after boost while apogee detection is locked out"); + apogee_lockout_value.setToolTipText("Time after launch while apogee detection is locked out"); row++; /* Frequency */ @@ -606,6 +636,33 @@ public class AltosConfigFCUI set_aprs_format_tool_tip(); row++; + /* APRS offset */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + aprs_offset_label = new JLabel("APRS offset:"); + pane.add(aprs_offset_label, c); + + c = new GridBagConstraints(); + c.gridx = 4; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + aprs_offset_value = new JComboBox(aprs_offset_values); + aprs_offset_value.setEditable(false); + aprs_offset_value.addItemListener(this); + aprs_offset_value.setMaximumRowCount(aprs_offset_values.length); + pane.add(aprs_offset_value, c); + set_aprs_offset_tool_tip(); + row++; + /* Callsign */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = row; @@ -709,6 +766,57 @@ public class AltosConfigFCUI set_pad_orientation_tool_tip(); row++; + /* Accel plus */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + accel_plus_label = new JLabel("Accel Plus:"); + pane.add(accel_plus_label, c); + + c = new GridBagConstraints(); + c.gridx = 4; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + accel_plus_value = new JTextField(10); + accel_plus_value.setEditable(true); + accel_plus_value.getDocument().addDocumentListener(this); + pane.add(accel_plus_value, c); + row++; + + /* Accel minus */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + accel_minus_label = new JLabel("Accel Minus:"); + pane.add(accel_minus_label, c); + + c = new GridBagConstraints(); + c.gridx = 4; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + accel_minus_value = new JTextField(10); + accel_minus_value.setEditable(true); + accel_minus_value.getDocument().addDocumentListener(this); + pane.add(accel_minus_value, c); + row++; + set_accel_tool_tips(); + /* Beeper */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = row; @@ -800,6 +908,20 @@ public class AltosConfigFCUI pyro.setActionCommand("Pyro"); row++; + /* Accel cal */ + c = new GridBagConstraints(); + c.gridx = 5; c.gridy = row; + c.gridwidth = 5; + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + accel_cal = new JButton("Calibrate Accelerometer"); + pane.add(accel_cal, c); + accel_cal.addActionListener(this); + accel_cal.setActionCommand("Accel"); + row++; + /* Buttons */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = row; @@ -873,7 +995,7 @@ public class AltosConfigFCUI return true; } - void set_dirty() { + public void set_dirty() { dirty = true; save.setEnabled(true); } @@ -912,7 +1034,8 @@ public class AltosConfigFCUI setVisible(false); dispose(); } - set_clean(); + if (cmd.equals("Save") || cmd.equals("Reset")) + set_clean(); } /* ItemListener interface method */ @@ -943,6 +1066,7 @@ public class AltosConfigFCUI radio_frequency_value.set_product(product); product_value.setText(product); set_pad_orientation_tool_tip(); + set_accel_tool_tips(); set_flight_log_max_tool_tip(); } @@ -1196,6 +1320,7 @@ public class AltosConfigFCUI } pad_orientation_value.setVisible(new_pad_orientation != AltosLib.MISSING); pad_orientation_label.setVisible(new_pad_orientation != AltosLib.MISSING); + accel_cal.setVisible(new_pad_orientation != AltosLib.MISSING); set_pad_orientation_tool_tip(); } @@ -1207,6 +1332,31 @@ public class AltosConfigFCUI return AltosLib.MISSING; } + public void set_accel_cal(int accel_plus, int accel_minus) { + if (accel_plus != AltosLib.MISSING) { + accel_plus_value.setText(String.format("%d", accel_plus)); + accel_minus_value.setText(String.format("%d", accel_minus)); + } + accel_plus_value.setVisible(accel_plus != AltosLib.MISSING); + accel_plus_label.setVisible(accel_plus != AltosLib.MISSING); + accel_minus_value.setVisible(accel_minus != AltosLib.MISSING); + accel_minus_label.setVisible(accel_minus != AltosLib.MISSING); + + set_accel_tool_tips(); + } + + public int accel_cal_plus() { + if (accel_plus_value.isVisible()) + return Integer.parseInt(accel_plus_value.getText()); + return AltosLib.MISSING; + } + + public int accel_cal_minus() { + if (accel_minus_value.isVisible()) + return Integer.parseInt(accel_minus_value.getText()); + return AltosLib.MISSING; + } + public void set_beep(int new_beep) { if (new_beep != AltosLib.MISSING) { int new_freq = (int) Math.floor (AltosConvert.beep_value_to_freq(new_beep) + 0.5); @@ -1319,20 +1469,29 @@ public class AltosConfigFCUI return pyro_firing_time; } + private String aprs_interval_string(int interval) { + if (interval == 0) + return "Disabled"; + return Integer.toString(interval); + } + + private int aprs_interval_value(String interval) throws AltosConfigDataException { + if (interval.equalsIgnoreCase("Disabled")) + return 0; + return parse_int("aprs interval", interval, false); + } + public void set_aprs_interval(int new_aprs_interval) { if (new_aprs_interval != AltosLib.MISSING) - aprs_interval_value.setSelectedItem(Integer.toString(new_aprs_interval)); + aprs_interval_value.setSelectedItem(aprs_interval_string(new_aprs_interval)); aprs_interval_value.setVisible(new_aprs_interval != AltosLib.MISSING); aprs_interval_label.setVisible(new_aprs_interval != AltosLib.MISSING); set_aprs_interval_tool_tip(); } public int aprs_interval() throws AltosConfigDataException { - if (aprs_interval_value.isVisible()) { - String s = aprs_interval_value.getSelectedItem().toString(); - - return parse_int("aprs interval", s, false); - } + if (aprs_interval_value.isVisible()) + return aprs_interval_value(aprs_interval_value.getSelectedItem().toString()); return AltosLib.MISSING; } @@ -1365,4 +1524,20 @@ public class AltosConfigFCUI return aprs_format_value.getSelectedIndex(); return AltosLib.MISSING; } + + public void set_aprs_offset(int new_aprs_offset) { + if (new_aprs_offset != AltosLib.MISSING) + aprs_offset_value.setSelectedItem(new_aprs_offset); + aprs_offset_value.setVisible(new_aprs_offset != AltosLib.MISSING); + aprs_offset_label.setVisible(new_aprs_offset != AltosLib.MISSING); + set_aprs_offset_tool_tip(); + } + + public int aprs_offset() throws AltosConfigDataException { + if (aprs_offset_value.isVisible()) { + Integer i = (Integer) aprs_offset_value.getSelectedItem(); + return i; + } + return AltosLib.MISSING; + } }