Example of graphical application for ESP32-C3, ESP32-C6, ESP32-P4 using Swift programming language with SDL3 graphics library.
Read more about Swift for ESP32 at Espressif Developer Portal.
Run the ESP32-P4 SDL3 Swift with Wokwi.com
- Swift 6.1 - https://www.swift.org/install
- ESP-IDF 5.4 - https://github.com/espressif/esp-idf
source esp-idf/export.shIf you want to use specific Swift toolchain, you can set the environment variable TOOLCHAINS.
The step is not required for Swift 6.1 and newer.
export TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-10-30-a.xctoolchain/Info.plist)This project supports multiple ESP32 development boards with different display configurations:
| Board | MCU | Display | Resolution | Interface | Status |
|---|---|---|---|---|---|
| ESP32-P4 Function Evaluation Board | ESP32-P4 | RGB LCD | 480x480 | RGB | ✅ Working |
| M5Stack Tab5 | ESP32-P4 | MIPI-DSI LCD | 720x1280 | MIPI-DSI | ✅ Working |
| ESP32-C3 LCD Kit | ESP32-C3 | SPI LCD | 240x240 | SPI | ✅ Working |
| ESP32-C6 DevKit | ESP32-C6 | SPI LCD | 320x240 | SPI | ✅ Working |
| Waveshare ESP32-C6-LCD-1.47 | ESP32-C6 | SPI LCD | 172x320 | SPI | ✅ Working |
idf.py @boards/esp32_p4_function_ev_board.cfg flash monitorThe M5Stack Tab5 is a premium ESP32-P4 tablet with a high-resolution 5-inch MIPI-DSI display (720x1280) and GT911 capacitive touch controller.
- Board: M5Stack Tab5
- MCU: ESP32-P4 RISC-V dual-core
- Display: 5-inch IPS LCD, 720x1280 resolution
- Touch: GT911 capacitive touch controller
- Interface: MIPI-DSI for display
idf.py @boards/m5stack_tab5.cfg flash monitoridf.py @boards/esp32_c3_lcdkit.cfg flash monitorThe configuration of this board is based on ESP-BSP Generic which allows configuration using menuconfig.
SPI Display configuration:
CONFIG_BSP_DISPLAY_ENABLED=y
CONFIG_BSP_DISPLAY_SCLK_GPIO=6
CONFIG_BSP_DISPLAY_MOSI_GPIO=7
CONFIG_BSP_DISPLAY_MISO_GPIO=-1
CONFIG_BSP_DISPLAY_CS_GPIO=20
CONFIG_BSP_DISPLAY_DC_GPIO=21
CONFIG_BSP_DISPLAY_RST_GPIO=3
CONFIG_BSP_DISPLAY_DRIVER_ILI9341=yYou can change the configuration by running:
idf.py @boards/esp32_c6_devkit.cfg menuconfigidf.py @boards/esp32_c6_devkit.cfg flash monitor- board: ESP32-C6-LCD-1.47
- display: 172x320
idf.py @boards/waveshare-esp32-c6-lcd-1.47.cfg flash monitor- Build the project, to get binaries for simulation.
- Install Wokwi for VS Code.
- Open file
boards/esp32_.../diagram.json. - Click Play button to start simulation.
- Click Pause button to freeze simulation and display states of GPIOs.
- Graphical assets: https://opengameart.org/content/platformer-tiles
- Font FreeSans.ttf: https://github.com/opensourcedesign/fonts/blob/master/gnu-freefont_freesans/FreeSans.ttf




