FabGL
ESP32 VGA Controller and Graphics Library
VGA outputs

VGA output can be configured such as 8 colors or 64 colors are displayed. Eight colors require 5 outputs (R, G, B, H and V), while sixty-four colors require 8 outputs (R0, R1, G0, G1, B0, B1, H and V).

Following an example of outputs configuration and a simple digital to analog converter circuit:

  === 8 colors, 1 bit per channel, 3 bit per pixel ===

  Sample connection scheme:
                       -----------
   GPIO22 (red0) ------|R 270 Ohm|---- VGA_R
                       -----------

                       -----------
   GPIO21 (green0) ----|R 270 Ohm|---- VGA_G
                       -----------

                       -----------
   GPIO19 (blue0) -----|R 270 Ohm|---- VGA_B
                       -----------

   GPIO18 ---------------------------- VGA_HSYNC

   GPIO5  ---------------------------- VGA_VSYNC

  Using above GPIOs the VGA Controller may be initialized in this way:
    VGAController.begin(GPIO_NUM_22, GPIO_NUM_21, GPIO_NUM_19, GPIO_NUM_18, GPIO_NUM_5);

  === 64 colors, 2 bit per channel, 6 bit per pixel ===

       One resistor for each R0, R1, G0, G1, B0 and B1. Low bit (LSB) should have
       twice resistance value than high bit (MSB), for example 800Ohm (LSB) and 400Ohm (MSB).

                       ------------
   GPIO22 (red1) ------|R 400 Ohm |------*---- VGA_R
                       ------------      |
                       ------------      |
   GPIO21 (red0) ------|R 800 Ohm |------*
                       ------------

                       ------------
   GPIO19 (green1) ----|R 400 Ohm |------*---- VGA_G
                       ------------      |
                       ------------      |
   GPIO18 (green0) ----|R 800 Ohm |------*
                       ------------

                       ------------
   GPIO5 (blue1) ------|R 400 Ohm |------*---- VGA_B
                       ------------      |
                       ------------      |
   GPIO4 (blue0) ------|R 800 Ohm |------*
                       ------------

   GPIO23 ------------------------------------ VGA_HSYNC

   GPIO15 ------------------------------------ VGA_VSYNC

  Using above GPIOs the VGA Controller may be initialized in this way:
    VGAController.begin(GPIO_NUM_22, GPIO_NUM_21, GPIO_NUM_19, GPIO_NUM_18, GPIO_NUM_5, GPIO_NUM_4, GPIO_NUM_23, GPIO_NUM_15);

Note: Do not connect GPIO_NUM_2 (led) to the VGA signals.

PS2 Keyboard connection uses two GPIOs (data and clock) and requires one 120 Ohm series resistor and one 2K Ohm pullup resistor for each signal:

                                        +5V
                                         |
                                         |
                                         *-----+
                                         |     |
                                        ---   ---
                                        | |   | |
                                        |R|   |R|
                                        |2|   |2|
                                        |K|   |K|
                                        | |   | |
                                        ---   ---
                       ------------      |     |
   GPIO33 (CLK)    ----|R 120 Ohm |------*--------- PS/2 KEYBOARD CLK
                       ------------            |
                       ------------            |
   GPIO32 (DAT)    ----|R 120 Ohm |------------*--- PS/2 KEYBOARD DAT
                       ------------

  Using above GPIOs the PS2 Keyboard Controller may be initialized in this way:
    Keyboard.begin(GPIO_NUM_33, GPIO_NUM_32);  // clk, dat
Author
Fabrizio Di Vittorio (fdivi.nosp@m.tto2.nosp@m.013@g.nosp@m.mail.nosp@m..com)