Skip to content

Getting Started

Run the example on your computer to see a progress bar updated by C code, or add ESP-GSP to an existing ESP-IDF project to display your own scene.

Use an ESP-IDF 6.0 or later shell with ESP32-C3 support, Python 3.10+, CMake 3.20+, and a native C11 compiler. Create the example from the Component Registry:

Terminal window
idf.py create-project-from-example "espressif/esp-gsp=1.12.0:usage/hello_world"
cd hello_world
python -m pip install -U esp-gsp-tools

From the example directory, select a supported target to install the project dependencies, then start the native simulator. No board connection is needed.

Terminal window
idf.py set-target esp32c3
python managed_components/espressif__esp-gsp/tools/sim_bridge/run.py --project pc

If you already have the unpacked component and the tool manager, run python tools/sim_bridge/run.py --project examples/usage/hello_world/pc from the component root. This native build uses CMake and a C compiler directly.

The browser shows the progress bar changing every 250 ms. The simulator runs the same C timer and generated setter as the firmware. For scene-only previews or headless captures, see the simulator reference.

To integrate ESP-GSP into an existing project, export ESP-IDF 6.0 or later (6.1 or later for ESP32-S31). Choose the scene size and pixel format for your display. The BSP supplies an esp_display_present_target_config_t and, for touch input, an esp_lcd_touch_handle_t in the same logical orientation.

From the ESP-IDF project root:

Terminal window
idf.py add-dependency "espressif/esp-gsp^1.12.0"

The equivalent entry in main/idf_component.yml is:

dependencies:
espressif/esp-gsp: "^1.12.0"

For a local checkout, use Component Manager override_path or EXTRA_COMPONENT_DIRS to select a single copy of ESP-GSP.

Terminal window
python -m pip install -U esp-gsp-tools

CMake uses this tool manager to download and cache the compiler named in the component’s .gspc_version. For an offline build or a project-specific pin, see compiler selection.

Create scenes/main.json in the project root. This scene has a progress bar and a toggle and needs no external assets.

{
"screen": "main",
"w": 320,
"h": 240,
"screen_bg": "#101820",
"objects": [
{
"type": "progress",
"parent": -1,
"name": "load",
"x": 40,
"y": 96,
"w": 240,
"h": 24,
"value": 30,
"fg_color": "#4CC9F0"
},
{
"type": "toggle",
"parent": -1,
"name": "power",
"x": 128,
"y": 164,
"w": 64,
"h": 32,
"fg_color": "#4361EE",
"callback": "power_changed"
}
]
}

name lets the application address a control. callback declares an event for application logic. When adding fonts or images, use paths relative to the scene file. See the widget library for complete examples.

In main/CMakeLists.txt:

idf_component_register(SRCS "app_main.c"
PRIV_REQUIRES esp-gsp)
gsp_add_bundle(${COMPONENT_LIB})

The default call compiles the sorted scenes/*.json files and their assets into an embedded RGB565 bundle. It also generates bundle_gsp.h and the scene headers. For a different pixel format, scene directory or bundle name, see build-time options.

Before first startup: stack and integrity checks

Section titled “Before first startup: stack and integrity checks”

The task that starts ESP-GSP also validates the bundle. The example sets CONFIG_ESP_MAIN_TASK_STACK_SIZE=20480. If another task starts the UI, give that task equivalent headroom, then measure uxTaskGetStackHighWaterMark() with your fonts, decoders and logging before reducing its stack.

Keep bundle CRC verification enabled. Set disable_bundle_crc only when another trusted mechanism has already verified the assets. If startup stalls, keep the task watchdog enabled while investigating the cause.

Supply your BSP’s display target and optional touch handle, then start the bundle and connect application state and events:

#include "esp_gsp_esp_lcd.h"
#include "bundle_gsp.h"
static void on_ui_event(esp_gsp_handle_t ui,
const esp_gsp_event_t *event,
void *user_ctx)
{
(void)ui;
(void)user_ctx;
if (gsp_main_event_is_power_changed(event)) {
/* Notify an application task; do not block this callback. */
}
}
void app_main(void)
{
esp_display_present_target_config_t display;
ESP_ERROR_CHECK(board_display_init(&display));
esp_lcd_touch_handle_t touch = NULL;
(void)board_touch_init(&touch); /* Optional. */
esp_gsp_config_t app = gsp_bundle_config();
esp_gsp_esp_lcd_config_t lcd = ESP_GSP_ESP_LCD_CONFIG_INIT();
lcd.display = display;
lcd.touch = touch;
esp_gsp_handle_t ui;
ESP_ERROR_CHECK(esp_gsp_esp_lcd_start(&app, &lcd, &ui));
ESP_ERROR_CHECK(esp_gsp_on_event(ui, on_ui_event, NULL));
ESP_ERROR_CHECK(gsp_main_load_set_value(ui, 60));
}

Replace board_display_init() and board_touch_init() with your BSP’s initialization functions. See the example hardware setup for panel configuration, framebuffers, rotation, byte order and touch mapping.

For an ESP32-P4 project:

Terminal window
idf.py set-target esp32p4
idf.py build

Select your board’s actual target. ESP32-H4 and ESP32-S31 use idf.py --preview set-target <target>. Check the panel pins and timing before running idf.py -p PORT flash monitor, replacing PORT with the board’s port.

After a build, open bundle_gsp.h for the setters and event predicates for your scene. In this example, gsp_main_load_set_value() updates the progress bar and gsp_main_event_is_power_changed() identifies the toggle event.

To pin the compiler for this project, create a project-root .gspc_version:

Terminal window
echo '0.13.0' > .gspc_version
idf.py build

The project marker overrides the component marker. An explicit GSPC_EXECUTABLE takes precedence over both. When upgrading the component, check that any project pin remains compatible. See compatibility.

If the compiler reports a capacity shortage, open idf.py menuconfig and select Component config -> ESP-GSP. See the Kconfig guide for capacity and memory settings, or the development workflow for connecting application state, events and resources.