clearing tv.print

Store Forums Video Experimenter Bugs/Problems clearing tv.print

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #11771
    Perry
    Participant

    So in my most recent post, I was creating a heads-up display. Which works – mostly.

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

    It’s mostly working, except that if the tv.print() has printed 3 characters (e.g. 125), and the values drop below that, the 5 remains visible. For example: If it is printing 125 and then it drops to 98, the output is “985”.

    Is there a way to clear the display before rewriting it?

    #11774
    Michael
    Keymaster

    Yes, you can clear the screen with

    tv.fill(0);

    #11776
    Perry
    Participant

    Thank you again for the prompt reply.

    I get no overlay on the screen when I add a tv.fill(0) entry (currently commented out at the bottom).

    My code is:

    `#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);
    }

    }

    #11813
    Michael
    Keymaster

    You are clearing the screen immediately after you display something to it. That is why you are not seeing anything.

    Move tv.fill(0) so you clear the screen BEFORE you write your output.

    tv.fill(0);
    tv.print(0, 0, s);
    #11814
    Perry
    Participant

    That makes a lot of sense. I will give that a go.

    Thanks very much.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.