We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everyone. As many Arduino enthusiasts, I cross the bridge to Processing. Its something good, really, but my lacks of C++ block me: On SerialCallResponse, I'd like to have the graph data updated every 30secondes, while the bargraph will run a normal speed ( dependent of frameRate or Serial speed).
void draw() {
background(180,180,240);
digitalClock.getTime();
digitalClock.display();
//first graph
stroke(0);
fill(200,200,200);
rect(100,275,300,20);
//data points
if((millis()-lasttime)>500){
for(int index =0; index<200; index++)
{
if(index == 199){
tempHistory0[index] = t0;
}
else{
tempHistory0[index] = tempHistory0[index + 1];
point(100 + index, 275 - tempHistory0[index]);
lasttime = millis();
}
}
}
}
In this case, the points a recorded every 500ms, but blinks, the rectangle on background erase it. Data from serial are bytes stored in an array. I tried many combinations but cannot find the right on. Its a simple coding question from a beginner. Greetings.
Answers
Take a look at the examples in this old post:
http://forum.processing.org/two/discussion/9432/having-an-event-occur-every-n-milliseconds
Other tagged links: http://forum.processing.org/two/discussions/tagged/timertask
Thanks for fast reply. Thread is very unstable, I try to understand and apply the Java timer then.
Just be aware that TimerTask runs in another Thread too! ;;)