VGA/TV display on Raspberry Pico

Overview
PicoVGA - VGA/TV display on Raspberry Pico
------------------------------------------
Miroslav Nemecek, panda38.sweb.cz, [email protected]

How to install:
- Install compiler gcc-arm-none-eabi-10-2020 into folder C:\ARM10
- Unpack this package into some folder

If you have gcc compiler installed in another folder,
 edit PATH in files _c1.bat and _boot2\c.bat

I recommend FAR Manager as program editor - it contains
 very useful console output.

To compile demo project, run c.bat (or c_all.bat to compile all).
To clear demo project, run d.bat (or d_all.bat to clear all).
To write demo project to the Pico board:
 - press and hold BOOTSEL button on the Pico board
 - connect USB cable
 - release BOOTSEL button
 - edit destination drive (now there is r:) in file _e1.bat, command:
       copy /b program.uf2 r:
   and then run e.bat 
   ... or drag and drop file 'program.uf2' to Pico drive.


How to connect VGA display
--------------------------
GP0 ... VGA B0 ... resistor 1K0 to Blue output
GP1 ... VGA B1 ... resistor 390 to Blue output
GP2 ... VGA G0 ... resistor 2K2 to Green output
GP3 ... VGA G1 ... resistor 1K0 to Green output
GP4 ... VGA G2 ... resistor 470 to Green output
GP5 ... VGA R0 ... resistor 2K2 to Red output
GP6 ... VGA R1 ... resistor 1K0 to Red output
GP7 ... VGA R2 ... resistor 470 to Red output
GP8 ... VGA SYNC synchronization ... resistor 100 to HSYNC or composite sync CSYNC

GP19 ... PWM sound output (RC LOW filter 1K5 resistor + 10n capacitor)


How to connect Pico to PC with serial port
------------------------------------------
Most demo projects are prepared to control via USB serial port adapter.
USB interface is selected in Makefile with this parameter:
DEFINE += -DPICO_STDIO_USB=1

Instead of it, you can use serial port. Change Makefile parameter to:
DEFINE += -DPICO_STDIO_UART=1

To connect Pico to PC via serial port, you need either convertor from
RS232 COM port from 3.3V levels of Pico board, or you need convertor
to USB port. Good choise is USB-serial adaptor PL2303TA.

   How to connect UART to Pico:
                    +---USB---+
   <-- UART0_TX GP0 |.1    40.|VBUS --- +5V power output to USB device
   --> UART0_RX GP1 |.2    39.|VSYS ---|<|--- +5V power input
   ---          GND |.3    38.| GND  K diode A
                GP2 |.4    37.| 3V3_EN
                GP3 |.5    36.| 3V3_OUT
                      ......
   Note: in simple case, you need not diode, you can connect +5V directly on board.

   connect USB/UART adaptor PL2303TA:
       red ......... +5V VSYS (39)
       black ....... GND (3)
       white RxD ... UART0_TX GP0 (1)
       green TxD ... UART0_RX GP1 (2)

   You need console program (as PuTTY) to see demo text.
   Setup port to 115200 Baud, 8 bits, 1 stop bit, no parity,
   flow control None.

   In Device Manager, USB adaptor can be found under name:
           "Prolific USB-to-Serial Comm Port (COM10)".


PicoVGA examples
----------------
Ants - card game
	keyboard control: 'J' left, 'L' right, space select, 'D' discard, 'H' help, 'Q' quit

Balloons - sprite demo, floating balloons

Draw - draw graphics demo

Earth - rotating Earth globe

Eggs - game of Eggs+Chickens+Hens, variant of the Reversi game
	keyboard control: 'L' right, 'I' up, 'J' left, 'K' down, 'H' help, 'Q' quit, 'P' 2 players, 'D' demo, space stone, Enter ok

Fifteen - game
	keyboard control: 'L' right, 'I' up, 'J' left, 'K' down, 'Q' new game

Flag - animation of flag fluttering in the wind

Ghost Racing - car racing game, racing with player's ghost copy, demonstration of 3D perspective projection
	keyboard control: 'I' gear up, 'K' gear down, 'J' turn left, 'L' turn right

Ginger House - picture fairy tale book
	keyboard control: 'J' previous page, 'L' next page

Hello - simple demonstration, print text "Hello world!" on the screen

Hypno - hypnotizing rotating pattern

Level Meter - demo of music volume level indication

Life - game, reproducing cells
	keyboard control: 'L' right, 'I' up, 'J' left, 'K' down, 'C' copy, 'V' paste, 'D' clear,
		space flip state, Enter run life, 0..9 select slot

Lines - moving line patterns

Mandelbrot - fractal pattern generator
	keyboard control: 'E' up, 'S' left, 'D' right, 'X' down, 'Q' zoom in, 'A' zoom out,
	'L' low resolution 132x100, 'M' medium resolution 264x200, 'H' high resolution 528x400,
	'I' integer arithmetics, 'F' float arithmetics, 'B' double arithmetics,
	'O' decrease number of steps, 'P' increase number of steps, 'U' increase system clock,
	'T' decrease system clock, space redraw

Matrix Rain - simulation of Matrix code rain

Maze - game, simple maze with maze generator
	keyboard control: 'J' left, 'I' up, 'L' right, 'K' down, 'H' help (show door)

Monoscope - test of various graphic modes
	keyboard control: '0'..'9', 'A'..'U' select videomode

Oscilloscope - demo oscilloscope simulator

Pacman - game of popular Pac-man
	keyboard control: 'J' left, 'I' up, 'L' right, 'K' down, 'A' pause

Pi - calculate Pi at 4800 digits

Pixels - random pixels

Raytrace - ray tracing 3D demonstration of mirror spheres

Sokoban - game with 3000 puzzles and with their solutions
	keyboard control: 'L' right, 'I' up, 'J' left, 'K' down, 'H' help (solution),
	'R' restart scene, 'Q' previous level, 'W' next level, 'P' info

Spheres - draw random spheres

Spots - draw random dot spots

Tetris - game
	keyboard control: 'L' right, 'I' turn, 'J' left, 'K' drop, 'A' pause

Train - puzzle game with 50 levels and with their solutions
	keyboard control: 'L' right, 'I' up, 'J' left, 'K' down, 'H' help (solution), Enter OK, Esc escape, BS backspace

Twister - deformable block covered with 4 textures

Water surface - simulation of a rippling water surface
Comments
  • Hardware timer usage and Audio pin for other purpose

    Hardware timer usage and Audio pin for other purpose

    Hello Mr. Miroslav Nemecek, Thank you for this wonderful gift. I am making a GUI console for my hobby project with it. However, I have a few questions.

    1. Is it possible to use the hardware timer (for the tachometer function)?
    2. How to utilize the audio out pin for another purpose?
    3. Is it possible to use DrawTextBg and Text printing with PrintText can be used on the same canvas at the same time? which example to follow?
    4. How to use UART0 at GP12,13, I2C0 on GP20,21 (for DS3231 RTC) and SPI0 on GP16,17,18,19 (for microSD card)? Thanks & Regards, Sourav
    opened by souravg009 2
  • ScreenSegmAText crashes PicoVGA

    ScreenSegmAText crashes PicoVGA

    I've been trying to use ScreenSegmAText but it appears to crash PicoVGA.

    I've tried with a few simple programs without luck.

    As as test, I modified the matrix rain sample using ScreenSegmAText() and it also doesn't work:

    ScreenSegmAText(g, TextBuf, Font_Copy, FONTH, DefPal16, TEXTWB);
    

    Expected output would be the matrix rain but with random CGA colors instead I get no monitor sync at all.

    opened by codaris 2
  • Different pins?

    Different pins?

    Hi I am working on a pico motherboard. My question is that if it's possible to move the output to other pins, because I still want the uart pins for data transmission.

    opened by carlni2008 1
  • Work with this circuit?

    Work with this circuit?

    Hi I am trying to get a rca output to work with this circuit:

    image

    This circuit works by combining the five VGA signals (R, G, B, H and V) into a crude approximation of a monochrome [RS-170] signal. The resistors at the top do a rough weighting of the three color channels to approximate how the eye responds to intensity, and the two resistors at the bottom add a combined sync signal to the mix.

    I have tried this circuit diagram with the vga output of the pico, so I can have 2 video out ports on my pico. However only the vga port worked, and the rca didn't. I am not sure about the problem, but the possible problem might be:

    1. I used regular ground for BGND since the pico doesn't have a individual ground for each color.
    2. The pico have CSYNC instead of HSYNC and VSYNC In the documentation, it also states "The circuit needs VGA to TV drivers which output negative polarity HSYNC and VSYNC signals"

    Do you have any ideas how I can make this work?

    opened by carlni2008 15
  • SPI?

    SPI?

    opened by lynch-mob 3
  • How to include a third party library in the

    How to include a third party library in the "Hello world" project?

    opened by souravg009 0
  • Support to non consecutive VGA_GPIO_SYNC

    Support to non consecutive VGA_GPIO_SYNC

    I am using PicoVGA with a RP2014 Zero board that has a more limited option of pins than the Pi Pico. I want to use UART and SPI and for that I need to assign VGA_GPIO_SYNC to a GPIO that is not consecutive to the color pins. From a quick look at the code, it seems that this will only affect the pins initialization in vga.c, (VGA_GPIO_SYNC would need to be initialized separately):

    // connect PIO to the pad
    for (i = VGA_GPIO_FIRST; i <= VGA_GPIO_LAST; i++) pio_gpio_init(VGA_PIO, i);
    
    ...
    
    // set pin direction to output
    pio_sm_set_consecutive_pindirs(VGA_PIO, VGA_SM(layer), VGA_GPIO_FIRST, VGA_GPIO_NUM, true);
    
    

    Can you confirm this? Is this change worth a pull request?

    opened by dquadros 1
  • How to build on non Windows ?

    How to build on non Windows ?

    This looks great as a project.

    The build system seems very Windows specific, will this build with the Linux pico gcc tools ? I have a "VGA demo base" for the Pico, how does the pinout compare, how do I configure it ?

    Thanks.

    opened by jonshouse1 17
  • Trying to scale a simple image

    Trying to scale a simple image

    I apologise in advance, my c is very rusty and this seems like a fairly straight forward task but I've been at it for hours and somehow I'm getting nothing coming out of the vga port anymore (though I should make clear compiling and running the demos included all worked).

    I have an image that's 192x144 and I want to scale it to the VESA resolution, but I can't seem to get there. I've converted the source bmp using the tool you included and have:

    // format: 8-bit pixel graphics
    // image width: 192 pixels
    // image height: 144 lines
    // image pitch: 192 bytes
    const u8 myImage[27648] __attribute__ ((aligned(4))) = {
    // ...
    

    I call this method to prepare the transform:

    void SetMat()
    {
      // IMGW = 192, IMGH=144, WIDTH=1152, HEIGHT=864
      Mat.PrepDrawImg(IMGW, IMGH, 0, 0, WIDTH, HEIGHT, 0, 0, 0, 0, 0);
      Mat.ExportInt(MatInt);
    }
    

    Then my main is - the setup videomode bit being where I think it's going wrong but I copied from the other examples in the hope I could get it to work.

    int main()
    {
      imageCanvas.img = (u8 *)myImage;
      imageCanvas.w = IMGW;
      imageCanvas.h = IMGH;
      imageCanvas.wb = IMGW;
      imageCanvas.format = CANVAS_8;
    
      Canvas.w = WIDTH;
      Canvas.h = HEIGHT;
      Canvas.wb = WIDTH;
      Canvas.format = CANVAS_8;
    
      SetMat();
    
      // setup videomode
      VgaCfgDef(&Cfg);        // get default configuration
      Cfg.video = &VideoVESA; // video timings
      Cfg.width = WIDTH;      // screen width
      Cfg.height = HEIGHT;    // screen height
      Cfg.wfull = WIDTH;      // full width
      Cfg.dbly = False;       // double Y
      VgaCfg(&Cfg, &Vmode); // calculate videomode setup
    
      // // initialize base layer 0 to simple color (will be not visible)
      // ScreenClear(pScreen);
      // sStrip *t = ScreenAddStrip(pScreen, Vmode.height);
      // sSegm *g = ScreenAddSegm(t, Vmode.width);
      // ScreenSegmColor(g, 0xff00ff00, 0x00ff00ff);
      // initialize system clock
      if (clock_get_hz(clk_sys) != Vmode.freq * 1000)
      set_sys_clock_pll(Vmode.vco * 1000, Vmode.pd1, Vmode.pd2);
    
      // initialize videomode
      VgaInitReq(&Vmode);
    
      DrawImgMat(&Canvas, &imageCanvas, 0, 0, WIDTH, HEIGHT, &Mat, DRAWIMG_CLAMP, 0);
    
      while (true)
      {
        // maybe call again later
        // DrawImgMat(&Canvas, &imageCanvas, 0, 0, WIDTH, HEIGHT, &Mat, DRAWIMG_CLAMP, 0);
      }
    }
    

    This isn't putting anything out on the the video port once it's running on the pico, and I'm hoping that … someone(?) might be able to set me straight, again, on what I'd imagine is fairly straight forward.

    Thanks in advance.

    opened by remy 1
Owner
Miroslav Nemecek
Miroslav Nemecek
Breakout game for Raspberry Pi Pico with Pimoroni Pico Display pack

breakout_rpi_pico Breakout game for Raspberry Pi Pico with Pimoroni Pico Display pack Prebuilt binary (breakout.uf2) is here. To build your own binary

null 19 Oct 15, 2022
Digital rain animation gif with glow squeezed into a raspberry pi pico and pimoroni pico-display

pico-display-matrix Digital rain animation gif with glow squeezed into a raspberry pi pico and pimoroni pico-display or how to actually use all Flash

null 32 Sep 10, 2022
Prueba del Raspberry PI PICO con un display Raspberry PI TFT 3.5"

Raspberry-PI-PICO-display-RPI35 Prueba del Raspberry PI PICO con un display Raspberry PI TFT 3.5" Con ayuda de la libreria https://github.com/khoih-pr

null 1 Nov 10, 2021
Pi Pico VGA Terminal Emulator For RC2014

picoterm Pi Pico VGA Terminal Emulator For RC2014 PicoTerm is a terminal emulator written specifically for this module. Currently it runs 80 columns b

RC2014 27 Dec 30, 2022
PicoQVGA - Minimalistic QVGA Display on Raspberry Pico

Minimalistic QVGA Display on Raspberry Pico with resolution 320x240/8bit, suitable as tutorial to PIO and DMA.

Miroslav Nemecek 18 Dec 28, 2022
Tetris on a Raspberry Pi Pico mounted on a Pimoroni Pico Explorer

PicoTetris Classic Tetris game running on a Raspberry Pi Pico microcontroller. Pico C port by Richard Birkby Original JavaScript implementation - Jake

Richard Birkby 34 Dec 3, 2022
Pico-uart-bridge - Raspberry Pi Pico UART-USB bridge

Raspberry Pi Pico USB-UART Bridge This program bridges the Raspberry Pi Pico HW UARTs to two independent USB CDC serial devices in order to behave lik

Álvaro Fernández Rojas 156 Dec 23, 2022
Display array is a board that sets 6 ST7735 display with a resolution of 80x160px in a linear array sharing the clock, data, rs, backlight pins together

The display array is a board that sets 6 ST7735 display with a resolution of 80x160px in a linear array sharing the clock, data, rs, backlight pins together, and leaving individual access to the cs lines of each display, This board allows you to display images with a resolution of 480x160px.

Josue Alejandro Gutierrez 70 Dec 19, 2022
Raspberry Pi Pico (RP2040) and Micro-ROS (ROS 2) Integration

The Pico is an amazing microcontroller and I couldn't wait for ROS 2 support or Arduino Core, so here is my approach. Once the Arduino Core for RP2040 is out it will be easier to use micro_ros_arduino.

Darko Lukić 19 Jun 19, 2022
built-in CMSIS-DAP debugger tailored especially for the RP2040 “Raspberry Pi Pico”

RP2040 has two ARM Cortex-M0+ cores, and the second core normally remains dormant. pico-debug runs on one core in a RP2040 and provides a USB CMSIS-DAP interface to debug the other core. No hardware is added; it is as if there were a virtual debug pod built-in.

null 272 Dec 30, 2022
🦠 µnix is a UNIX-like operating system for the raspberry pi pico.

The µnix Operating System "µnix", "munix" or, "micro unix" aims to be a micro kernel based operating system targeting the Raspberry Pi Pico. "µnix" is

Sleepy Monax 57 Dec 11, 2022
Fractal rendering for Raspberry Pi Pico microcontroller

picofract Mandelbrot Set rendering demo for Raspberry Pi Pico microcontroller with Pico Display Pack. Building If you already have the Pimoroni SDK bu

null 22 Dec 7, 2022
Arduino API for the Raspberry Pico

Raspberry PI Pico - Arduino API On Friday I was receiving my Raspberry PI Pico and I had the opportunity to play around with it. Actually most of the

Phil Schatzmann 59 Jan 2, 2023
x86 emulator on Raspberry Pi Pico

picox86 x86 emulator on Raspberry Pi Pico https://user-images.githubusercontent.com/10139098/110543817-13299080-812b-11eb-9c88-674cdae919fc.mp4 PCB fr

null 39 Nov 9, 2022
A laser cut Dreamcast Pop'n Music controller and integrated memory card using the Raspberry Pi Pico's Programmable IO

Dreamcast Pop'n Music Controller Using Raspbery Pi Pico (RP2040) Intro This is a homebrew controller for playing the Pop'n Music games on the Sega Dre

null 42 Dec 29, 2022
Web Server based on the Raspberry Pico using an ESP8266 with AT firmware for WiFi

PicoWebServer This program runs on a Raspberry Pico RP2040 to provide a web server when connected to an Espressif ESP8266. This allows the Pico to be

null 52 Jan 7, 2023
Raspberry Pi Pico Arduino core, for all RP2040 boards

Arduino-Pico Raspberry Pi Pico Arduino core, for all RP2040 boards This is a port of the RP2040 (Raspberry Pi Pico processor) to the Arduino ecosystem

Earle F. Philhower, III 929 Jan 5, 2023
A programming environment for Lua for the Raspberry Pi Pico microcontroller

picolua A programming environment for Lua for the Raspberry Pi Pico microcontroller. Version 0.3, April 2021 What is this? picolua is a proof-of-conce

Kevin Boone 65 Jan 8, 2023
a little hobby raspberry pi pico emulator

PICO-EMU a little raspberry pi pico emulator note: we use the provided bootrom from raspberry pi at the repo: https://github.com/raspberrypi/pico-boot

supercyp 26 Nov 5, 2022