static final int ao_flight_landed = 8;
static final int ao_flight_invalid = 9;
+ /* Telemetry modes */
+ static final int ao_telemetry_off = 0;
+ static final int ao_telemetry_full = 1;
+ static final int ao_telemetry_tiny = 2;
+
static HashMap<String,Integer> string_to_state = new HashMap<String,Integer>();
static boolean map_initialized = false;
void set_channel(int channel) { }
+ void set_telemetry(int telemetry) { }
+
void update(AltosState state) throws InterruptedException { }
}
Container bag;
JComboBox channels;
+ JComboBox telemetries;
public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) {
AltosPreferences.init(this);
});
c.gridx = 0;
c.gridy = 0;
+ c.insets = new Insets(3, 3, 3, 3);
c.anchor = GridBagConstraints.WEST;
bag.add (channels, c);
+
+ // Telemetry format menu
+ telemetries = new JComboBox();
+ telemetries.addItem("TeleMetrum");
+ telemetries.addItem("TeleMini/TeleNano");
+ telemetries.setSelectedIndex(AltosPreferences.telemetry(serial) - 1);
+ telemetries.setMaximumRowCount(2);
+ telemetries.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ int telemetry = telemetries.getSelectedIndex();
+ reader.set_telemetry(telemetry);
+ }
+ });
+ c.gridx = 1;
+ c.gridy = 0;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.WEST;
+ bag.add (telemetries, c);
+ c.insets = new Insets(0, 0, 0, 0);
}
/* Flight status is always visible */
c.gridy = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
+ c.gridwidth = 2;
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);
/* channel preference name */
final static String channelPreferenceFormat = "CHANNEL-%d";
+ /* telemetry format preference name */
+ final static String telemetryPreferenceFormat = "TELEMETRY-%d";
+
/* voice preference name */
final static String voicePreference = "VOICE";
/* Channel (map serial to channel) */
static Hashtable<Integer, Integer> channels;
+ /* Telemetry (map serial to telemetry format) */
+ static Hashtable<Integer, Integer> telemetries;
+
/* Voice preference */
static boolean voice;
channels = new Hashtable<Integer,Integer>();
+ telemetries = new Hashtable<Integer,Integer>();
+
voice = preferences.getBoolean(voicePreference, true);
callsign = preferences.get(callsignPreference,"N0CALL");
return channel;
}
+ public static void set_telemetry(int serial, int new_telemetry) {
+ telemetries.put(serial, new_telemetry);
+ synchronized (preferences) {
+ preferences.putInt(String.format(telemetryPreferenceFormat, serial), new_telemetry);
+ flush_preferences();
+ }
+ }
+
+ public static int telemetry(int serial) {
+ if (telemetries.containsKey(serial))
+ return telemetries.get(serial);
+ int telemetry = preferences.getInt(String.format(telemetryPreferenceFormat, serial),
+ Altos.ao_telemetry_full);
+ telemetries.put(serial, telemetry);
+ return telemetry;
+ }
+
public static void set_voice(boolean new_voice) {
voice = new_voice;
synchronized (preferences) {
byte[] line_bytes;
int line_count;
boolean monitor_mode;
+ int telemetry;
+ int channel;
static boolean debug;
boolean remote;
LinkedList<String> pending_output = new LinkedList<String>();
}
public void set_radio() {
- set_channel(AltosPreferences.channel(device.getSerial()));
+ telemetry = AltosPreferences.telemetry(device.getSerial());
+ channel = AltosPreferences.channel(device.getSerial());
+ set_channel(channel);
set_callsign(AltosPreferences.callsign());
}
- public void set_channel(int channel) {
+ public void set_channel(int in_channel) {
+ channel = in_channel;
if (altos != null) {
if (monitor_mode)
- printf("m 0\nc r %d\nm 1\n", channel);
+ printf("m 0\nc r %d\nm %d\n", channel, telemetry);
else
printf("c r %d\n", channel);
flush_output();
}
}
+ public void set_telemetry(int in_telemetry) {
+ telemetry = in_telemetry;
+ if (altos != null) {
+ if (monitor_mode)
+ printf("m 0\nm %d\n", telemetry);
+ flush_output();
+ }
+ }
+
void set_monitor(boolean monitor) {
monitor_mode = monitor;
if (altos != null) {
if (monitor)
- printf("m 1\n");
+ printf("m %d\n", telemetry);
else
printf("m 0\n");
flush_output();
device = in_device;
line = "";
monitor_mode = false;
+ telemetry = Altos.ao_telemetry_full;
monitors = new LinkedList<LinkedBlockingQueue<AltosLine>> ();
reply_queue = new LinkedBlockingQueue<AltosLine> ();
open();
ground_altitude = data.ground_altitude();
height = data.filtered_height();
- System.out.printf("height %g\n", height);
report_time = System.currentTimeMillis();
accel_minus_g = map.get_int(AO_TELEM_CAL_ACCEL_MINUS, MISSING);
/* flight computer values */
- acceleration = map.get_int(AO_TELEM_KALMAN_ACCEL, MISSING);
- if (acceleration != MISSING)
- acceleration /= 16.0;
- speed = map.get_int(AO_TELEM_KALMAN_SPEED, MISSING);
- if (speed != MISSING)
- speed /= 16.0;
+ acceleration = map.get_double(AO_TELEM_KALMAN_ACCEL, MISSING, 1/16.0);
+ speed = map.get_double(AO_TELEM_KALMAN_SPEED, MISSING, 1/16.0);
height = map.get_int(AO_TELEM_KALMAN_HEIGHT, MISSING);
flight_accel = map.get_int(AO_TELEM_ADHOC_ACCEL, MISSING);
AltosPreferences.set_channel(device.getSerial(), channel);
}
+ void set_telemetry(int telemetry) {
+ serial.set_telemetry(telemetry);
+ AltosPreferences.set_telemetry(device.getSerial(), telemetry);
+ }
+
public AltosTelemetryReader (AltosDevice in_device)
throws FileNotFoundException, AltosSerialInUseException, IOException {
device = in_device;