Skip to content

Feature add ESP32-C3-LcdKit #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
board: [esp32_p4_function_ev_board]
board: [esp32_p4_function_ev_board, esp32_c3_lcdkit]
fail-fast: false

steps:
Expand All @@ -41,6 +41,7 @@ jobs:
esp-box) echo 'esp32s3';;
m5stack_core_s3) echo 'esp32s3';;
esp32_p4_function_ev_board) echo 'esp32p4';;
esp32_c3_lcdkit) echo 'esp32c3';;
*) echo 'Unknown target'; exit 1;;
esac)" >> $GITHUB_ENV

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:
release_name:
description: 'Name of the GitHub Release'
required: true
default: 'v1.0.0'
default: 'v1.1.0'
release_tag:
description: 'Tag for the GitHub Release'
required: true
default: 'v1.0.0'
default: 'v1.1.0'
prefix:
description: 'Prefix for binary name'
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
board: [esp32_p4_function_ev_board]
board: [esp32_p4_function_ev_board, esp32_c3_lcdkit]
fail-fast: false

steps:
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Test Status](https://github.com/georgik/esp32-sdl3-swift-example/actions/workflows/test.yml/badge.svg)

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

Read more about Swift for ESP32 at [Espressif Developer Portal](https://developer.espressif.com/tags/swift/).

Expand All @@ -14,10 +14,20 @@ Read more about Swift for ESP32 at [Espressif Developer Portal](https://develope

## Build

ESP32-P4-Function-Ev-Board:

```shell
idf.py @boards/esp32_p4_function_ev_board.cfg flash monitor
```

ESP32-C3-LcdKit:

![ESP32-C3-LcdKit](docs/img/esp32-c3-lcdkit.webp)

```shell
idf.py @boards/e@boards/esp32_c3_lcdkit.cfg flash monitor
```

## Credits

- Graphical assets: https://opengameart.org/content/platformer-tiles
Expand Down
1 change: 1 addition & 0 deletions boards/esp32_c3_lcdkit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults.esp32_c3_lcdkit;sdkconfig.defaults" -DBUILD_BOARD="esp32_c3_lcdkit" -DIDF_TARGET=esp32c3 -B build.esp32_c3_lcdkit
35 changes: 35 additions & 0 deletions boards/esp32_c3_lcdkit/diagram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"version": 1,
"author": "Juraj Michálek",
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-c3-devkitm-1",
"id": "esp",
"top": -494.32,
"left": -455.03,
"attrs": { "builder": "rust-std-esp32" }
},
{ "type": "wokwi-ili9341", "id": "lcd1", "top": -546.22, "left": -134.92, "attrs": {} },
{ "type": "wokwi-ky-040", "id": "encoder1", "top": -417.5, "left": -703.6, "attrs": {} }
],
"connections": [
[ "esp:TX", "$serialMonitor:RX", "", [] ],
[ "esp:RX", "$serialMonitor:TX", "", [] ],
[ "esp:3V3", "lcd1:VCC", "green", [] ],
[ "esp:GND.1", "lcd1:GND", "black", [ "v215.62", "h374.23" ] ],
[ "esp:1", "lcd1:SCK", "blue", [ "v215.62", "h422.24" ] ],
[ "esp:7", "lcd1:CS", "red", [ "v186.82", "h295.01" ] ],
[ "esp:2", "lcd1:D/C", "magenta", [ "v215.62", "h403.03" ] ],
[ "esp:0", "lcd1:MOSI", "orange", [ "v215.62", "h412.64" ] ],
[ "esp:3", "lcd1:LED", "white", [ "v234.82", "h431.84" ] ],
[ "lcd1:LED", "esp:3V3", "white", [] ],
[ "esp:10", "encoder1:DT", "green", [] ],
[ "esp:9", "encoder1:CLK", "blue", [] ],
[ "esp:3V3", "encoder1:VCC", "red", [] ],
[ "esp:GND.1", "encoder1:GND", "black", [] ],
[ "esp:8", "encoder1:SW", "yellow", [] ]
],
"serialMonitor": { "display": "terminal", "newline": "lf", "convertEol": true },
"dependencies": {}
}
7 changes: 7 additions & 0 deletions boards/esp32_c3_lcdkit/wokwi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Wokwi Configuration File
# Reference: https://docs.wokwi.com/vscode/project-config
[wokwi]
version = 1
firmware = 'build.esp32_c3_lcdkit/flasher_args.json'
elf = 'build.esp32_c3_lcdkit/esp32-sdl3-swift-example.elf'
gdbServerPort=3333
Binary file added docs/img/esp32-c3-lcdkit.webp
Binary file not shown.
11 changes: 10 additions & 1 deletion main/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func app_main() {
var attr = pthread_attr_t()

pthread_attr_init(&attr)
pthread_attr_setstacksize(&attr, 65536) // Set the stack size for the thread
pthread_attr_setstacksize(&attr, 32000) // Set the stack size for the thread

// Create the SDL thread
let ret = pthread_create(&sdl_pthread, &attr, sdl_thread_entry_point, nil)
Expand Down Expand Up @@ -76,6 +76,15 @@ func sdl_thread_entry_point(arg: UnsafeMutableRawPointer?) -> UnsafeMutableRawPo
return nil
}

var width: Int32 = 0
var height: Int32 = 0

// Get window size
SDL_GetWindowSize(window, &width, &height)

// Print the resolution
print("Display resolution: \(width)x\(height)")

// Create SDL renderer
guard let renderer = SDL_CreateRenderer(window, nil) else {
print("Failed to create renderer")
Expand Down
7 changes: 6 additions & 1 deletion main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## IDF Component Manager Manifest File
dependencies:
joltwallet/littlefs: "==1.14.8"
georgik/sdl: "^3.1.2~8"
georgik/sdl: "^3.1.2~9"
georgik/sdl_ttf: "^3.0.0~3"
idf:
version: ">=5.1.0"
Expand All @@ -10,3 +10,8 @@ dependencies:
version: "3.0.1"
rules:
- if: "${BUILD_BOARD} == esp32_p4_function_ev_board_noglib"

espressif/esp32_c3_lcdkit:
version: "^1.1.0~1"
rules:
- if: "${BUILD_BOARD} == esp32_c3_lcdkit"
23 changes: 23 additions & 0 deletions sdkconfig.defaults.esp32_c3_lcdkit
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) 5.4.0 Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32c3"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y

CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
CONFIG_SPIRAM_RODATA=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_FREERTOS_HZ=1000
CONFIG_BSP_LCD_RGB_BUFFER_NUMS=2
CONFIG_BSP_LCD_RGB_BOUNCE_BUFFER_MODE=y
CONFIG_SPIRAM_MODE_HEX=y
CONFIG_SPIRAM_SPEED_200M=y
CONFIG_IDF_EXPERIMENTAL_FEATURES=y

CONFIG_ESP_MAIN_TASK_STACK_SIZE=8912