ESP32 VGA Controller and Graphics Library
FabGL Library

www.FabGL.com - 2019 by Fabrizio Di Vittorio (fdivi.nosp@m.tto2.nosp@m.013@g.nosp@m.mail.nosp@m..com)

This is a VGA Controller, PS/2 Keyboard and Mouse Controller, Graphics Library, Graphical User Interface (GUI), Game Engine and ANSI/VT Terminal for the ESP32.
This library works well with ESP32 revision 1 or upper.

VGA output requires a digital to analog converter (DAC): it can be done by three 270 Ohm resistors to have 8 colors, or by 6 resistors to have 64 colors.

Three fonts are embedded to best represents 80x25 or 132x25 text screen, at 640x350 resolution. However other fonts and resolutions can be used.

Sprites can have up to 64 colors (RGB, 2 bits per channel + transparency).
A sprite has associated one o more bitmaps, even of different size. Bitmaps (frames) can be selected in sequence to create animations.
Unlimited number of sprites are supported. However big sprites and a large amount of them reduces the frame rate and could generate flickering.

When there is enough memory (on low resolutions like 320x200), it is possible to allocate two screen buffers, so to implement double buffering.
In this case drawing primitives always draw on the back buffer.

Except for double buffering or when explicitly disabled, all drawings are performed on vertical retracing, so no flickering is visible.
If the queue of primitives to draw is not processed before the vertical retracing ends, then it is interrupted and continued at next retracing.

The main classes of FabGL library are:

  • fabgl::VGAControllerClass (instanced as VGAController), that controls the hardware. Use to setup GPIOs, screen resolution and adjust the screen position.
  • fabgl::CanvasClass (instanced as Canvas), that provides a set of drawing primitives (lines, rectangles, text...).
  • fabgl::TerminalClass, that emulates an ANSI/VT100/VT102 and up terminal (look at vttest score).
  • fabgl::KeyboardClass (instanced as Keyboard), that controls a PS2 keyboard and translates scancodes to virtual keys or ASCII/ANSI codes.
  • fabgl::MouseClass (instanced as Mouse), that controls a PS2 mouse.
  • fabgl::Scene abstract class that handles sprites, timings and collision detection.
  • fabgl::uiApp base class to build Graphical User Interface applications

See Configuring VGA outputs for VGA connection sample schema.

See Configuring PS/2 port for PS/2 connection sample schema.

Space Invaders Example

Graphical User Interface - GUI Example

Simple Terminal Out Example

Network Terminal Example

Modeline Studio Example

Loopback Terminal Example

Double Buffering Example

Collision Detection Example

Created by Fabrizio Di Vittorio (fdivi.nosp@m.tto2.nosp@m.013@g.nosp@m.mail.nosp@m..com) - http://www.fabgl.com
Copyright (c) 2019 Fabrizio Di Vittorio.
All rights reserved.

This file is part of FabGL Library.

FabGL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

FabGL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with FabGL. If not, see http://www.gnu.org/licenses/.