# ESP-GSP
English | [简体中文](README_zh.md) | [Online documentation](https://docs.espressif.com/projects/esp-gsp/master/index.html)
ESP-GSP (Espressif Graphics Scene Processor) is an ahead-of-time compiled UI
framework for ESP-IDF. It turns JSON scenes and assets into a Bundle
and C headers. The application uses the headers to update controls. The
runtime draws the Bundle through the ESP-LCD target provided by the application.
```text
JSON + assets -> GSPC ─┬─ Bundle (.gspb) -> runtime -> display
└─ C headers -> application
```
Embed the Bundle in firmware or load a compatible deployable `.gspb` at
runtime. The [USB live reload example](examples/usage/device_live_reload/README.md)
moves a button while keeping its existing C callback. It includes ESP32-P4, ESP32-S3 and ESP32-S31 display profiles.
## Highlights
| Capability | What it provides |
|---|---|
| Build-time UI | Schema validation, asset compilation and deterministic Bundles |
| Generated API | Typed access to named controls and event helpers for declared callbacks |
| Embedded runtime | Configurable memory use, RGB565 and RGB888 rendering |
| UI features | Controls, layouts, lists, grids, templates, navigation, media and Canvas |
| Input | Tap, drag, scroll, flick and optional application-owned two-contact pinch |
| Display paths | RGB, MIPI-DSI, SPI and QSPI with safe software fallbacks |
| Visual editor | ESP-GSP Studio provides canvas editing, live WASM preview, structured scene editing and agent collaboration |
## Requirements
- ESP-IDF 6.0 or later; use 6.1 or later for ESP32-S31.
- Python 3.10 or later for the `esp-gsp-tools` toolchain manager.
- An application or BSP that initializes an `esp_lcd` display target.
## Try the maintained example
If you have this checkout, open the included [Hello World example](examples/usage/hello_world/README.md)
for PC preview and board instructions. To try a published release, create the example
from the ESP Component Registry:
<!-- gsp-version:registry-example -->
```sh
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
```
<!-- /gsp-version:registry-example -->
The component targets ESP32, ESP32-C2/C3/C5/C6/H4, ESP32-S3, ESP32-P4 and
ESP32-S31. H4 and S31 use ESP-IDF's `--preview` target flag.
The example includes checked profiles for ESP32-C3, ESP32-S3, ESP32-P4 and
ESP32-S31. Select the profile that matches the real board and verify its panel
pins and timings before flashing.
Compiler setup uses the active ESP-IDF Python environment. A matching `gspc`
already on PATH can be used offline; otherwise CMake uses the tool manager.
See [compiler selection](docs/en/guide/workflow.md#compiler-selection)
for source builds, Windows executables, version pins and offline use.
## Add ESP-GSP to an existing project
From the ESP-IDF project root:
<!-- gsp-version:dependency-command -->
```sh
idf.py add-dependency "espressif/esp-gsp^1.12.0"
python -m pip install -U esp-gsp-tools
```
<!-- /gsp-version:dependency-command -->
Create scene JSON files under the project-level `scenes/` directory. Give an
element a stable `name` when the application must update it, and add a
`callback` when an action must enter application logic:
```json
{
"screen": "main", "w": 320, "h": 240,
"objects": [
{"type": "progress", "parent": -1, "name": "load",
"x": 24, "y": 80, "w": 272, "h": 18, "value": 0},
{"type": "toggle", "parent": -1, "name": "power",
"callback": "power_changed", "x": 128, "y": 140, "w": 64, "h": 32}
]
}
```
Register the Bundle after the application component:
```cmake
idf_component_register(SRCS "app_main.c" PRIV_REQUIRES esp-gsp)
gsp_add_bundle(${COMPONENT_LIB})
```
The next build validates every scene, compiles its assets, embeds one Bundle
and generates `bundle_gsp.h`. Start from `gsp_bundle_config()` and
`ESP_GSP_ESP_LCD_CONFIG_INIT()`, then use the generated
`gsp_<scene>_<name>_*()` helpers. The
[Getting Started guide](docs/en/getting-started.md) provides the complete
integration and display startup code.
## Important runtime contracts
- Keep layout and declarative behavior in JSON; keep product state and blocking
work in application tasks.
- Generated setters are asynchronous on ESP-IDF. Use `esp_gsp_flush()` only at
explicit synchronization boundaries.
- Stop external producers first, then call `esp_gsp_stop()` from an application
task. Do not block framework callbacks.
- A Bundle has one logical scene resolution and one RGB565 or RGB888 output
format. The BSP owns panel timing, rotation, byte order and touch mapping.
## Documentation
| Task | Start here |
|---|---|
| Install and run the first scene | [Getting Started](docs/en/getting-started.md) |
| View FPS, CPU and resource data | [Performance statistics](docs/en/guide/performance.md) |
| View benchmarks by chip, interface and resolution | [Hardware performance statistics](docs/en/guide/hardware-benchmark.md) |
| Understand the recommended workflow | [Development workflow](docs/en/guide/workflow.md) |
| Build and verify UI with a coding agent | [Agent-assisted UI development](docs/en/guide/agent-assisted-ui.md) |
| Author JSON and choose fields | [Scene guide](docs/en/guide/scenes.md) and [field reference](docs/en/reference/authoring.md) |
| Learn a control | [Widget library](docs/en/components/index.md) |
| Connect application state | [Runtime and generated API](docs/en/guide/runtime-api.md) |
| Configure memory and features | [Configuration](docs/en/configuration/index.md) and [Kconfig](docs/en/reference/kconfig.md) |
| Integrate a display | [Display presentation](docs/en/guide/display.md) |
| Design and preview scenes visually | [ESP-GSP Studio](docs/en/editor/index.md) |
| Preview without hardware | [Simulator preview](docs/en/configuration/simulator-preview.md) |
| Diagnose a problem | [Troubleshooting](docs/en/configuration/troubleshooting.md) |
| Look up exact C declarations | [Function reference](docs/en/reference/api-functions.md) |
The [documentation index](docs/README.md) links the complete English and
Simplified Chinese documentation sets. The repository also contains the
[product scenarios](examples/scenarios/README.md) and the
[`benchmark`](examples/performance/benchmark/README.md) hardware workload.
## Choose the integration path
- Build the scene structure with GSPC. Use properties and templates for dynamic
UI, collections for application datasets, runtime media for encoded images,
and Canvas for continuous pixel producers.
- Implement pinch scaling in application logic using the reported two-contact
gesture, then update the target control or Canvas.
- Use [right-to-left text](docs/en/guide/scenes.md#right-to-left-text)
in static labels or enable BiDi for text updated at runtime.
## License
Espressif Modified MIT License. See [LICENSE](LICENSE).
bb50510ef768d87ba4e13f80c61023aab9981452
idf.py add-dependency "espressif/esp-gsp^1.12.0"