FabGL2 2.0.0
ESP32 Display Controller and Graphics Library for ESP-IDF
Loading...
Searching...
No Matches
GraphicalUserInterface

Tour of the FabGL GUI (fabui.h): overlapping windows, mouse and keyboard input, and all the standard controls, at 640x480 with 16 colors.

The tests panel on the left contains one button per test, plus the free memory:

Button What it shows
Test Controls A window with all the controls: label, text edit, normal / switch / split buttons, list box, normal and editable combo boxes, check box, radio buttons, horizontal and vertical sliders
Create Frame Creates a new window with a random color and position (move, resize, minimize, maximize and close it)
Destroy Frame Destroys the last created window
Test Modal Dialog A modal window with a form (text edits in a panel): the rest of the UI is blocked until Close is pressed
Test MessageBox A sequence of message boxes with 1-3 buttons and the different icons (info, question, error, warning, none)
Test PaintBox A custom-painted chart with a horizontal scroll bar (uiPaintBox)
Test Timer An analog clock window updated by a timer
Test InputBox The InputBox dialogs (message, progress bar, menus) opened from inside a GUI application

Controls

  • Mouse: click, drag window title bars to move them, drag window borders to resize, use the buttons in the title bar to minimize, maximize and close
  • Keyboard: Tab / Shift+Tab move the focus, Space / Enter press the focused button, the arrow keys move in lists, combo boxes and sliders

What it demonstrates

Hardware

  • VGA output (default pins)
  • PS/2 keyboard on port 0 and PS/2 mouse on port 1

Build

See Building the examples.

Source code

Main file of the example, main/GraphicalUserInterface.cpp. The complete project is in the examples/VGA/GraphicalUserInterface folder.

1/*
2 Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - <http://www.fabgl.com>
3 Copyright (c) 2019-2026 Fabrizio Di Vittorio.
4 All rights reserved.
5
6
7* Please contact fdivitto2013@gmail.com if you need a commercial license.
8
9
10* This library and related software is available under GPL v3.
11
12 FabGL is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation, either version 3 of the License, or
15 (at your option) any later version.
16
17 FabGL is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with FabGL. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26
27#include "esp_random.h"
28#include "fabgl.h"
29
30
31// random integer in the range [0, max)
32static inline int randomInt(int max) { return max > 0 ? (int) (esp_random() % (uint32_t) max) : 0; }
33// random integer in the range [min, max)
34static inline int randomInt(int min, int max) { return max > min ? min + (int) (esp_random() % (uint32_t) (max - min)) : min; }
35
36#include "fabui.h"
37
38#include "App.h"
39
40
41
42fabgl::VGA16Controller DisplayController;
43fabgl::PS2Controller PS2Controller;
44
45
46
47void setup()
48{
49 PS2Controller.begin(PS2Preset::KeyboardPort0_MousePort1, KbdMode::GenerateVirtualKeys);
50
51 DisplayController.begin();
52 DisplayController.setResolution(VGA_640x480_60Hz);
53}
54
55
56void loop()
57{
58 MyApp().runAsync(&DisplayController, 3500).joinAsyncRun(); // why this? Just to use a larger stack!
59}
60
61
62extern "C" void app_main()
63{
64 setup();
65 while (true)
66 loop();
67}
static void begin(gpio_num_t port0_clkGPIO, gpio_num_t port0_datGPIO, gpio_num_t port1_clkGPIO=GPIO_UNUSED, gpio_num_t port1_datGPIO=GPIO_UNUSED)
Initializes the PS/2 device controller.
PS/2 device controller.
VGA bitmapped display controller with 16 colors.
void begin(gpio_num_t redGPIO, gpio_num_t greenGPIO, gpio_num_t blueGPIO, gpio_num_t HSyncGPIO, gpio_num_t VSyncGPIO)
Initializer for 8 colors (5 GPIOs).
Single include file of the FabGL library.
#define VGA_640x480_60Hz
Definition fabglconf.h:246
This file contains all classes related to FabGL Graphical User Interface.