Adjusting the viewport position of the Video Experimenter output

Store Forums Video Experimenter General Discussion Adjusting the viewport position of the Video Experimenter output

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #8690
    Michael
    Keymaster

    Some people have asked how to adjust the position of the Video Experimenter output on the video screen. The viewport of the TVout library does not always take up the entire screen, and this is a problem if you want to display something at the very top/bottom or left/right on the screen.

    I found a simple way to adjust the position by simply changing two variables in your Arduino sketch. The variable display.output_delay controls horizontal position and the variable display.render_start controls vertical position. I connected two potentiometers to my Arduino to make adjustments and display the values I am setting. Here is a video:

    Unfortunately, when I try to move the viewport to the left, the image gets all corrupted and I’m not sure why. However, it is very successful at shifting the image to the top/bottom or to the right. The results you have on your video output device may vary, so you will need to experiment a bit.

    Here is the code for the whole sketch:

    
    #include <TVout.h>
    #include <fontALL.h>
    
    #define W 136
    #define H 96
    
    TVout tv;
    byte x,y;
    char s[32];
    
    void setup()  {
      tv.begin(NTSC, W, H);
      initOverlay();
      tv.select_font(font6x8);
      tv.fill(0);
    }
    
    // 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() {
      tv.draw_rect(0, 0, W-1, H-1, 1, 0); // bounding rectangle
      uint8_t output_delay = map(analogRead(0), 0, 1023, 130, 255);
      sprintf(s, "OUTPUT_DELAY = %d", output_delay);
      tv.print(16, 32, s);
    
      uint8_t start_render = map(analogRead(1), 0, 1023, 10, 70);
      sprintf(s, "START_RENDER = %d", start_render);
      tv.print(16, 48, s);
    
      tv.delay_frame(1);
      display.output_delay = output_delay;
    
      tv.delay_frame(1);
      display.start_render = start_render;
    
      tv.delay_frame(3);
    }
    
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.