+ int flight_log_max_limit;
+ int flight_log_max;
+
+ public String flight_log_max_label(int flight_log_max) {
+ if (flight_log_max_limit != 0) {
+ int nflight = flight_log_max_limit / flight_log_max;
+ String plural = nflight > 1 ? "s" : "";
+
+ return String.format("%d (%d flight%s)", flight_log_max, nflight, plural);
+ }
+ return String.format("%d", flight_log_max);
+ }
+
+ public void set_flight_log_max(int new_flight_log_max) {
+ flight_log_max_value.setVisible(new_flight_log_max >= 0);
+ flight_log_max_label.setVisible(new_flight_log_max >= 0);
+
+ flight_log_max_value.setSelectedItem(flight_log_max_label(new_flight_log_max));
+ flight_log_max = new_flight_log_max;
+ set_flight_log_max_tool_tip();
+ }
+
+ public void set_flight_log_max_enabled(boolean enable) {
+ flight_log_max_value.setEnabled(enable);
+ set_flight_log_max_tool_tip();
+ }
+
+ public int flight_log_max() throws AltosConfigDataException {
+ return parse_int("flight log max", flight_log_max_value.getSelectedItem().toString(), true);
+ }
+
+ public void set_flight_log_max_limit(int new_flight_log_max_limit) {
+ flight_log_max_limit = new_flight_log_max_limit;
+ flight_log_max_value.removeAllItems();
+ for (int i = 8; i >= 1; i--) {
+ int size = flight_log_max_limit / i;
+ flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
+ }
+ if (flight_log_max != 0)
+ set_flight_log_max(flight_log_max);
+ }
+
+ public void set_ignite_mode(int new_ignite_mode) {
+ ignite_mode_value.setVisible(new_ignite_mode >= 0);
+ ignite_mode_label.setVisible(new_ignite_mode >= 0);
+
+ if (new_ignite_mode >= ignite_mode_values.length)
+ new_ignite_mode = 0;
+ if (new_ignite_mode < 0) {
+ ignite_mode_value.setEnabled(false);
+ new_ignite_mode = 0;
+ } else {
+ ignite_mode_value.setEnabled(true);
+ }
+ ignite_mode_value.setSelectedIndex(new_ignite_mode);
+ set_ignite_mode_tool_tip();
+ }
+
+ public int ignite_mode() {
+ if (ignite_mode_value.isEnabled())
+ return ignite_mode_value.getSelectedIndex();
+ else
+ return -1;
+ }
+
+
+ public void set_pad_orientation(int new_pad_orientation) {
+ pad_orientation_value.setVisible(new_pad_orientation >= 0);
+ pad_orientation_label.setVisible(new_pad_orientation >= 0);
+
+ if (new_pad_orientation >= pad_orientation_values.length)
+ new_pad_orientation = 0;
+ if (new_pad_orientation < 0)
+ new_pad_orientation = 0;
+ pad_orientation_value.setSelectedIndex(new_pad_orientation);
+ set_pad_orientation_tool_tip();
+ }
+
+ public int pad_orientation() {
+ if (pad_orientation_value.isEnabled())
+ return pad_orientation_value.getSelectedIndex();
+ else
+ return -1;
+ }
+
+ public void set_beep(int new_beep) {
+ beep_value.setVisible(new_beep >= 0);
+ beep_label.setVisible(new_beep >= 0);
+
+ int new_freq = (int) Math.floor (AltosConvert.beep_value_to_freq(new_beep) + 0.5);
+ for (int i = 0; i < beep_values.length; i++)
+ if (new_beep == AltosConvert.beep_freq_to_value(Integer.parseInt(beep_values[i]))) {
+ beep_value.setSelectedIndex(i);
+ set_beep_tool_tip();
+ return;
+ }
+ beep_value.setSelectedItem(String.format("%d", new_freq));
+ beep_value.setEnabled(new_beep >= 0);
+ set_beep_tool_tip();
+ }
+
+ public int beep() {
+ if (beep_value.isEnabled())
+ return AltosConvert.beep_freq_to_value(Integer.parseInt(beep_value.getSelectedItem().toString()));
+ else
+ return -1;
+ }
+
+ String[] tracker_motion_values() {
+ if (AltosConvert.imperial_units)
+ return tracker_motion_values_ft;
+ else
+ return tracker_motion_values_m;
+ }
+
+ void set_tracker_motion_values() {
+ String[] v = tracker_motion_values();
+ while (tracker_motion_value.getItemCount() > 0)
+ tracker_motion_value.removeItemAt(0);
+ for (int i = 0; i < v.length; i++)
+ tracker_motion_value.addItem(v[i]);
+ tracker_motion_value.setMaximumRowCount(v.length);
+ }
+
+ String get_tracker_motion_label() {
+ return String.format("Logging Trigger Motion (%s):", AltosConvert.height.show_units());
+ }
+
+ void set_tracker_tool_tip() {
+ if (tracker_motion_value.isEnabled())
+ tracker_motion_value.setToolTipText("How far the device must move before logging");
+ else
+ tracker_motion_value.setToolTipText("This device doesn't disable logging when stationary");
+ if (tracker_interval_value.isEnabled())
+ tracker_interval_value.setToolTipText("How often to report GPS position");
+ else
+ tracker_interval_value.setToolTipText("This device can't configure interval");
+ }
+
+ public void set_tracker_motion(int tracker_motion) {
+ tracker_motion_label.setVisible(tracker_motion >= 0);
+ tracker_motion_value.setVisible(tracker_motion >= 0);
+
+ if (tracker_motion < 0) {
+ tracker_motion_value.setEnabled(false);
+ } else {
+ tracker_motion_value.setEnabled(true);
+ tracker_motion_value.setSelectedItem(AltosConvert.height.say(tracker_motion));
+ }
+ }
+
+ public int tracker_motion() throws AltosConfigDataException {
+ String str = tracker_motion_value.getSelectedItem().toString();
+ try {
+ return (int) (AltosConvert.height.parse_locale(str) + 0.5);
+ } catch (ParseException pe) {
+ throw new AltosConfigDataException("invalid tracker motion %s", str);
+ }
+ }
+
+ public void set_tracker_interval(int tracker_interval) {
+ tracker_interval_label.setVisible(tracker_interval >= 0);
+ tracker_interval_value.setVisible(tracker_interval >= 0);
+
+ if (tracker_interval< 0) {
+ tracker_interval_value.setEnabled(false);
+ } else {
+ tracker_interval_value.setEnabled(true);
+ tracker_interval_value.setSelectedItem(String.format("%d", tracker_interval));
+ }
+ }
+
+ public int tracker_interval() throws AltosConfigDataException {
+ return parse_int ("tracker interval", tracker_interval_value.getSelectedItem().toString(), false);
+ }
+
+ public void set_pyros(AltosPyro[] new_pyros) {
+ pyros = new_pyros;
+ pyro.setVisible(pyros != null);
+ if (pyros != null && pyro_ui != null)
+ pyro_ui.set_pyros(pyros);
+ }
+
+ public AltosPyro[] pyros() throws AltosConfigDataException {
+ if (pyro_ui != null)
+ pyros = pyro_ui.get_pyros();
+ return pyros;
+ }
+
+ public void set_pyro_firing_time(double new_pyro_firing_time) {
+ pyro_firing_time = new_pyro_firing_time;
+ pyro.setVisible(pyro_firing_time >= 0);
+ if (pyro_firing_time >= 0 && pyro_ui != null)
+ pyro_ui.set_pyro_firing_time(pyro_firing_time);
+ }
+
+ public double pyro_firing_time() throws AltosConfigDataException {
+ if (pyro_ui != null)
+ pyro_firing_time = pyro_ui.get_pyro_firing_time();
+ return pyro_firing_time;
+ }
+
+ public void set_aprs_interval(int new_aprs_interval) {
+ aprs_interval_value.setVisible(new_aprs_interval >= 0);
+ aprs_interval_label.setVisible(new_aprs_interval >= 0);
+
+ String s;
+
+ if (new_aprs_interval <= 0)
+ s = "Disabled";
+ else
+ s = Integer.toString(new_aprs_interval);
+ aprs_interval_value.setSelectedItem(s);
+ set_aprs_interval_tool_tip();