-
Notifications
You must be signed in to change notification settings - Fork 26
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
Need help on addPoint syntax #12
Comments
Hi Yves, I tried your example and it works for me:
There are several addPoint methods in Grafica. You can see them listed here: https://github.com/jagracar/grafica/blob/master/src/grafica/GPlot.java#L1928 |
Hi Javier, public void addPoint(float x, float y) It works but the program crashes at the start with this error ArrayIndexOutOfBoundsExeption : 1 import grafica.*;
import processing.serial.*; // Importing the serial library to communicate with the Arduino
Serial myPort; // Initializing a vairable named 'myPort' for serial communication
public GPlot plot1;
public GPointsArray polygonPoints;
String valeurs;
String deplacement;
String val_force ;
String values;
public void setup(){
size(1200, 800, JAVA2D);
myPort = new Serial (this, "COM4", 9600); // Set the com port and the baud rate according to the Arduino IDE
myPort.bufferUntil('\n');
plot1 = new GPlot(this);
plot1.setPos(350, 150);
plot1.setDim(700, 500);
plot1.getTitle().setText("Effet tactile");
plot1.getXAxis().getAxisLabel().setText("Déplacement (mm)");
plot1.getYAxis().getAxisLabel().setText("Force (N)");
}
public void draw(){
valeurs = myPort.readStringUntil('\n');
String values[] = split(valeurs,' ');
if (values.length > 0) {
deplacement = values[0];
val_force = values[1];
}
plot1.addPoint(float(deplacement),float( val_force));
// Reset the points if the user pressed the space bar
if (keyPressed && key == ' ') {
plot1.setPoints(new GPointsArray());
}
plot1.beginDraw();
plot1.drawBackground();
plot1.drawBox();
plot1.drawXAxis();
plot1.drawYAxis();
plot1.drawTitle();
plot1.drawGridLines(GPlot.BOTH);
plot1.drawLines();
plot1.drawPoints();
plot1.endDraw();
} Thank you |
Hi,
I would like to plot a simple graph in real time from two sensors values sent by an arduino based on the mouse position example.
My problem is that I don't understand the syntax of the example.
The code below works perfectly with the mouse position but when I try to change it with my values , I get
The function "addPoint()" expects parameters like : "addPoint(GPoint)"
Could you please help me ?
Regards,
Yves
The text was updated successfully, but these errors were encountered: