diff options
| author | Keith Packard <keithp@keithp.com> | 2010-07-28 13:01:52 -0700 |
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2010-07-28 13:01:52 -0700 |
| commit | 71da54a5ce255395376a44586782ab8b6f3b289f (patch) | |
| tree | b6dc77d08e3c1dace620249f60e69b7ed0c70b5c /ao-tools/altosui/AltosUI.java | |
| parent | e76b9cc32bbcc5176d9bdd6f8d79778024627382 (diff) | |
Make voice and channel menus work.
Stores voice and channel data to preferences.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'ao-tools/altosui/AltosUI.java')
| -rw-r--r-- | ao-tools/altosui/AltosUI.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/ao-tools/altosui/AltosUI.java b/ao-tools/altosui/AltosUI.java index 5c92b9b4..511c3709 100644 --- a/ao-tools/altosui/AltosUI.java +++ b/ao-tools/altosui/AltosUI.java @@ -210,6 +210,7 @@ public class AltosUI extends JFrame { System.exit(0); } }); + voice.speak("Rocket flight monitor ready."); } public void info_reset() { @@ -490,6 +491,7 @@ public class AltosUI extends JFrame { try { serial_line.open(device); DeviceThread thread = new DeviceThread(serial_line); + serial_line.set_channel(AltosPreferences.channel()); run_display(thread); } catch (FileNotFoundException ee) { JOptionPane.showMessageDialog(AltosUI.this, @@ -706,9 +708,16 @@ public class AltosUI extends JFrame { menu.setMnemonic(KeyEvent.VK_V); menubar.add(menu); - radioitem = new JRadioButtonMenuItem("Enable Voice"); + radioitem = new JRadioButtonMenuItem("Enable Voice", AltosPreferences.voice()); radioitem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { + JRadioButtonMenuItem item = (JRadioButtonMenuItem) e.getSource(); + boolean enabled = item.isSelected(); + AltosPreferences.set_voice(enabled); + if (enabled) + voice.speak_always("Enable voice."); + else + voice.speak_always("Disable voice."); } }); menu.add(radioitem); @@ -724,12 +733,13 @@ public class AltosUI extends JFrame { for (int c = 0; c <= 9; c++) { radioitem = new JRadioButtonMenuItem(String.format("Channel %1d (%7.3fMHz)", c, 434.550 + c * 0.1), - c == 0); + c == AltosPreferences.channel()); radioitem.setActionCommand(String.format("%d", c)); radioitem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - System.out.println("Command: " + e.getActionCommand() + " param: " + - e.paramString()); + int new_channel = Integer.parseInt(e.getActionCommand()); + AltosPreferences.set_channel(new_channel); + serial_line.set_channel(new_channel); } }); menu.add(radioitem); |
