mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-19 13:54:23 +01:00
Moved serial monitor baud rate from the Tools menu to the EditorStatus bar. No longer appending newline when pressing enter in the serial monitor edit field.
This commit is contained in:
parent
41d86d5a75
commit
9d13220743
@ -665,11 +665,6 @@ public class Editor extends JFrame
|
||||
JMenuItem item;
|
||||
JMenuItem rbMenuItem;
|
||||
JMenuItem cbMenuItem;
|
||||
SerialRateMenuListener srml = new SerialRateMenuListener();
|
||||
String[] portRates = {
|
||||
"300","1200","2400","4800","9600","14400",
|
||||
"19200","28800","38400","57600","115200"
|
||||
};
|
||||
|
||||
serialMenuListener = new SerialMenuListener();
|
||||
|
||||
@ -734,22 +729,7 @@ public class Editor extends JFrame
|
||||
serialMenu = new JMenu("Serial Port");
|
||||
populateSerialMenu();
|
||||
menu.add(serialMenu);
|
||||
|
||||
serialRateMenu = new JMenu("Serial Monitor Baud Rate");
|
||||
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
|
||||
String curr_rate = Preferences.get("serial.debug_rate");
|
||||
|
||||
for (int i = 0; i < portRates.length; i++) {
|
||||
rbMenuItem = new JCheckBoxMenuItem(portRates[i], portRates[i].equals(curr_rate));
|
||||
rbMenuItem.addActionListener(srml);
|
||||
group.add(rbMenuItem);
|
||||
serialRateMenu.add(rbMenuItem);
|
||||
}
|
||||
|
||||
menu.add(serialRateMenu);
|
||||
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
burnBootloaderItem = new JMenuItem("Burn Bootloader");
|
||||
@ -822,30 +802,6 @@ public class Editor extends JFrame
|
||||
*/
|
||||
}
|
||||
|
||||
// manages the serial port speed menu
|
||||
class SerialRateMenuListener implements ActionListener {
|
||||
|
||||
SerialRateMenuListener() {}
|
||||
|
||||
public void actionPerformed(ActionEvent actionevent) {
|
||||
int count = serialRateMenu.getItemCount();
|
||||
Object to;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
to = serialRateMenu.getItem(i);
|
||||
if ( to instanceof JCheckBoxMenuItem) ((JCheckBoxMenuItem)serialRateMenu.getItem(i)).setState(false);
|
||||
}
|
||||
|
||||
JCheckBoxMenuItem item = (JCheckBoxMenuItem)actionevent.getSource();
|
||||
item.setState(true);
|
||||
String name = item.getLabel();
|
||||
|
||||
Preferences.set("serial.debug_rate", name);
|
||||
//System.out.println("serial port speed set to " + name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class McuMenuListener implements ActionListener {
|
||||
McuMenuListener() {}
|
||||
|
||||
@ -1448,7 +1404,7 @@ public class Editor extends JFrame
|
||||
buttons.activate(EditorButtons.SERIAL);
|
||||
serialPort = new Serial(true);
|
||||
debugging = true;
|
||||
status.serial("Serial message:");
|
||||
status.serial();
|
||||
} else {
|
||||
doStop();
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
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
|
||||
|
||||
$Id:$
|
||||
*/
|
||||
|
||||
package processing.app;
|
||||
@ -68,6 +70,8 @@ public class EditorStatus extends JPanel implements ActionListener {
|
||||
JButton okButton;
|
||||
JButton sendButton;
|
||||
JTextField editField;
|
||||
JTextField serialField;
|
||||
JComboBox serialRates;
|
||||
|
||||
//Thread promptThread;
|
||||
int response;
|
||||
@ -179,15 +183,16 @@ public class EditorStatus extends JPanel implements ActionListener {
|
||||
empty();
|
||||
}
|
||||
|
||||
public void serial(String message)
|
||||
public void serial()
|
||||
{
|
||||
mode = SERIAL;
|
||||
this.message = message;
|
||||
this.message = NO_MESSAGE;
|
||||
|
||||
sendButton.setVisible(true);
|
||||
editField.setVisible(true);
|
||||
editField.setText("");
|
||||
editField.requestFocus();
|
||||
serialRates.setVisible(true);
|
||||
serialField.setVisible(true);
|
||||
serialField.setText("");
|
||||
serialField.requestFocus();
|
||||
|
||||
repaint();
|
||||
}
|
||||
@ -195,7 +200,8 @@ public class EditorStatus extends JPanel implements ActionListener {
|
||||
public void unserial()
|
||||
{
|
||||
sendButton.setVisible(false);
|
||||
editField.setVisible(false);
|
||||
serialField.setVisible(false);
|
||||
serialRates.setVisible(false);
|
||||
empty();
|
||||
}
|
||||
|
||||
@ -399,19 +405,48 @@ public class EditorStatus extends JPanel implements ActionListener {
|
||||
event.consume();
|
||||
//System.out.println("code is " + code + " char = " + c);
|
||||
}
|
||||
} else { // mode != EDIT (i.e. mode == SERIAL)
|
||||
if (c == KeyEvent.VK_ENTER) { // accept the input
|
||||
String answer = editField.getText();
|
||||
editor.serialPort.write(answer + "\n");
|
||||
event.consume();
|
||||
editField.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
//System.out.println("code is " + code + " char = " + c);
|
||||
}
|
||||
});
|
||||
add(editField);
|
||||
editField.setVisible(false);
|
||||
|
||||
serialField = new JTextField();
|
||||
serialField.addActionListener(this);
|
||||
|
||||
serialField.addKeyListener(new KeyAdapter() {
|
||||
public void keyTyped(KeyEvent event) {
|
||||
int c = event.getKeyChar();
|
||||
|
||||
if (c == KeyEvent.VK_ENTER) { // accept the input
|
||||
editor.serialPort.write(serialField.getText());
|
||||
event.consume();
|
||||
serialField.setText("");
|
||||
}
|
||||
}});
|
||||
|
||||
add(serialField);
|
||||
serialField.setVisible(false);
|
||||
|
||||
String[] serialRateStrings = {
|
||||
"300","1200","2400","4800","9600","14400",
|
||||
"19200","28800","38400","57600","115200"
|
||||
};
|
||||
|
||||
serialRates = new JComboBox();
|
||||
|
||||
if (Base.isMacOS())
|
||||
serialRates.setBackground(bgcolor[SERIAL]);
|
||||
|
||||
for (int i = 0; i < serialRateStrings.length; i++)
|
||||
serialRates.addItem(serialRateStrings[i] + " baud");
|
||||
|
||||
serialRates.setSelectedItem(
|
||||
Preferences.get("serial.debug_rate") + " baud");
|
||||
serialRates.addActionListener(this);
|
||||
add(serialRates);
|
||||
serialRates.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -428,15 +463,19 @@ public class EditorStatus extends JPanel implements ActionListener {
|
||||
noButton.setLocation(noLeft, top);
|
||||
cancelButton.setLocation(cancelLeft, top);
|
||||
editField.setLocation(yesLeft - Preferences.BUTTON_WIDTH, top);
|
||||
serialField.setLocation(yesLeft - Preferences.BUTTON_WIDTH, top);
|
||||
okButton.setLocation(noLeft, top);
|
||||
serialRates.setLocation(0, top);
|
||||
sendButton.setLocation(cancelLeft, top);
|
||||
|
||||
yesButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
noButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
cancelButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
okButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
sendButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
editField.setSize( 2*Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
yesButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
noButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
cancelButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
okButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
sendButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
serialRates.setSize( 3*Preferences.BUTTON_WIDTH/2, Preferences.BUTTON_HEIGHT);
|
||||
editField.setSize( 2*Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
serialField.setSize( 3*Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
}
|
||||
|
||||
|
||||
@ -479,8 +518,15 @@ public class EditorStatus extends JPanel implements ActionListener {
|
||||
editor.sketch.nameCode(answer);
|
||||
unedit();
|
||||
} else if (e.getSource() == sendButton) {
|
||||
editor.serialPort.write(editField.getText());
|
||||
editField.setText("");
|
||||
editor.serialPort.write(serialField.getText());
|
||||
serialField.setText("");
|
||||
} else if (e.getSource() == serialRates) {
|
||||
String wholeString = (String) serialRates.getSelectedItem();
|
||||
String rateString = wholeString.substring(0, wholeString.indexOf(' '));
|
||||
int rate = Integer.parseInt(rateString);
|
||||
Preferences.set("serial.debug_rate", rateString);
|
||||
editor.serialPort.dispose();
|
||||
editor.serialPort = new Serial(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,10 @@ UPDATES
|
||||
Added support for analog inputs 6 and 7 and pwm on pins 5 and 6 on the
|
||||
on the ATmega168 used in the Arduino Mini (extra analog inputs not available
|
||||
in DIP ATmega168s).
|
||||
You now select the baud rate for the serial monitor from within the editor
|
||||
status bar when the serial monitor is running instead of from the Tools menu.
|
||||
Pressing enter within the serial monitor edit box no longer appends a newline
|
||||
to the message sent to the board.
|
||||
|
||||
0005 - 2006.09.26
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user