Skip to content

Example of Embedded Swift with SDL3 on ESP32-P4, ESP32-C3, ESP32-C6

Notifications You must be signed in to change notification settings

georgik/esp32-sdl3-swift-example

Repository files navigation

ESP32 Swift Example

Test Status

Example of graphical application for ESP32-C3, ESP32-P4.

Read more about Swift for ESP32 at Espressif Developer Portal.

On-line Demo Simulation

ESP32-P4 SDL3 Swift Simulation

Run the ESP32-P4 SDL3 Swift with Wokwi.com

Requirements

Build

Configure build environment

source esp-idf/export.sh
export TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-10-30-a.xctoolchain/Info.plist)

Build for ESP32-P4-Function-Ev-Board

idf.py @boards/esp32_p4_function_ev_board.cfg flash monitor

Build for ESP32-C3-LcdKit

ESP32-C3-LcdKit

idf.py @boards/esp32_c3_lcdkit.cfg flash monitor

Build for ESP32-C6-DevKit

ESP32-C6-DevKit

The 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=y

You can change the configuration by running:

idf.py @boards/esp32_c6_devkit.cfg menuconfig
idf.py @boards/esp32_c6_devkit.cfg flash monitor

Run simulation in VS Code

  • 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.

Credits