int_ref radio_calibration;
int_ref radio_setting;
int_ref radio_frequency;
+ int_ref telemetry_rate;
string_ref config_version;
string_ref version;
string_ref product;
config_ui.set_version(version.get());
config_ui.set_radio_frequency(frequency());
config_ui.set_radio_calibration(radio_calibration.get());
+ config_ui.set_telemetry_rate(telemetry_rate.get());
config_ui.set_clean();
if (!made_visible) {
made_visible = true;
get_int(line, "Radio cal:", radio_calibration);
get_int(line, "Frequency:", radio_frequency);
get_int(line, "Radio setting:", radio_setting);
+ get_int(line, "Telemetry rate:", telemetry_rate);
get_string(line,"software-version", version);
get_string(line,"product", product);
}
radio_setting.set(0);
radio_frequency.set(0);
radio_calibration.set(1186611);
+ telemetry_rate.set(Altos.ao_telemetry_rate_38400);
config_version.set("0.0");
version.set("unknown");
product.set("unknown");
}
}
+ synchronized int telemetry_rate() {
+ System.out.printf("telemetry_rate: %d\n", telemetry_rate.get());
+ return telemetry_rate.get();
+ }
+
+ synchronized void set_telemetry_rate(int new_telemetry_rate){
+ int rate = telemetry_rate.get();
+
+ System.out.printf("set_telemetry_rate %d\n", new_telemetry_rate);
+ if (rate >= 0)
+ telemetry_rate.set(new_telemetry_rate);
+ }
+
final static int serial_mode_read = 0;
final static int serial_mode_save = 1;
final static int serial_mode_reboot = 2;
* available firmware version might place on the actual frequency
*/
config.set_frequency(AltosPreferences.frequency(serial.get()));
+ config.set_telemetry_rate(AltosPreferences.telemetry_rate(serial.get()));
config.process_line("all finished");
}
if (frequency != 0)
AltosPreferences.set_frequency(serial.get(),
frequency);
+ AltosPreferences.set_telemetry_rate(serial.get(),
+ telemetry_rate());
}
public void run () {
void save_data() {
double freq = config_ui.radio_frequency();
set_frequency(freq);
+ int telemetry_rate = config_ui.telemetry_rate();
+ set_telemetry_rate(telemetry_rate);
run_serial_thread(serial_mode_save);
}
radio_setting = new int_ref(0);
radio_frequency = new int_ref(0);
radio_calibration = new int_ref(1186611);
+ telemetry_rate = new int_ref(AltosLib.ao_telemetry_rate_38400);
config_version = new string_ref("0.0");
version = new string_ref("unknown");
product = new string_ref("unknown");
}
}
}
-}
\ No newline at end of file
+}
JLabel frequency_label;
JLabel radio_calibration_label;
JLabel radio_frequency_label;
+ JLabel rate_label;
public boolean dirty;
JLabel serial_value;
AltosUIFreqList radio_frequency_value;
JLabel radio_calibration_value;
+ AltosUIRateList rate_value;
JButton save;
JButton reset;
radio_calibration_value = new JLabel(String.format("%d", 1186611));
pane.add(radio_calibration_value, c);
+ /* Telemetry Rate */
+ c = new GridBagConstraints();
+ c.gridx = 0; c.gridy = 7;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ c.ipady = 5;
+ rate_label = new JLabel("Telemetry Rate:");
+ pane.add(rate_label, c);
+
+ c = new GridBagConstraints();
+ c.gridx = 4; c.gridy = 7;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.weightx = 1;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = ir;
+ c.ipady = 5;
+ rate_value = new AltosUIRateList();
+ pane.add(rate_value, c);
+
/* Buttons */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 12;
radio_calibration_value.setText(String.format("%d", calibration));
}
+ public int telemetry_rate() {
+ return rate_value.getSelectedIndex();
+ }
+
+ public void set_telemetry_rate(int rate) {
+ rate_value.setSelectedIndex(rate);
+ }
+
public void set_clean() {
dirty = false;
}
JLabel radio_calibration_label;
JLabel radio_frequency_label;
JLabel radio_enable_label;
+ JLabel rate_label;
JLabel aprs_interval_label;
JLabel aprs_ssid_label;
JLabel flight_log_max_label;
AltosUIFreqList radio_frequency_value;
JTextField radio_calibration_value;
JRadioButton radio_enable_value;
+ AltosUIRateList rate_value;
JComboBox<String> aprs_interval_value;
JComboBox<Integer> aprs_ssid_value;
JComboBox<String> flight_log_max_value;
radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
}
+ void set_rate_tool_tip() {
+ if (rate_value.isEnabled())
+ rate_value.setToolTipText("Select telemetry baud rate");
+ else
+ rate_value.setToolTipText("Firmware version does not support variable telemetry rates");
+ }
+
void set_aprs_interval_tool_tip() {
if (aprs_interval_value.isEnabled())
aprs_interval_value.setToolTipText("Enable APRS and set the interval between APRS reports");
set_radio_enable_tool_tip();
row++;
+ /* Telemetry Rate */
+ 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;
+ rate_label = new JLabel("Telemetry baud rate:");
+ pane.add(radio_enable_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;
+ rate_value = new AltosUIRateList();
+ rate_value.addItemListener(this);
+ pane.add(rate_value, c);
+ set_rate_tool_tip();
+ row++;
+
/* APRS interval */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = row;
return -1;
}
+ public void set_telemetry_rate(int new_rate) {
+ rate_value.set_rate(new_rate);
+ }
+
+ public int telemetry_rate() {
+ return rate_value.rate();
+ }
+
public void set_callsign(String new_callsign) {
callsign_value.setVisible(new_callsign != null);
callsign_value.setText(new_callsign);
Container bag;
AltosUIFreqList frequencies;
+ AltosUIRateList rates;
AltosUITelemetryList telemetries;
JLabel telemetry;
c.anchor = GridBagConstraints.WEST;
bag.add (frequencies, c);
+ // Telemetry rate list
+ rates = new AltosUIRateList(AltosUIPreferences.telemetry_rate(serial));
+ rates.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ int rate = rates.rate();
+ try {
+ reader.set_telemetry_rate(rate);
+ } catch (TimeoutException te) {
+ } catch (InterruptedException ie) {
+ }
+ reader.save_telemetry_rate();
+ }
+ });
+ rates.setEnabled(reader.supports_telemetry_rate(AltosLib.ao_telemetry_rate_2400));
+ c.gridx = 1;
+ c.gridy = 0;
+ c.weightx = 0;
+ c.weighty = 0;
+ c.insets = new Insets(3, 3, 3, 3);
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.WEST;
+ bag.add (rates, c);
+
// Telemetry format list
if (reader.supports_telemetry(Altos.ao_telemetry_standard)) {
- telemetries = new JComboBox<String>();
- for (int i = 1; i <= Altos.ao_telemetry_max; i++)
- telemetries.addItem(Altos.telemetry_name(i));
- int telemetry = AltosPreferences.telemetry(serial);
- if (telemetry <= Altos.ao_telemetry_off ||
- telemetry > Altos.ao_telemetry_max)
- telemetry = Altos.ao_telemetry_standard;
- telemetries.setSelectedIndex(telemetry - 1);
- telemetries.setMaximumRowCount(Altos.ao_telemetry_max);
- telemetries.setPreferredSize(null);
- telemetries.revalidate();
+ telemetries = new AltosUITelemetryList(serial);
telemetries.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- int telemetry = telemetries.getSelectedIndex() + 1;
+ int telemetry = telemetries.get_selected();
reader.set_telemetry(telemetry);
reader.save_telemetry();
}
});
- c.gridx = 1;
+ c.gridx = 2;
c.gridy = 0;
c.weightx = 0;
c.weighty = 0;
version = "Telemetry: None";
telemetry = new JLabel(version);
- c.gridx = 1;
+ c.gridx = 2;
c.gridy = 0;
c.weightx = 0;
c.weighty = 0;
c.gridy = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
- c.gridwidth = 2;
+ c.gridwidth = 3;
bag.add(flightStatus, c);
- c.gridwidth = 1;
/* The rest of the window uses a tabbed pane to
* show one of the alternate data views
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
- c.gridwidth = 2;
bag.add(pane, c);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
--- /dev/null
+/*
+ * Copyright © 2011 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.altosuilib_3;
+
+import javax.swing.*;
+import org.altusmetrum.altoslib_5.*;
+
+public class AltosUIRateList extends JComboBox<String> {
+
+ String product;
+ int serial;
+
+ public void set_rate(int new_rate) {
+ int i;
+
+ if (new_rate < 0) {
+ setVisible(false);
+ return;
+ }
+
+ setSelectedIndex(new_rate);
+ }
+
+ public void set_product(String new_product) {
+ product = new_product;
+ }
+
+ public void set_serial(int new_serial) {
+ serial = new_serial;
+ }
+
+ public int rate() {
+ return getSelectedIndex();
+ }
+
+ public AltosUIRateList () {
+ super();
+ for (int i = 0; i < AltosLib.ao_telemetry_rate_values.length; i++)
+ addItem(String.format("%d baud", AltosLib.ao_telemetry_rate_values[i]));
+ setMaximumRowCount(getItemCount());
+ setEditable(false);
+ product = "Unknown";
+ serial = 0;
+ }
+
+ public AltosUIRateList(int in_rate) {
+ this();
+ set_rate(in_rate);
+ }
+}
AltosUIVoltageIndicator.java \
AltosUIFreqList.java \
AltosUITelemetryList.java \
+ AltosUIRateList.java \
OSXAdapter.java
JAR=altosuilib_$(ALTOSUILIB_VERSION).jar