Tvout: clearing the screen before re-writing

I am creating a heads-up display. Which works – mostly.

Arduino 1 (Mega) takes sensor values and input, and signals a second Arduino (Uno + Nootropic Video Experimenter shield). The VE shield outputs video with data overlaid.

It’s mostly working, except that if the tv.print() has printed 3 digits (e.g. 125), and the values drop below that, the 5 remains visible. For example: If it has displayed “Motor Speed: 125” and then it drops to 98, the output is “Motor Speed: 985”.
Is there a way to clear the display before rewriting it?

The support staff at Nootropic suggested I add tv.fill(0) but when I do that, I get no output at all. They have not responded to any posts at all on their support forums since just before the US holiday last week…

#include <TVout.h>
#include <fontALL.h>
#define W 136
#define H 96
TVout tv;
char s[26];
void setup() {
tv.begin(NTSC, W, H);
initOverlay();
tv.select_font(font6x8);
tv.fill(0);
Serial.begin(19200);
}
// Initialize ATMega registers for video overlay capability.
// Must be called after tv.begin().
void initOverlay() {
TCCR1A = 0;
// Enable timer1. ICES0 is set to 0 for falling edge detection on input capture pin.
TCCR1B = _BV(CS10);
// Enable input capture interrupt
TIMSK1 |= _BV(ICIE1);
// Enable external interrupt INT0 on pin 2 with falling edge.
EIMSK = _BV(INT0);
EICRA = _BV(ISC01);
}
// Required to reset the scan line when the vertical sync occurs
ISR(INT0_vect) {
display.scanLine = 0;
}
void loop() {
if (Serial.available())
{
sprintf(s,”Motor speed:%i”,Serial.read());
tv.print(0, 0, s);
tv.fill(0);
}
}

Typically, displays need time to refresh. Try to add a delay()

arduino_new:
Typically, displays need time to refresh. Try to add a delay()

Better still, print a space.

I have tried implementing delays of varying length or moving the tv.fill(0) to outside of the if(), with no luck.

@TheMember…: Can you clarify what you mean by “printing a space”?

Can you clarify what you mean by “printing a space”?

Print the value, then if it less than 100 print a space to remove the previously printed third digit. Alternatively, if there is room on the display then always print a space after the value