Show Posts
Pages: [1] 2 3 ... 10
1  Using Arduino / Displays / Re: TVout: NTSC and PAL Composite Video Output. on: February 25, 2011, 05:08:49 pm
Does the tvout sketch work when you send data from the pc?
2  Using Arduino / Displays / Re: TVout: NTSC and PAL Composite Video Output. on: February 24, 2011, 04:43:00 pm
@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.
3  Using Arduino / Displays / Re: TVout on: February 20, 2011, 06:25:41 am
lets say we have a 16pixel line: pixel 0,1,2..15
it would be encoded like so:

byte1{0,1,2,3,4,5,6,7} byte2{8,9,10,11,12,13,14,15}

Each line must be a multiple of 8 pixels.
4  Using Arduino / Displays / Re: NTSC on: February 19, 2011, 09:22:29 pm
FYI the vertical sync pulses in the link KE7GKP posted are not correct, they will work most of the time however(its what TVout does).

A few more links:
http://www.sxlist.com/techref/io/video/ntsc.htm
http://www.batsocks.co.uk/readme/video_timing.htm
5  Using Arduino / Displays / Re: TVout on: February 19, 2011, 09:13:44 pm
TVout uses a 1bit encoding.  So each byte contains 8 pixels worth of data.
ie 0x00 = 8 black pixels and 0xff = 8 white pixels.
6  Using Arduino / Displays / Re: TVout: NTSC and PAL Composite Video Output. on: February 08, 2011, 10:11:00 pm
@schumixmd
I haven't done anything with OSD capabilities but TVout has been modified to do this previously (search the old thread linked to in the first post).  An OSD has also been done with nothing more than a few resistors see (not TVout based but this is where I had planned on starting if I was to create a TVout OSD version): http://www.elenafrancesco.org/arduino/baroneosd/ which will do some basic text overlay.

As far as the pollserial issues that is odd but not all that surprising as I did'nt do much testing beyond the super basic terminal app meant as a quick example on using the hbi_hook.  If I remember correctly pollserial goes a bit crazy if the rx buffer gets full maybe start there? (make sure to handle the data fast enough maybe)

@gijs
I very much enjoyed those videos you achieved some very cool effects.
7  Using Arduino / Displays / Re: TVout: NTSC and PAL Composite Video Output. on: January 31, 2011, 08:56:57 pm
Well the issue that has stopped me from changing the vsync is the fact that I still don't have an oscilloscope or a logic analyzer to actually confirm the signal.  In addition to that I started working in my field and don't have as much time right now to work on this.

If you are just trying to display text then maybe the tellymate firmware or tvtext would do what is needed right away.
8  Using Arduino / Displays / Re: TVout: NTSC and PAL Composite Video Output. on: January 30, 2011, 09:53:57 am
@TECH GEEK
If you are still having troubles getting it to work properly I would try a different tv if possible and if the problem persists double check all the connections.  The last thing to try is putting a 75ohm resistor across video connection and GND.

@laarka
Yes there are some timing issues. The problem is in the vertical sync the approach I took is no where near what the signal is supposed to be.  This signal will work just fine on regular tube tvs but on newer tvs can have issue with it.  If your small lcd will accept a PAL signal try that as my capture card works far better with PAL than NTSC and maybe your little TV will too.

Yes the interrupts will screw with any existing time sensitive code.  To combat this I wrote a replacement for millis and delay that will remain accurate (just call TV.delay() and TV.millis()).
There are some restrictions to the accuracy with these replacement functions as they work by counting scan-lines.  Their are also function pointers now that will for automatic management of devices in the background.  To see how they work take a look at the included serial terminal example and the pollserial library which is just a modified version of hardware serial.

@crosh
yeah that would be a good link to add drrr.
9  Using Arduino / Displays / Re: TVout: NTSC and PAL Composite Video Output. on: January 29, 2011, 03:15:31 pm
Place the three folders in the zip directly into the Documents\Arduino\libraries folder so it would contain:
pollserial
TVout
TVoutfonts
10  Using Arduino / Displays / Re: TVout: NTSC and PAL Composite Video Output. on: January 29, 2011, 01:03:20 pm
You need to install the library, go to the google code page linked to in the first post.  Simply download TVoutBeta1 and unzip it to your arduino/libraries folder.  The posted sketch is an example sketch that can be found in File-Examples-TVout once the library has been installed.
11  Using Arduino / Displays / Re: TVout: NTSC and PAL Composite Video Output. on: January 29, 2011, 12:52:41 pm
Sure post the errors and Ill see what I can do.
12  Using Arduino / Displays / TVout: NTSC and PAL Composite Video Output. on: January 29, 2011, 11:59:44 am
I had a thread in the old forums and as this section is for video output I though I would start a new thread here.

Anyway, TVout is an interrupt driven composite video output Library using only 2 resistors to generate a black and white signal at configurable resolutions (defaults to 128x96). It can output text with several included fonts, draw simple shapes, bitmaps, generate 1bit audio, and allows direct access to the frame buffer for custom display routines.

This Library does restrict the use of interrupts (like the ones used by the Serial library) to combat this it includes 2 hooks for calling functions at fixed intervals. One occurs every scan-line and is suitable for very fast methods such as polling the serial connection; this is demon-straighted in the add-on library pollserial.  The second occurs once per frame for longer methods like polling a game-pad or plying music in the background.

Full documentation on this library can be found here: http://code.google.com/p/arduino-tvout/wiki/Welcome?tm=6

Output Schematic:

Specific Connections per device can be found on the Google code page.

Example Video and Source Code (excluding image data):

Code:
#include <TVout.h>
#include <fontALL.h>
#include "schematic.h"
#include "TVOlogo.h"

TVout TV;

int zOff = 150;
int xOff = 0;
int yOff = 0;
int cSize = 50;
int view_plane = 64;
float angle = PI/60;

float cube3d[8][3] = {
  {xOff - cSize,yOff + cSize,zOff - cSize},
  {xOff + cSize,yOff + cSize,zOff - cSize},
  {xOff - cSize,yOff - cSize,zOff - cSize},
  {xOff + cSize,yOff - cSize,zOff - cSize},
  {xOff - cSize,yOff + cSize,zOff + cSize},
  {xOff + cSize,yOff + cSize,zOff + cSize},
  {xOff - cSize,yOff - cSize,zOff + cSize},
  {xOff + cSize,yOff - cSize,zOff + cSize}
};
unsigned char cube2d[8][2];


void setup() {
  TV.begin(NTSC,120,96);
  TV.select_font(font6x8);
  intro();
  TV.println("I am the TVout\nlibrary running on a freeduino\n");
  TV.delay(2500);
  TV.println("I generate a PAL\nor NTSC composite  video using\ninterrupts\n");
  TV.delay(2500);
  TV.println("My schematic:");
  TV.delay(1500);
  TV.bitmap(0,0,schematic);
  TV.delay(10000);
  TV.clear_screen();
  TV.println("Lets see what\nwhat I can do");
  TV.delay(2000);
  
  //fonts
  TV.clear_screen();
  TV.println(0,0,"Multiple fonts:");
  TV.select_font(font4x6);
  TV.println("4x6 font FONT");
  TV.select_font(font6x8);
  TV.println("6x8 font FONT");
  TV.select_font(font8x8);
  TV.println("8x8 font FONT");
  TV.select_font(font6x8);
  TV.delay(2000);
  
  TV.clear_screen();
  TV.print(9,44,"Draw Basic Shapes");
  TV.delay(2000);
  
  //circles
  TV.clear_screen();
  TV.draw_circle(TV.hres()/2,TV.vres()/2,TV.vres()/3,WHITE);
  TV.delay(500);
  TV.draw_circle(TV.hres()/2,TV.vres()/2,TV.vres()/2,WHITE,INVERT);
  TV.delay(2000);
  
  //rectangles and lines
  TV.clear_screen();
  TV.draw_rect(20,20,80,56,WHITE);
  TV.delay(500);
  TV.draw_rect(10,10,100,76,WHITE,INVERT);
  TV.delay(500);
  TV.draw_line(60,20,60,76,INVERT);
  TV.draw_line(20,48,100,48,INVERT);
  TV.delay(500);
  TV.draw_line(10,10,110,86,INVERT);
  TV.draw_line(10,86,110,10,INVERT);
  TV.delay(2000);
  
  //random cube forever.
  TV.clear_screen();
  TV.print(16,40,"Random Cube");
  TV.print(28,48,"Rotation");
  TV.delay(2000);
  
  randomSeed(analogRead(0));
}

void loop() {
  int rsteps = random(10,60);
  switch(random(6)) {
    case 0:
      for (int i = 0; i < rsteps; i++) {
        zrotate(angle);
        printcube();
      }
      break;
    case 1:
      for (int i = 0; i < rsteps; i++) {
        zrotate(2*PI - angle);
        printcube();
      }
      break;
    case 2:
      for (int i = 0; i < rsteps; i++) {
        xrotate(angle);
        printcube();
      }
      break;
    case 3:
      for (int i = 0; i < rsteps; i++) {
        xrotate(2*PI - angle);
        printcube();
      }
      break;
    case 4:
      for (int i = 0; i < rsteps; i++) {
        yrotate(angle);
        printcube();
      }
      break;
    case 5:
      for (int i = 0; i < rsteps; i++) {
        yrotate(2*PI - angle);
        printcube();
      }
      break;
  }
}

void intro() {
unsigned char w,l,wb;
  int index;
  w = pgm_read_byte(TVOlogo);
  l = pgm_read_byte(TVOlogo+1);
  if (w&7)
    wb = w/8 + 1;
  else
    wb = w/8;
  index = wb*(l-1) + 2;
  for ( unsigned char i = 1; i < l; i++ ) {
    TV.bitmap((TV.hres() - w)/2,0,TVOlogo,index,w,i);
    index-= wb;
    TV.delay(50);
  }
  for (unsigned char i = 0; i < (TV.vres() - l)/2; i++) {
    TV.bitmap((TV.hres() - w)/2,i,TVOlogo);
    TV.delay(50);
  }
  TV.delay(3000);
  TV.clear_screen();
}

void printcube() {
  //calculate 2d points
  for(byte i = 0; i < 8; i++) {
    cube2d[i][0] = (unsigned char)((cube3d[i][0] * view_plane / cube3d[i][2]) + (TV.hres()/2));
    cube2d[i][1] = (unsigned char)((cube3d[i][1] * view_plane / cube3d[i][2]) + (TV.vres()/2));
  }
  TV.delay_frame(1);
  TV.clear_screen();
  draw_cube();
}

void zrotate(float q) {
  float tx,ty,temp;
  for(byte i = 0; i < 8; i++) {
    tx = cube3d[i][0] - xOff;
    ty = cube3d[i][1] - yOff;
    temp = tx * cos(q) - ty * sin(q);
    ty = tx * sin(q) + ty * cos(q);
    tx = temp;
    cube3d[i][0] = tx + xOff;
    cube3d[i][1] = ty + yOff;
  }
}

void yrotate(float q) {
  float tx,tz,temp;
  for(byte i = 0; i < 8; i++) {
    tx = cube3d[i][0] - xOff;
    tz = cube3d[i][2] - zOff;
    temp = tz * cos(q) - tx * sin(q);
    tx = tz * sin(q) + tx * cos(q);
    tz = temp;
    cube3d[i][0] = tx + xOff;
    cube3d[i][2] = tz + zOff;
  }
}

void xrotate(float q) {
  float ty,tz,temp;
  for(byte i = 0; i < 8; i++) {
    ty = cube3d[i][1] - yOff;
    tz = cube3d[i][2] - zOff;
    temp = ty * cos(q) - tz * sin(q);
    tz = ty * sin(q) + tz * cos(q);
    ty = temp;
    cube3d[i][1] = ty + yOff;
    cube3d[i][2] = tz + zOff;
  }
}

void draw_cube() {
  TV.draw_line(cube2d[0][0],cube2d[0][1],cube2d[1][0],cube2d[1][1],WHITE);
  TV.draw_line(cube2d[0][0],cube2d[0][1],cube2d[2][0],cube2d[2][1],WHITE);
  TV.draw_line(cube2d[0][0],cube2d[0][1],cube2d[4][0],cube2d[4][1],WHITE);
  TV.draw_line(cube2d[1][0],cube2d[1][1],cube2d[5][0],cube2d[5][1],WHITE);
  TV.draw_line(cube2d[1][0],cube2d[1][1],cube2d[3][0],cube2d[3][1],WHITE);
  TV.draw_line(cube2d[2][0],cube2d[2][1],cube2d[6][0],cube2d[6][1],WHITE);
  TV.draw_line(cube2d[2][0],cube2d[2][1],cube2d[3][0],cube2d[3][1],WHITE);
  TV.draw_line(cube2d[4][0],cube2d[4][1],cube2d[6][0],cube2d[6][1],WHITE);
  TV.draw_line(cube2d[4][0],cube2d[4][1],cube2d[5][0],cube2d[5][1],WHITE);
  TV.draw_line(cube2d[7][0],cube2d[7][1],cube2d[6][0],cube2d[6][1],WHITE);
  TV.draw_line(cube2d[7][0],cube2d[7][1],cube2d[3][0],cube2d[3][1],WHITE);
  TV.draw_line(cube2d[7][0],cube2d[7][1],cube2d[5][0],cube2d[5][1],WHITE);
}

Tetris Using either a Hackvision or a Video Game Shield with a wii classic controller(can wire it up without the shield too) for input:

13  Using Arduino / Displays / Re: How Can I Make a PONG-Like Game on a TV? on: January 29, 2011, 11:21:59 am
http://code.google.com/p/arduino-tvout/

Pong has been done several times.
I ported an open version of tetris to the arduino (available on the TVout page).
If you follow the links on the TVout page there are a few other games running on it.
14  Forum 2005-2010 (read only) / Troubleshooting / Re: TVOUT on PAL tv? on: January 16, 2011, 02:01:39 pm
Yes some tvs do require the 75ohm resistor it all depends on the tv with mine it makes no difference.

If you attempt to check the voltages with a multi meter then there does need to be a 75ohm load across the output.
15  Forum 2005-2010 (read only) / Troubleshooting / Re: TVOUT on PAL tv? on: January 11, 2011, 04:24:03 pm
TV.begin(PAL)

 should work.
Pages: [1] 2 3 ... 10