Stationary Text with timer and a varying distance

Store Forums Video Experimenter General Discussion Stationary Text with timer and a varying distance

Tagged: , ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #9022
    canulker
    Participant

    Hello there, we are trying to show the distance we are measuring on the monitor. Aside from that we have a crossair and a time indicator. The following code was working very fine until I merged it with the code of the rangefinder. Then I uploaded this code to the arudino again but now I get nothing. What am I doing wrong? Thank you for your help.

    #include “TVout.h”
    #include “fontALL.h”

    TVout TV;

    unsigned long t;
    int s=0;
    int m=0;
    int h=0;

    void setup()
    {
    TV.begin(PAL,128,96);
    initOverlay();
    TV.select_font(font4x6);

    }

    // 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;

    // Crossair
    TV.draw_line(66,47,66,52,1);
    TV.draw_line(66,56,66,61,1);
    TV.draw_line(59,54,65,54,1);
    TV.draw_line(68,54,74,54,1);
    }

    void loop()
    {
    //Timer
    t=millis()/1000;
    s=t-(h*3600+m*60);
    if (s==60)
    { s=s-60;
    m=m+1;}
    if (m==60)
    {m=0;
    h=h+1;}
    TV.set_cursor(0,6);
    if (h<10) //<——————– YA DA BU PRINTLERDE
    TV.print(0);
    TV.print(h);
    TV.print(“:”);
    if (m<10)
    TV.print(0);
    TV.print(m);
    TV.print(“:”);
    if (s<10)
    TV.print(0);
    TV.print(s);

    //Distance

    TV.set_cursor(105,6);
    // TV.print(sf10_string);
    TV.print(” m”);

    //Zoom
    TV.set_cursor(55,6);
    TV.print(“Zoom: ?”);
    delay(500);

    }

    #9025
    Michael
    Keymaster

    You are drawing your crosshair in the ISR(INT0_vect) interrupt handler. I do not think you should be doing that. All your drawing should be in loop(). Should the crosshair drawing be at the beginning of loop()?

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