System.exit(0);
}
});
+ voice.speak("Rocket flight monitor ready.");
}
public void info_reset() {
flightInfoModel[i].finish();
}
- static final int MIN_PAD_SAMPLES = 10;
-
public void show(AltosState state) {
flightStatusModel.set(state);
info_reset();
- if (state.npad >= MIN_PAD_SAMPLES)
+ if (state.gps_ready)
info_add_row(0, "Ground state", "%s", "ready");
else
info_add_row(0, "Ground state", "wait (%d)",
- MIN_PAD_SAMPLES - state.npad);
+ state.gps_waiting);
info_add_row(0, "Rocket state", "%s", state.data.state);
info_add_row(0, "Callsign", "%s", state.data.callsign);
info_add_row(0, "Rocket serial", "%6d", state.data.serial);
voice.speak("rocket landed safely");
else
voice.speak("rocket may have crashed");
- if (state.gps != null)
+ if (state.from_pad != null)
voice.speak("bearing %d degrees, range %d meters",
(int) (state.from_pad.bearing + 0.5),
(int) (state.from_pad.distance + 0.5));
(int) (state.max_height + 0.5));
}
}
+ if (old_state == null || old_state.gps_ready != state.gps_ready) {
+ if (state.gps_ready)
+ voice.speak("GPS ready");
+ else if (old_state != null)
+ voice.speak("GPS lost");
+ }
old_state = state;
}
void close() {
serial.close();
serial.remove_monitor(telem);
- System.out.println("DisplayThread done");
}
public DeviceThread(AltosSerial s) {
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,
* a TeleDongle over the packet link
*/
private void SaveFlightData() {
+ new AltosEeprom(AltosUI.this);
}
/* Create the AltosUI menus
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);
+ item = new JMenuItem("Test Voice",KeyEvent.VK_T);
+ item.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ voice.speak("That's one small step for man; one giant leap for mankind.");
+ }
+ });
+ menu.add(item);
}
// Channel menu
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);