Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Label text slow to update via network events

$
0
0

I'm working on a sketch that is receiving network events from an external program (specifically, an OpenFrameworks sketch), using the processing.net library.

Inside the draw method, I have the following code to parse the incoming data, and assign it appropriately to display a value of text in a text label:

void draw()
{
  // check for incoming data
  Client client = server.available();
  if (client != null) {
    // check for a full line of incoming data
    String line = client.readStringUntil('\n');

    if (line != null) {
      //println(line);
      int val = int(trim(line)); // extract the predicted class
      //println(val);
      if (val == 1) {
        messageText = "EVENT 1";
      } else if (val == 2) {
        messageText = "EVENT 2";
      } else if (val == 3) {
        messageText = "EVENT 3";
      }
    }
  }

  // draw
  background(0);
  textFont(f,64);
  fill(255);
  textAlign(CENTER);
  text(messageText, width/2, height/2);

}

Through logging, I have verified that the data is being received properly

However, I'm experiencing a very annoying bug - the text of my messageText label is VERY slow to update...after a new event has occurred (and is shown as such through logging), the messageText will still display the value of the last event for several seconds.

Anyone have any pointers on how to speed up performance here?

Thanks!


Viewing all articles
Browse latest Browse all 2896

Trending Articles