I don’t know if I understand well, but let’s create an event with a thread() and just add a counter something like this. Where do you want to go from here?
long count;
String data = "";
void setup() {
size(500, 150);
textSize(18);
start_time = millis();
}
void draw() {
background(0);
if (frameCount % 30 == 0) {
thread("requestData");
}
text("Incoming data = "+data+" Count: "+count, 50, 50);
}
void requestData() {
if(millis() - start_time > random(1000, 5000)) {
count++;
start_time = millis();
data = "Xx"+random(100, 10000);
}
}