Hello All,
I came out with this simple driver, writen entirely in micropython, (v1.18 pico firmware), allowing to use a VGA screen with a 640x480 resolution and 3 bits per pixel (8 colors).
My purpose was just to learn how to use PIO programming and synchronization with DMA, but I might as well share the result of this with the community.
Since the pico does not have a tremendous amount of memory for this kind of usage, I saved space by using 32 bits words (and only using 30 bits out of them).
In the end the buffer for the whole frame takes 120k of RAM, wich leaves the PICO with approx 50k to do some stuff with micropython
Synchronization between PIO and DMA is achived using PIO Irqs.
I got inspiration from :
- This project (for the pico, written in c) very well documented by V. Hunter Adams (vha3@cornell.edu) https://vanhunteradams.com/Pico/VGA/VGA ... ganization
- The explanations provided on this forum by Roberthh and the tools he posted on github https://github.com/robert-hh/RP2040-Exa ... r/rp2_util
I added the possibility to overclock the pico to 250MHz, but in the end it does not really impact the picture quality. I coded a few routines to draw rectangles/lines/circle, for testing purpose.
I tried to document the code as much as I could. Since I am still a beginner, I have no doubt that this can be optimized quite a lot.
If any of you is interested in using or improving it, i'll be happy to provide further explanations.
Code is here : https://github.com/HughMaingauche/PICO-VGA-Micropython
Simple VGA driver using Pico and micropython
-
- Posts: 15
- Joined: Sun Aug 15, 2021 9:34 pm
Simple VGA driver using Pico and micropython
- Attachments
-
- 20220306_174803.jpg (157.03 KiB) Viewed 5474 times
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Simple VGA driver using Pico and micropython
If you're a beginner that's extremely impressive!
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 15
- Joined: Sun Aug 15, 2021 9:34 pm
Re: Simple VGA driver using Pico and micropython
Hello pythoncoder,
well when i see you guys on this forum i really feel like i am a beginner. This thing took me 2 weeks and a lot of thinking (and also a scope). I turned 50 recently and I am totally amazed by the capabilities of such a small device.
I think this pico can do more than the CPC 464 i've had on my 14th birthday. To make sure of this I implemented a simple font and draw some nice plots !!! (see below)
well when i see you guys on this forum i really feel like i am a beginner. This thing took me 2 weeks and a lot of thinking (and also a scope). I turned 50 recently and I am totally amazed by the capabilities of such a small device.
I think this pico can do more than the CPC 464 i've had on my 14th birthday. To make sure of this I implemented a simple font and draw some nice plots !!! (see below)
Re: Simple VGA driver using Pico and micropython
This looks really neat. Out of interest, what VGA board / adapter are you using to connect to the Pico? It looks like something separate, rather than something like the Pimoroni base with VGA. #curious
-
- Posts: 15
- Joined: Sun Aug 15, 2021 9:34 pm
Re: Simple VGA driver using Pico and micropython
Hello andypiper,
there is no VGA board, the pico GPIO pins are connected directly to the VGA cable via 300ohms resistors to drop the 3.3V to 0.7V on the red/blue/green inputs, and 47ohms resistors for impedance adjustment on the Hsync/Vsync inputs.
It is connected to the VGA cable via a simple header (see here) and that is maybe what you think is a separate board.
There is nothing more on the picture. The black square-shaped thing you see on my breadboard is a 3.3v lithium battery which is not related and not wired to anything.
there is no VGA board, the pico GPIO pins are connected directly to the VGA cable via 300ohms resistors to drop the 3.3V to 0.7V on the red/blue/green inputs, and 47ohms resistors for impedance adjustment on the Hsync/Vsync inputs.
It is connected to the VGA cable via a simple header (see here) and that is maybe what you think is a separate board.
There is nothing more on the picture. The black square-shaped thing you see on my breadboard is a 3.3v lithium battery which is not related and not wired to anything.