I ve got a tablet hook up to arduino which send 3 variables to processing : penStatus, x, y in ascii string
In processing i ve set up a drawing sketch which splits the string then interprets x and y to do some drawing.
But the lines are not continuous and kind of "laggy". it seems that it can't keep up with the speed of the stylus; it only draws small xtoy points and jumps to another one with no connection lines between them, i ve joined the processing sketch and a picture of the results.
thanks for any help.
import processing.serial.*;
Serial myPort; // The serial port
int x = 0;
int y = 0;
int oldx = 0;
int oldy = 0;
int penStatus = 0;
void setup()
{
size(3200,2400);
frameRate(25);
background(0);
smooth();
stroke (204, 102, 0);
strokeWeight(5);
strokeJoin(MITER);
myPort = new Serial(this, "COM5", 19200);
myPort.bufferUntil('\n');
}
void serialEvent(Serial myPort) {
oldx = x;
oldy = y;
// read the serial buffer:
String myString = myPort.readStringUntil('\n');
// if you got any bytes other than the linefeed:
myString = trim(myString);
// split the string at the commas
// and convert the sections into integers:
int sensors[] = int(split(myString, ','));
// print out the values you got:
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t");
println();
penStatus = sensors[0];
x = sensors[1];
y = sensors[2];
print(oldx);
print(oldy);
print(x);
println(y);
}
}
void draw() {
line (oldx, oldy, x, y);
}
Uploaded with ImageShack.us