Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions app/src/processing/app/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2374,8 +2374,7 @@ class DefaultExportHandler implements Runnable {
public void run() {

try {
serialMonitor.closeSerialPort();
serialMonitor.setVisible(false);
serialMonitor.suspend();

uploading = true;

Expand All @@ -2402,6 +2401,14 @@ public void run() {
uploading = false;
//toolbar.clear();
toolbar.deactivate(EditorToolbar.EXPORT);

// Return the serial monitor window to its initial state
try {
serialMonitor.resume();
}
catch (SerialException e) {
statusError(e);
}
}
}

Expand Down Expand Up @@ -2476,12 +2483,9 @@ protected boolean handleExportCheckModified() {
}


public void handleSerial() {
if (uploading) return;

public void handleSerial() {
try {
serialMonitor.openSerialPort();
serialMonitor.setVisible(true);
serialMonitor.openSerialMonitor();
} catch (SerialException e) {
statusError(e);
}
Expand Down
51 changes: 50 additions & 1 deletion app/src/processing/app/SerialMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ public class SerialMonitor extends JFrame implements MessageConsumer {
private JComboBox lineEndings;
private JComboBox serialRates;
private int serialRate;
private boolean serialMonitorEnabled;


public SerialMonitor(String port) {
super(port);

this.port = port;

addWindowListener(new WindowAdapter() {
Expand Down Expand Up @@ -171,6 +172,8 @@ public void actionPerformed(ActionEvent event) {
}
}
}

serialMonitorEnabled = true;
}

protected void setPlacement(int[] location) {
Expand Down Expand Up @@ -228,4 +231,50 @@ public void run() {
}
}});
}

public void enableWindow(boolean enable)
{
textArea.setEnabled(enable);
scrollPane.setEnabled(enable);
textField.setEnabled(enable);
sendButton.setEnabled(enable);
autoscrollBox.setEnabled(enable);
lineEndings.setEnabled(enable);
serialRates.setEnabled(enable);

serialMonitorEnabled = enable;
}

// Make the serial monitor window operational
public void openSerialMonitor() throws SerialException
{
// If the serial monitor is not currently disabled, open
// the serial port
if (serialMonitorEnabled)
openSerialPort();

// Make the window visible
setVisible(true);
}

// Puts the window in suspend state, closing the serial port
// to allow other entity (the programmer) to use it
public void suspend()
{
if (serial != null)
// Serial is opened. Record this fact and close it
closeSerialPort();

enableWindow(false);
}

public void resume() throws SerialException
{
// Enable the window
enableWindow(true);

// If the window is visible, try to open the serial port
if (isVisible())
openSerialPort();
}
}