Skip to content

Commit 4532618

Browse files
committed
Send Board Reset from Serial Monitor
This introduces two new features: ++ a reset button to the serial monitor. So the board can be reset by a simple button press ++ the "reset board on serial monitor open" has been removed. I think that removed "feature" was a great annoyance: imagine the Arduino is controlling some device. And you forgot to open the monitor. Open it later, Reset, Not nice.
1 parent 87400d9 commit 4532618

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

app/src/processing/app/AbstractMonitor.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public abstract class AbstractMonitor extends JFrame implements ActionListener {
4141
protected JScrollPane scrollPane;
4242
protected JTextField textField;
4343
protected JButton sendButton;
44-
44+
protected JButton resetButton;
4545
protected JCheckBox autoscrollBox;
4646
protected JComboBox lineEndings;
4747
protected JComboBox serialRates;
@@ -102,10 +102,12 @@ public void actionPerformed(ActionEvent event) {
102102

103103
textField = new JTextField(40);
104104
sendButton = new JButton(_("Send"));
105+
resetButton = new JButton(_("Send Reset"));
105106

106107
upperPane.add(textField);
107108
upperPane.add(Box.createRigidArea(new Dimension(4, 0)));
108109
upperPane.add(sendButton);
110+
upperPane.add(resetButton);
109111

110112
getContentPane().add(upperPane, BorderLayout.NORTH);
111113

@@ -189,6 +191,10 @@ public void onSendCommand(ActionListener listener) {
189191
sendButton.addActionListener(listener);
190192
}
191193

194+
public void onResetCommand(ActionListener listener) {
195+
resetButton.addActionListener(listener);
196+
}
197+
192198
protected void setPlacement(int[] location) {
193199
setBounds(location[0], location[1], location[2], location[3]);
194200
}

app/src/processing/app/SerialMonitor.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import static processing.app.I18n._;
2929

30+
3031
@SuppressWarnings("serial")
3132
public class SerialMonitor extends AbstractMonitor {
3233

@@ -66,6 +67,17 @@ public void actionPerformed(ActionEvent e) {
6667
}
6768
});
6869

70+
onResetCommand(new ActionListener() {
71+
public void actionPerformed(ActionEvent e) {
72+
try {
73+
serial.setDTR(true);
74+
Thread.sleep(207); // Pfffffff.
75+
serial.setDTR(false);
76+
} catch (Exception se) {
77+
se.printStackTrace(); // we are in deep trouble if this happens....
78+
}
79+
}
80+
});
6981
}
7082

7183
private void send(String s) {

arduino-core/src/processing/app/Serial.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public Serial(String iname, int irate, char iparity, int idatabits, float istopb
121121
try {
122122
port = new SerialPort(iname);
123123
port.openPort();
124-
port.setParams(rate, databits, stopbits, parity, true, true);
124+
port.setParams(rate, databits, stopbits, parity, true, false);
125125
port.addEventListener(this);
126126
} catch (Exception e) {
127127
throw new SerialException(I18n.format(_("Error opening serial port ''{0}''."), iname), e);

0 commit comments

Comments
 (0)