Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Serial plotter remote commands #7461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
Loading
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
SerialPlotter: reset xCount when clear the graph
  • Loading branch information
Wilhelm Wiens committed Apr 9, 2020
commit 450c40d9f2edddd22d4dca924d72341e80700d76
19 changes: 13 additions & 6 deletions 19 app/src/processing/app/SerialPlotter.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public SerialPlotter(BoardPort port) {

graphWidth.addChangeListener(cl -> {setNewBufferCapacity((int)graphWidth.getValue()); } );

clearButton.addActionListener(ae -> {graphs.clear();});
clearButton.addActionListener(ae -> {CommandClearGraph();});
}

protected void onCreateWindow(Container mainPane) {
Expand Down Expand Up @@ -396,7 +396,7 @@ public void onSendCommand(ActionListener listener) {
sendButton.addActionListener(listener);
}

public void appyPreferences() {
public void applyPreferences() {
// Apply line endings.
if (PreferencesData.get("serial.line_ending") != null) {
lineEndings.setSelectedIndex(PreferencesData.getInteger("serial.line_ending"));
Expand Down Expand Up @@ -429,6 +429,12 @@ private void setNewBufferCapacity(int capacity){
}
}

private void CommandClearGraph()
{
graphs.clear();
xCount=0;
}

public void message(final String s) {
messageBuffer.append(s);
while (true) {
Expand Down Expand Up @@ -457,7 +463,7 @@ public void message(final String s) {
if(parts[i].startsWith("#") && parts[i].length() > 1) {
String command = parts[i].substring(1, parts[i].length()).trim();
if("CLEAR".equals(command)) {
graphs.clear();
CommandClearGraph();
}
else if(command.startsWith("SIZE:")) {
String[] subString = parts[i].split("[:]+");
Expand Down Expand Up @@ -522,14 +528,14 @@ else if(command.startsWith("SIZE:")) {

if(value != null) {
if(validParts >= graphs.size()) {
graphs.add(new Graph(validParts));
graphs.add(new Graph(validParts, buffer_capacity));
}
graphs.get(validParts).buffer.add(value);
validParts++;
}
if(label != null) {
if(validLabels >= graphs.size()) {
graphs.add(new Graph(validLabels));
graphs.add(new Graph(validLabels, buffer_capacity));
}
graphs.get(validLabels).label = label;
validLabels++;
Expand All @@ -538,10 +544,11 @@ else if(command.startsWith("SIZE:")) {
else if(validLabels > validParts) validParts = validLabels;
}
}

}
SwingUtilities.invokeLater(SerialPlotter.this::repaint);
}


public void open() throws Exception {
super.open();

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.