Using two different readStringUntil "characters"

I guess what you’re actually attempting there is to move the line()'s current coordinates w/ the values received from Serial, right? :thinking:

I see that at the Arduino’s side, you use map() in order to constrain the sent values within the range of [-10 to 10]. :world_map:

My bet is that those values mean how much farther to draw the next line()'s coordinates in relation to the previous 1.:horse_racing:

So I’ve made some changes to my previous Serial posted sketch. :man_mechanic:

Now, instead of vals[], we’re gonna have a PVector mov variable:

Variable mov is gonna store the values received from Serial::readString() using its method PVector::set():

void serialEvent(final Serial s) {
  mov.set(float(splitTokens(s.readString())));
  redraw = true;
}

We’re also gonna need a 2nd PVector named vec, which’s gonna store canvas’ current coordinates:
final PVector vec = new PVector(), mov = new PVector();

And we’re gonna initialize it w/ the canvas’ center coordinates:
vec.set(width>>1, height>>1);

Now, every time a new coordinate pair is received within serialEvent(), we’re gonna use PVector::add() method in order to move vec’s current coordinates to a new 1, passing mov as its argument:

line(vec.x, vec.y, vec.add(mov).x, vec.y);

Here’s the complete sketch “Serial TSV-Reading Line-Drawing”. Have fun: :smile_cat:

/**
 * Serial TSV-Reading Line-Drawing (v1.0)
 * GoToLoop (2019/May/02)
 *
 * https://Discourse.Processing.org/t/
 * using-two-different-readstringuntil-characters/10769/21
 */

import processing.serial.Serial;

static final String PORT = "COM12";
static final int BAUDS = 115200, INDEX = 1;

final PVector vec = new PVector(), mov = new PVector();

void setup() {
  size(1300, 700);
  noLoop();

  stroke(-1);
  clear();

  vec.set(width>>1, height>>1);

  final String[] ports = Serial.list();
  printArray(ports);

  new Serial(this, PORT, BAUDS).bufferUntil(ENTER);
  //new Serial(this, ports[INDEX], BAUDS).bufferUntil(ENTER);
}

void draw() {
  line(vec.x, vec.y, vec.add(mov).x, vec.y);

  if (outtaBounds(vec)) {
    vec.set(width>>1, height>>1);
    System.err.println("Coords reset back to center of canvas!");
  }

  println(vec, mov);
}

boolean outtaBounds(final PVector v) {
  return v.x < 0 | v.x >= width | v.y < 0 | v.y >= height;
}

void serialEvent(final Serial s) {
  mov.set(float(splitTokens(s.readString())));
  redraw = true;
}