Need help - changeable text screen output

how can you output a changing text, which comes via a serial interface on the screen output? the problem is that the first text always stops and then it runs into each other.

example:

  textSize(100);
  fill(0, 139, 0, 139);
  text(distance, 1000,1400);

thanks for the help!

I guess you’re not clearing the previous display? if yes, juts put background(0) to clear, put it before the text being drawn onto the screen. I’m not very sure, can you post the working code? just a bit to show the problem.

hi thanks for the answer and sorry for the bad description.

i’m doing a radar project, with the arduino i send distance to processing and i want to show it there. because background(0) i want to leave it that way, that’s just the background color, right?

i just tried to make an example:

int test;

void setup(){
     size(1000, 1000);
     }
     
void draw(){
  
  int test=5*5;
  textSize(100);
  fill(0, 139, 0, 139);
  text(test, 300,300);  
  }

that’s how it works. but the measured distance always changes or stays away.

I’ll take a picture later to pinpoint the problem.

thank you

1 Like

You need to clear the previous display to show the next frame. Just draw a background on to it

int test;

void setup() {
  size(1000, 1000);
  frameRate(3);
}

void draw() {
  background(200);
  float test=random(10);
  textSize(100);
  fill(0, 139, 0, 139);
  text(test, 300, 300);
}
1 Like

you could also make a list and add the last value at the top of the list

  • Using background(200); too, of course
  • the "\n" + means line break

Chrisir

String textResult = ""; 

void setup() {
  size(1000, 1000);
  frameRate(3);
}

void draw() {
  background(200);

  float test=random(10);
  println(test); 
  textResult = test + "\n" + textResult;  // !!!!!!!

  showText();
}

//---------------------------------------------------------

void showText() {
  // show text
  textSize(15);
  fill(0, 139, 0);
  text(textResult, 300, 30);
}
//
3 Likes

so it works perfectly but unfortunately my text is also covered because i inserted it in the setup.

is there a possibility to put the background in a small field?

Edit:

i took my text from the setup into the loop. now it works :slight_smile: thank you!

i try to build in the rest and get back to you if i’m still waiting somewhere.

many thanks :slight_smile:

2 Likes