ESP32: VGA terminal (FabGL)
FabGL draws a 640×400 terminal on a VGA monitor.
How it works
An ESP32-DevKitC generates VGA with FabGL: I2S1 sends the picture by DMA in LCD mode, eight bits in parallel, at 25.175 MHz. Two GPIOs per colour go through the resistor DAC (270 Ω for the high bit, 470 Ω for the low one) to the DE-15 socket, HSYNC and VSYNC directly; the monitor on its cable recognises 640×400 at 70 Hz and shows the terminal in the display panel. The sketch prints a line every 500 ms; change it in the code editor (FabGL 1.0.9, GPL-3.0, with our patch for Arduino-ESP32 3.x). The scope on the VGA lines sees the colours and HSYNC sampled at the simulation step (every 50 µs) and VSYNC at 70 Hz with exact edges.
Wiring
Each line is one connection (net) and the pins it joins.
| Net | Pins |
|---|---|
| GND | A1 GNDJ1 GND |
| VSYNC | A1 GPIO15J1 VSYNC |
| B0 | A1 GPIO4R6 1 |
| B1 | A1 GPIO5R5 1 |
| BLUE | J1 BLUER5 2R6 2 |
| G0 | A1 GPIO18R4 1 |
| G1 | A1 GPIO19R3 1 |
| GREEN | J1 GREENR3 2R4 2 |
| HSYNC | A1 GPIO23J1 HSYNC |
| R0 | A1 GPIO21R2 1 |
| R1 | A1 GPIO22R1 1 |
| RED | J1 REDR1 2R2 2 |
Parts
Firmware
sketch.ino · 26 lines
// ESP32 VGA terminal with FabGL: 640x400 at 70 Hz, 16 colours (640x480 needs more memory than an
// ESP32 without PSRAM has free: FabGL then shortens the screen). The picture comes out of I2S1 by
// DMA on the pins of the usual FabGL board: red GPIO22/21, green GPIO19/18, blue GPIO5/4 (high bit
// first, each through the resistor DAC), HSYNC GPIO23, VSYNC GPIO15.
#include "fabgl.h"
fabgl::VGA16Controller DisplayController;
fabgl::Terminal Terminal;
void setup() {
Serial.begin(115200);
DisplayController.begin();
DisplayController.setResolution(VGA_640x400_70Hz);
Terminal.begin(&DisplayController);
Terminal.enableCursor(true);
Terminal.write("\e[44;97m\e[2J\e[H"); // white on blue, clear the screen
Terminal.write("\e[1mESP32 VGA terminal\e[0m\e[44;97m (FabGL, 640x400, 16 colours)\r\n\n");
Serial.printf("VGA started: %d x %d\n", DisplayController.getViewPortWidth(), DisplayController.getViewPortHeight());
}
void loop() {
static int n = 0;
Terminal.printf("\e[93mline %d\e[97m uptime %lu ms\r\n", n++, millis());
Serial.printf("line %d\n", n);
delay(500);
}Open in the simulator