If you review the attached code, in the "draw" routine, where I am writing the value of 'n' to the display window, you will notice that I am trying to "blank" the same area before each display update of "n". I can NOT get this to work. It simply displays all the values on 'n' one on top of the other, resulting in a mess.
Can someone point out my errors, and how I can get the countdown 'n' to display cleanly?
NOTE: I had to remove the http links to the actual images in the "loadImage" code below, as I have not made enough posts here for the system to allow to include active links. Code:
// Declare all the variables
int refreshTime = 30 * 1000; // every 15 minutes;
int lastTime;
String blank = " ";
PFont font;
PImage b;
PImage bb;
PImage cc;
PImage dd;
void setup() {
size(500,330);
frameRate(1);
font = loadFont("Futura-MediumItalic-48.vlw");
fill(120);
textFont(font,18 );
delay(10*1000); // delay to wait for Arduino bootloader, just in case
lastTime = millis() - refreshTime; // make it so we getWebImages at startup
}
void draw() {
int n = (int)((refreshTime-(millis()-lastTime))/1000)+1;
println("countdown to update: "+ n);
text(blank, 45, 41);
text(n , 45, 41);
if( millis() - lastTime >= refreshTime ) {
getWebImages();
lastTime = millis();
}
}
void getWebImages() {
println("Fetching images....");
b=loadImage("image1");
bb=loadImage("image2");
cc=loadImage("image3");
dd=loadImage("image4");
//Display the images
println("Displaying Images.....");
image(b,120,0);
image(bb,0,0);
image(cc,0,49);
image(dd,0,70);
return;
}
catch (Exception ex) {
ex.printStackTrace();
System.out.println("ERROR: "+ex.getMessage());
}
}
Thanks for any help....
Jim