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
- uiApp, uiFrame, modal windows (showModalWindow()), messageBox(), timers (setTimer() / onTimer)
- Controls: uiLabel, uiStaticLabel, uiTextEdit, uiButton, uiSplitButton, uiListBox, uiComboBox, uiCheckBox (check box and radio button), uiSlider, uiPanel, uiPaintBox
- Anchors (controls that follow the window size), event handlers as lambdas
- uiApp::runAsync() to run the application in its own task
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
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include "esp_random.h"
29
30
31
32static inline int randomInt(int max) { return max > 0 ? (int) (esp_random() % (uint32_t) max) : 0; }
33
34static inline int randomInt(int min, int max) { return max > min ? min + (int) (esp_random() % (uint32_t) (max - min)) : min; }
35
37
38#include "App.h"
39
40
41
44
45
46
47void setup()
48{
49 PS2Controller.
begin(PS2Preset::KeyboardPort0_MousePort1, KbdMode::GenerateVirtualKeys);
50
51 DisplayController.
begin();
53}
54
55
56void loop()
57{
58 MyApp().runAsync(&DisplayController, 3500).joinAsyncRun();
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.
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.
This file contains all classes related to FabGL Graphical User Interface.