VGA library - now with TV output

Thanks :slight_smile:

I've merged in the PAL and NTSC branches so the VGA library now does TV output. The circuit uses just 6 resistors and a capacitor. Quality is... err... well if you remember what home computers used to be like in the 80s you will have a fair idea of how low to set your expectations :wink:

Resolution is fixed at 320x240 in PAL and 320x200 in NTSC. I've tested it on 5 different TVs and monitors, but my timings are quite a way off spec so I would expect some trouble particularly on old TVs. I'll try and do a proper release tomorrow but the code is already on Github.

rdac.png

First of all, really great work!

I tried the DrawingTestPal example of your library with the Arduino Ide 1.5.2 on my Arduino Due, but it show me this error :

In file included from DrawingTestPAL.ino:1:
C:\Users\andrea\Desktop\Andrea\Arduino\arduino-1.5.2\libraries\VGA/VGA.h: In function 'void _v_digitalWriteDirect(int, boolean)':
C:\Users\andrea\Desktop\Andrea\Arduino\arduino-1.5.2\libraries\VGA/VGA.h:49: error: 'g_APinDescription' was not declared in this scope
C:\Users\andrea\Desktop\Andrea\Arduino\arduino-1.5.2\libraries\VGA/VGA.h:50: error: 'g_APinDescription' was not declared in this scope

Ithos92:
First of all, really great work!

I tried the DrawingTestPal example of your library with the Arduino Ide 1.5.2 on my Arduino Due, but it show me this error :

In file included from DrawingTestPAL.ino:1:

C:\Users\andrea\Desktop\Andrea\Arduino\arduino-1.5.2\libraries\VGA/VGA.h: In function 'void _v_digitalWriteDirect(int, boolean)':
C:\Users\andrea\Desktop\Andrea\Arduino\arduino-1.5.2\libraries\VGA/VGA.h:49: error: 'g_APinDescription' was not declared in this scope
C:\Users\andrea\Desktop\Andrea\Arduino\arduino-1.5.2\libraries\VGA/VGA.h:50: error: 'g_APinDescription' was not declared in this scope

Make sure you have selected Arduino Due in the Tools/Board menu - that's the main cause of that particular error message.

stimmer:
Make sure you have selected Arduino Due in the Tools/Board menu - that's the main cause of that particular error message.

It works!

Thank you!

Quick preview of the next release: Only minor bugfixes in the library, although one of those bugs was causing a hang when receiving Serial data, so if you use Serial and VGA you should upgrade (the fix is already in github master if you need it now)

The major addition is a new demo, which decodes GPS GPGGA/GPGSV strings and shows a rotated globe and satellite positions. Data can be taken from a real GPS or entered in the serial monitor. You have probably seen smartphone apps which do this, well now you can do it on an Arduino too 8) Watch satellites move across the sky in real time (although only if you are very patient as it takes the satellites 6 hours to get from one side of their orbit to the other!)

Sparkfun has a VGA breakout introduced lately, can this make connections for Due users easier? Papilio VGA Wing - WIG-11569 - SparkFun Electronics

Yes you could use that although it is actually 6 bit, not 8, so in colour mode you would only get 64 colours (you might be able to get all 256 by adding a few extra resistors). Mono mode should be just fine. It would need a bit of work to wire it to the right pins - it wouldn't just be able to plug straight into the Due like it can with a Papilio.

Stimmer,
I downloaded the library, but running into issues when also using the SDFat library to read my graphics off the SD Card. Any thoughts why these libraries conflict? Is there any potential for making them able to work together? It was possible previously with the PWM version.

I'd really like to use the VGA library because it's so convienient, but reading the graphics data off the SD card is absolutely needed (ie: I can't load the bitmap into the VGA library framebuffer without the SDFat library being initialized at the same time). I was hoping to take advantage of the speed increases you mentioned before, as well as the image stabilization using the additional timer.

Thanks for any info you can provide.

If it worked before I'd say there's a good chance that it will work again. I'll take a look at it later today.

Could you tell me a few things: which VGA screen mode are you using (mono, colour, PAL or NTSC), and which exact version of the SDFat library are you using and how is it wired up?

Stimmer,

VGA Library:
stimmer-DueVGA-0.404-3-g86f6dc0

Color at 320x240

Adruino Pin
34, 35 --> Blue
36, 37, 38 --> Red
39, 40, 41 --> Green
42, 43 --> Hsync / Vsync

I'm using the Arduino Wifi Shield (R2) with onboard SD Card reader. I'm not actually using the Wifi functions at the moment.

SDFat Library:
SdFatBeta20130207

Thanks - could you please try the following as a temporary workaround.

In the SdFat library, in file Sd2Card.cpp on line 85:
change "#define USE_SAM3X_DMAC 1" to "#define USE_SAM3X_DMAC 0"

Tell me if it works, and if it does work is the SdFat library now too slow or at an acceptable speed?

It looks like there is a DMA clash between the VGA and SdFat libraries. It should be possible to sort it out properly somehow - there should be a way to use DMA for both at the same time.

Stimmer,
Thanks for the advice. Switched to

#define USE_SAM3X_DMAC 0

in the SDFat library, and everything works perfectly now.

Thanks for letting me know. I think I have found out what the actual problem is (basically in DMA mode SdFat gets SPI overruns if anything else is using DMA at the same time) but I'll bring it up in the SdFat thread where fat16lib is more likely to see it.

OK, after a lot of testing and debugging it turns out that using the #define USE_SAM3X_DMAC 0 workaround posted above is the fastest and best solution I can find to the problem of running DueVGA and SdFat together.

Does running SdFat at a slower SPI speed like this work?

  if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();

No, even at SPI_SIXTEENTH_SPEED they still wouldn't work together in DMA mode.

I'm happy with the speed in non-DMA mode. It's fast enough for uncompressed full-screen animation at about 15fps. The code just loads each frame directly into the colour buffer:

#include <VGA.h>
#include <SdFat.h>

const int chipSelect = SS; // you may need to change this to the pin you connected SS to

SdFat sd;
SdFile file;

void setup() {
  VGA.begin(320,240,VGA_COLOUR);
  sd.begin(chipSelect, SPI_FULL_SPEED);
  file.open("anim.dat", O_READ);
}

void loop() {
  file.rewind();
  while(file.available()){
    file.read(VGA.cb,320*240);
  }
}

I've attached a video of the output (though being a highly compressed shaky video of a shaky video it doesn't look as good as it does in real life!)

shot0001.png

duevgaanim.mp4 (2.93 MB)

1 Like

I've made a new release of the library. Get it here: DueVGA-0.512.zip This release fixes a few bugs and clashes between DueVGA and the Serial and Audio libraries.

It also includes three longer demos - the GPS demo and the Animation demos have been posted above already, the other one is a demo of a waterfall plot. This takes an audio signal as inout, samples it and performs a FFT, and shows the result on a scrolling display. See the video and screenshot below for an example of what it does.

Very nice library ! I love it !

Just a little test : Display 256 colors palette.

Eddy

#include <VGA.h>
#define SQAURESIZE 8

void setup() {
  VGA.begin(320,240,VGA_COLOUR);
}

double a=0;

void loop() {

  int c=0;
  VGA.waitSync();
  
  double x = (320-SQAURESIZE*16)/2; 
  double y = (240-SQAURESIZE*16)/2;
  VGA.drawText("256 colors!",116,y-20,255,0);
  for (int j=0; j<16; j++){
    for (int i=0; i<16; i++){
      VGA.fillRect(i*SQAURESIZE+x,j*SQAURESIZE+y,i*SQAURESIZE+SQAURESIZE-1+x,j*SQAURESIZE+SQAURESIZE-1+y,c);
      c++;

    } 
  } 


}

Hi,

What about UNO board support? It makes sense to have light version of lib...