1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-22 08:22:04 +03:00

Merge branch 'master' into new-extension

This commit is contained in:
David A. Mellis
2010-11-10 12:15:28 -05:00
15 changed files with 1896 additions and 36 deletions

View File

@ -789,6 +789,7 @@ public class Base {
// This will store the sketch count as zero
editors.remove(editor);
Editor.serialMonitor.closeSerialPort();
storeSketches();
// Save out the current prefs state
@ -826,6 +827,7 @@ public class Base {
// If quit is canceled, this will be replaced anyway
// by a later handleQuit() that is not canceled.
storeSketches();
Editor.serialMonitor.closeSerialPort();
if (handleQuitEach()) {
// make sure running sketches close before quitting

View File

@ -151,7 +151,7 @@ public class Editor extends JFrame implements RunnerListener {
super("Arduino");
this.base = ibase;
//Base.setIcon(this);
Base.setIcon(this);
// Install default actions for Run, Present, etc.
resetHandlers();
@ -2392,10 +2392,10 @@ public class Editor extends JFrame implements RunnerListener {
if (uploading) return;
try {
serialMonitor.openSerialPort();
serialMonitor.openSerialPort();
serialMonitor.setVisible(true);
} catch (SerialException e) {
statusError(e);
statusError(e);
}
}

View File

@ -19,6 +19,7 @@
package processing.app;
import processing.app.debug.MessageConsumer;
import processing.core.*;
import java.awt.*;
import java.awt.event.*;
@ -106,6 +107,14 @@ public class SerialMonitor extends JFrame implements MessageConsumer {
autoscrollBox = new JCheckBox("Autoscroll", true);
lineEndings = new JComboBox(new String[] { "No line ending", "Newline", "Carriage return", "Both NL & CR" });
lineEndings.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
Preferences.setInteger("serial.line_ending", lineEndings.getSelectedIndex());
}
});
if (Preferences.get("serial.line_ending") != null) {
lineEndings.setSelectedIndex(Preferences.getInteger("serial.line_ending"));
}
lineEndings.setMaximumSize(lineEndings.getMinimumSize());
String[] serialRateStrings = {
@ -127,7 +136,7 @@ public class SerialMonitor extends JFrame implements MessageConsumer {
Preferences.set("serial.debug_rate", rateString);
closeSerialPort();
try {
openSerialPort();
openSerialPort();
} catch (SerialException e) {
System.err.println(e);
}
@ -144,8 +153,40 @@ public class SerialMonitor extends JFrame implements MessageConsumer {
getContentPane().add(pane, BorderLayout.SOUTH);
pack();
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
if (Preferences.get("last.screen.height") != null) {
// if screen size has changed, the window coordinates no longer
// make sense, so don't use them unless they're identical
int screenW = Preferences.getInteger("last.screen.width");
int screenH = Preferences.getInteger("last.screen.height");
if ((screen.width == screenW) && (screen.height == screenH)) {
String locationStr = Preferences.get("last.serial.location");
if (locationStr != null) {
int[] location = PApplet.parseInt(PApplet.split(locationStr, ','));
setPlacement(location);
}
}
}
}
protected void setPlacement(int[] location) {
setBounds(location[0], location[1], location[2], location[3]);
}
protected int[] getPlacement() {
int[] location = new int[4];
// Get the dimensions of the Frame
Rectangle bounds = getBounds();
location[0] = bounds.x;
location[1] = bounds.y;
location[2] = bounds.width;
location[3] = bounds.height;
return location;
}
private void send(String s) {
if (serial != null) {
switch (lineEndings.getSelectedIndex()) {
@ -166,6 +207,9 @@ public class SerialMonitor extends JFrame implements MessageConsumer {
public void closeSerialPort() {
if (serial != null) {
int[] location = getPlacement();
String locationStr = PApplet.join(PApplet.str(location), ",");
Preferences.set("last.serial.location", locationStr);
textArea.setText("");
serial.dispose();
serial = null;