Go Down

Topic: VGA library - now with TV output (Read 96771 times) previous topic - next topic


Very nice library ! I love it !

Just a little test : Display 256 colors palette.


Code: [Select]

#include <VGA.h>
#define SQAURESIZE 8

void setup() {

double a=0;

void loop() {

  int c=0;
  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++){





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




What about UNO board support? It makes sense to have light version of lib...
DueVGA is too dependent on hardware features only available in the SAM3X chip in the Due (particularly DMA) so it would be impossible to port it to the Uno.
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html


Not to mention going from 96k of ram to 2k..
Great work on this library. I've been looking for something cool to do with my Due, now I may have found it. :)


Jul 22, 2013, 10:18 am Last Edit: Jul 24, 2013, 11:37 am by gadgetoid Reason: 1
I have been working on drawing bitmapped graphics with this library using a couple of techniques:

8-bit, 256 colour PNG images converted to unsigned char arrays of pixels

I have written a utility in Ruby that I'm finalising, which will convert 8-bit PNGs for display using Due VGA. It references a colour-palette PNG image that contains all the displayable colours on the Due, re-ordered so that they are correctly converted to their binary value.

8-bit, 16 colour PNG images converted to one-pixel-per-nibble unsigned char arrays

I have written a utility which, when given a 16-colour index palette, will produce an image at half the storage size. You will only have access to 15 actual colours, as index 0 is reserved for transparency.

Both of these things are in my GitHub and are highly experimental and very unfinished; https://github.com/Gadgetoid/Due-Megadrive-Controller/tree/Tinkering

See the Tools and MDC_VGA folders.

I have also produce an 8-bit palette which can be used with Adobe products (and possibly others) for compressing images for optimal display, see Tools/8bit-truecolor-palette.act

And, finally, a couple of photos to show what you can achieve with these tools:

UPDATE: I have now migrated the Arduino Due VGA specific stuff to a new repository, it was getting cluttered in with my MegaDrive controller library: https://github.com/Gadgetoid/Arduino-DueVGA-Tools

And I've also thrown together a colour table which you can see here: http://pi.gadgetoid.com/arduino-due/DueVGA-colour-table

UPDATE 2: From an idea I had this morning. HSV to RRRGGGBB conversion: https://github.com/Gadgetoid/Arduino-DueVGA-Tools/blob/master/DueVGA_HSV/DueVGA_HSV.ino

@Stimmer this code could be dropped straight into a SetPixelHSV function.


I'd like to know what is the real reason to use the MOSI pin (A26).
Isn't it possible to use another pin, allowing to obtain a simpler connector ?
Thanks in advance for the reply,


gadgetoid: Wow, impressive work! Thanks for the HSV code, I may well add it to the library because it would simplify my fractal demos (which use an ugly look up table at the moment)

fog44: Monochrome mode uses the SPI hardware to generate pixels. Therefore the output has to be on the MOSI pin. I am experimenting if it is possible to use the SSC hardware (in which case output would be on port A.16 / Arduino pin A0) but I don't know if it will work yet.
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html


   Is there a similar library for VGA input?  I want to convert a VGA signal from my computer to a composite RCA output to a TV.

   I figure the problem with this is the processor speed and not being able to both read the incoming signal and generate the outgoing signal quickly enough.  Is that the limiting factor here?

   I suppose I could write a PC application that would capture the screen and send it over serial to the Arduino and fill the frame buffer, and then simply have the Arduino generate the composite video signal.  That may be doable, as long as I can cram that much video data over serial quickly enough to get it to appear to be video instead of stop-motion.

   At 320x240 at 8-bit color, that'd be 76800 bytes of data for the frame buffer, at a baud rate of 115200 (bits per second) or 14400 Bytes/sec.  By my calculation, it'd take 5.3 seconds to transfer one frame, which is far too slow.

   I do have a wifi shield.  I wonder if I can get better throughput using that.  It looks like the wifi benchmarks are pretty good for throughput (can range from 0.7 Mbps to 3.4 Mbps reasonably).  Although, that won't overcome the memory constraint.

   From what I understand, the 480i (interlaced) TV format is equivalent to 640x480 resolution.  Does the fact that the TV format is interlaced mean that that the frame is actually half the size (half-line or every-other line)?  Or will I have to downsample my video to fit the memory of the microcontroller?


You're right about the limiting factor of processing and I/O speed. Also, grabbing a VGA signal would need 3 A/D converters running at 12.5Msps each just for 320x240 :)

In composite mode there still isn't much processing capacity left for input. The closest thing to what you are doing that I have tried is the SD card animation demo, which loads uncompressed animations from an SD card straight into the framebuffer ram. In VGA mode the frame rate is acceptable but in composite mode it slows to a few frames per second (I can't remember exactly how slow it was, but it was unwatchable)
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html


I created a shield to utilize this awesome library you made. I need to order a few more components before I can be sure I got it right, but I suspect it will work fine. I used jumpers to isolate the composite video resistors from the VGA resistors, and I went ahead and tossed in an LM386 amplifier hooked to the DAC0 and DAC1 pins with an audio out jack (may have accidentally selected the very small size audio jack, oops). Oh, and VGA has i2c data, I went ahead and broke out those pins. I left out support for monochrome mode, it just made things more manageable in the PCB layout.
I made a whole bunch of the boards, so once I confirm they actually work, I'll have them up on my Tindie store as DIY kits.. :)


Wow, fantastic work 8)

One suggestion, if you are connecting to DAC0 and DAC1 put 4.7k resistors in series to make sure the output impedance is high enough, some of us have broken our DACs because RLOAD was too low.

I2C could come in useful, it can be used to tell the make and model of the monitor (quite easy, it's in ASCII) and the refresh rates and modes it supports (much harder, it is in a strange binary format)
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html


I've got the DAC's capacitively decoupled from each other, and from the amp chip, definitely don't want to blow my or anyone else's DAC's. I'll keep everyone posted on when the parts come in, and I've had a chance to test out the board.


Ok, the shield I made "works".. I got the polarity backwards on the composite jack, the silkscreen is backwards on the jumpers, so you have to select VGA for composite, and composite for VGA.. DOH.. And the audio output jack is 2.5mm rather than 3.5mm.. It all works, so I'm going to respin the board and have another batch made. Anyone want one of these mostly working boards?
Great job on the library guys. I went ahead and added a jack for a Wii nunchuck adapter to the next rev, maybe someone can use this shield and this library to write video games. :)


Ok, the board works well enough that I know the minor fixes will solve the minor mistakes of the first batch. I went ahead and listed them as a fundraiser on Tindie. Hope you don't mind me linking to your video stimmer, that was a pretty epic demonstration. :)


Thanks For Awe Some Library :D

I ask If you can Make tutorials for how you can make the Timing Signals Using The Arduino Board

And How you Write Library Like That If you can

I will be very Glad To learn from you

I know that my Request is strange some way :)

Thanks In Advance

Go Up