diff options
| -rw-r--r-- | altosui/Altos.java | 5 | ||||
| -rw-r--r-- | altosui/AltosFlightReader.java | 2 | ||||
| -rw-r--r-- | altosui/AltosFlightUI.java | 24 | ||||
| -rw-r--r-- | altosui/AltosPreferences.java | 25 | ||||
| -rw-r--r-- | altosui/AltosSerial.java | 23 | ||||
| -rw-r--r-- | altosui/AltosState.java | 1 | ||||
| -rw-r--r-- | altosui/AltosTelemetry.java | 8 | ||||
| -rw-r--r-- | altosui/AltosTelemetryReader.java | 5 | 
8 files changed, 82 insertions, 11 deletions
| diff --git a/altosui/Altos.java b/altosui/Altos.java index 8ee94e04..9d5b2e02 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -63,6 +63,11 @@ public class Altos {  	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; diff --git a/altosui/AltosFlightReader.java b/altosui/AltosFlightReader.java index 3d59de9a..f665bda8 100644 --- a/altosui/AltosFlightReader.java +++ b/altosui/AltosFlightReader.java @@ -34,5 +34,7 @@ public class AltosFlightReader {  	void set_channel(int channel) { } +	void set_telemetry(int telemetry) { } +  	void update(AltosState state) throws InterruptedException { }  } diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index 68e0ef87..286b2a4e 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -119,6 +119,7 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {  	Container	bag;  	JComboBox	channels; +	JComboBox	telemetries;  	public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) {  		AltosPreferences.init(this); @@ -149,8 +150,28 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {  			});  			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 */ @@ -159,7 +180,9 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {  		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 @@ -190,6 +213,7 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {  		c.fill = GridBagConstraints.BOTH;  		c.weightx = 1;  		c.weighty = 1; +		c.gridwidth = 2;  		bag.add(pane, c);  		setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); diff --git a/altosui/AltosPreferences.java b/altosui/AltosPreferences.java index d4df4e16..5f827655 100644 --- a/altosui/AltosPreferences.java +++ b/altosui/AltosPreferences.java @@ -34,6 +34,9 @@ class AltosPreferences {  	/* 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"; @@ -61,6 +64,9 @@ class AltosPreferences {  	/* 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; @@ -94,6 +100,8 @@ class AltosPreferences {  		channels = new Hashtable<Integer,Integer>(); +		telemetries = new Hashtable<Integer,Integer>(); +  		voice = preferences.getBoolean(voicePreference, true);  		callsign = preferences.get(callsignPreference,"N0CALL"); @@ -189,6 +197,23 @@ class AltosPreferences {  		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) { diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java index f9f9e6e4..a8ba66bd 100644 --- a/altosui/AltosSerial.java +++ b/altosui/AltosSerial.java @@ -47,6 +47,8 @@ public class AltosSerial implements Runnable {  	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>(); @@ -231,25 +233,37 @@ public class AltosSerial implements Runnable {  	}  	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(); @@ -285,6 +299,7 @@ public class AltosSerial implements Runnable {  		device = in_device;  		line = "";  		monitor_mode = false; +		telemetry = Altos.ao_telemetry_full;  		monitors = new LinkedList<LinkedBlockingQueue<AltosLine>> ();  		reply_queue = new LinkedBlockingQueue<AltosLine> ();  		open(); diff --git a/altosui/AltosState.java b/altosui/AltosState.java index 4e165f80..0ff2479e 100644 --- a/altosui/AltosState.java +++ b/altosui/AltosState.java @@ -80,7 +80,6 @@ public class AltosState {  		ground_altitude = data.ground_altitude();  		height = data.filtered_height(); -		System.out.printf("height %g\n", height);  		report_time = System.currentTimeMillis(); diff --git a/altosui/AltosTelemetry.java b/altosui/AltosTelemetry.java index 3eb0efa8..91b6d048 100644 --- a/altosui/AltosTelemetry.java +++ b/altosui/AltosTelemetry.java @@ -253,12 +253,8 @@ public class AltosTelemetry extends AltosRecord {  		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); diff --git a/altosui/AltosTelemetryReader.java b/altosui/AltosTelemetryReader.java index 6c5a9397..980391b4 100644 --- a/altosui/AltosTelemetryReader.java +++ b/altosui/AltosTelemetryReader.java @@ -47,6 +47,11 @@ class AltosTelemetryReader extends AltosFlightReader {  		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; | 
