Go Down

Topic: TVout: NTSC and PAL Composite Video Output. (Read 13 times) previous topic - next topic

mdmetzle


@mdmetzle, Thanks!

I am looking for a way to get the tvout lib to let one pin go HIGH when there is a white pixel, and another pin go HIGH when there is a black pixel..

it should probably be done close to here, but i don't understand this..:

__asm__ __volatile__ (
   "ADD   r26,r28\n\t"
   "ADC   r27,r29\n\t"
   //save PORTB
   "IN      r16,%[port]\n\t"
   "ANDI   r16,0xFD\n\t"
   
(the above is from version 3 of the tvout lib, video_gen.ccp).



The first two lines are a 16bit add and are calculating the pointer to the current render line in the frame buffer.  The second 2 lines grab the port containing the output pin and set it to the video pin to low and the sync pin(if applicable in later versions) high.  Then through out the rest of the line rendering routine the video pin is modified and the rest of the port is left alone.  If you dont care about the port status then the these lines are not needed.

leo72

Hello.
A couple of days ago I tried to realize a little idea of mine...
I used 2 standalone Atmega328 on a breadboard: the first one runs a sketch that uses the PS2Keyboard lib to read the input from a PS2 keyboard, the second one has a sketch inside che reads the input from the first Atmega and then sends the output on the TV.

But I'm having a strange problem: keys that I see on the TV are different from the ones I press on the keyboard.... I.E. I get [ESC] from "h" or "3[ESC]" from "7" etc...

Strange because if I connect the first Atmega to an Arduino and send the keys I read from the keyboard to a serial terminal open under the Arduino IDE I can see the correct keys (i.e. if I digit "h"-"e"-"l-"l"-"o" I see "hello"), so I can say for sure that the connection of the keyboard is OK. It seems that "pollserial" doesn't read the correct datas.

I connected the 2 Atmega using pins 2 and 3 (RX & TX): of course, 2->3 and 3->2.
This is the sketch on the first Atmega:
Code: [Select]
/*  PS2Keyboard library example*/
   
#include <PS2Keyboard.h>

const int DataPin = 2;
const int IRQpin =  3;

PS2Keyboard keyboard;

void setup() {
  delay(2000);
  keyboard.begin(DataPin, IRQpin);
  Serial.begin(9600);
}

void loop() {
  if (keyboard.available()) {
   
    // read the next key
    char c = keyboard.read();
   
    // check for some of the special keys
    if (c == PS2_ENTER) {
      Serial.println();
    } else if (c == PS2_TAB) {
      Serial.print("[Tab]");
    } else if (c == PS2_ESC) {
      Serial.print("[ESC]");
    } else if (c == PS2_PAGEDOWN) {
      Serial.print("[PgDn]");
    } else if (c == PS2_PAGEUP) {
      Serial.print("[PgUp]");
    } else if (c == PS2_LEFTARROW) {
      Serial.print("[Left]");
    } else if (c == PS2_RIGHTARROW) {
      Serial.print("[Right]");
    } else if (c == PS2_UPARROW) {
      Serial.print("[Up]");
    } else if (c == PS2_DOWNARROW) {
      Serial.print("[Down]");
    } else if (c == PS2_DELETE) {
      Serial.print("[Del]");
    } else {
     
      // otherwise, just print all normal characters
      Serial.print(c);
    }
  }
}


This is the sketch that is running on the second Atmega:
Code: [Select]
#include <TVout.h>
#include <pollserial.h>
#include <fontALL.h>

TVout TV;
pollserial pserial;

void setup()  {
  TV.begin(_PAL,120,96);
  TV.select_font(font6x8);
  TV.println("Terminale seriale");
  TV.println("-- Versione 0.1 --");
  TV.set_hbi_hook(pserial.begin(9600));
}

void loop() {
  if (pserial.available()) {
    TV.print((char)pserial.read());
  }
}

pocketscience

Is life really that serious...??!

leo72

What do you mean?
That I don't have to use common grounds or that I have to use them?  :smiley-roll-sweat:

mdmetzle

Does the tvout sketch work when you send data from the pc?

Go Up