Skip to content

Commit e741fb8

Browse files
authored
Feature add ESP32-C3-LcdKit (#3)
* add ESP32-C3 DevKit
1 parent 078855e commit e741fb8

File tree

11 files changed

+98
-7
lines changed

11 files changed

+98
-7
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
runs-on: ubuntu-latest
2828
strategy:
2929
matrix:
30-
board: [esp32_p4_function_ev_board]
30+
board: [esp32_p4_function_ev_board, esp32_c3_lcdkit]
3131
fail-fast: false
3232

3333
steps:
@@ -41,6 +41,7 @@ jobs:
4141
esp-box) echo 'esp32s3';;
4242
m5stack_core_s3) echo 'esp32s3';;
4343
esp32_p4_function_ev_board) echo 'esp32p4';;
44+
esp32_c3_lcdkit) echo 'esp32c3';;
4445
*) echo 'Unknown target'; exit 1;;
4546
esac)" >> $GITHUB_ENV
4647

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ on:
66
release_name:
77
description: 'Name of the GitHub Release'
88
required: true
9-
default: 'v1.0.0'
9+
default: 'v1.1.0'
1010
release_tag:
1111
description: 'Tag for the GitHub Release'
1212
required: true
13-
default: 'v1.0.0'
13+
default: 'v1.1.0'
1414
prefix:
1515
description: 'Prefix for binary name'
1616
required: true

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
board: [esp32_p4_function_ev_board]
16+
board: [esp32_p4_function_ev_board, esp32_c3_lcdkit]
1717
fail-fast: false
1818

1919
steps:

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
Example of graphical application for ESP32-P4.
5+
Example of graphical application for ESP32-C3, ESP32-P4.
66

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

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

1515
## Build
1616

17+
ESP32-P4-Function-Ev-Board:
18+
1719
```shell
1820
idf.py @boards/esp32_p4_function_ev_board.cfg flash monitor
1921
```
2022

23+
ESP32-C3-LcdKit:
24+
25+
![ESP32-C3-LcdKit](docs/img/esp32-c3-lcdkit.webp)
26+
27+
```shell
28+
idf.py @boards/e@boards/esp32_c3_lcdkit.cfg flash monitor
29+
```
30+
2131
## Credits
2232

2333
- Graphical assets: https://opengameart.org/content/platformer-tiles

boards/esp32_c3_lcdkit.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults.esp32_c3_lcdkit;sdkconfig.defaults" -DBUILD_BOARD="esp32_c3_lcdkit" -DIDF_TARGET=esp32c3 -B build.esp32_c3_lcdkit

boards/esp32_c3_lcdkit/diagram.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"version": 1,
3+
"author": "Juraj Michálek",
4+
"editor": "wokwi",
5+
"parts": [
6+
{
7+
"type": "board-esp32-c3-devkitm-1",
8+
"id": "esp",
9+
"top": -494.32,
10+
"left": -455.03,
11+
"attrs": { "builder": "rust-std-esp32" }
12+
},
13+
{ "type": "wokwi-ili9341", "id": "lcd1", "top": -546.22, "left": -134.92, "attrs": {} },
14+
{ "type": "wokwi-ky-040", "id": "encoder1", "top": -417.5, "left": -703.6, "attrs": {} }
15+
],
16+
"connections": [
17+
[ "esp:TX", "$serialMonitor:RX", "", [] ],
18+
[ "esp:RX", "$serialMonitor:TX", "", [] ],
19+
[ "esp:3V3", "lcd1:VCC", "green", [] ],
20+
[ "esp:GND.1", "lcd1:GND", "black", [ "v215.62", "h374.23" ] ],
21+
[ "esp:1", "lcd1:SCK", "blue", [ "v215.62", "h422.24" ] ],
22+
[ "esp:7", "lcd1:CS", "red", [ "v186.82", "h295.01" ] ],
23+
[ "esp:2", "lcd1:D/C", "magenta", [ "v215.62", "h403.03" ] ],
24+
[ "esp:0", "lcd1:MOSI", "orange", [ "v215.62", "h412.64" ] ],
25+
[ "esp:3", "lcd1:LED", "white", [ "v234.82", "h431.84" ] ],
26+
[ "lcd1:LED", "esp:3V3", "white", [] ],
27+
[ "esp:10", "encoder1:DT", "green", [] ],
28+
[ "esp:9", "encoder1:CLK", "blue", [] ],
29+
[ "esp:3V3", "encoder1:VCC", "red", [] ],
30+
[ "esp:GND.1", "encoder1:GND", "black", [] ],
31+
[ "esp:8", "encoder1:SW", "yellow", [] ]
32+
],
33+
"serialMonitor": { "display": "terminal", "newline": "lf", "convertEol": true },
34+
"dependencies": {}
35+
}

boards/esp32_c3_lcdkit/wokwi.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Wokwi Configuration File
2+
# Reference: https://docs.wokwi.com/vscode/project-config
3+
[wokwi]
4+
version = 1
5+
firmware = 'build.esp32_c3_lcdkit/flasher_args.json'
6+
elf = 'build.esp32_c3_lcdkit/esp32-sdl3-swift-example.elf'
7+
gdbServerPort=3333

docs/img/esp32-c3-lcdkit.webp

18.6 KB
Binary file not shown.

main/Main.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func app_main() {
2424
var attr = pthread_attr_t()
2525

2626
pthread_attr_init(&attr)
27-
pthread_attr_setstacksize(&attr, 65536) // Set the stack size for the thread
27+
pthread_attr_setstacksize(&attr, 32000) // Set the stack size for the thread
2828

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

79+
var width: Int32 = 0
80+
var height: Int32 = 0
81+
82+
// Get window size
83+
SDL_GetWindowSize(window, &width, &height)
84+
85+
// Print the resolution
86+
print("Display resolution: \(width)x\(height)")
87+
7988
// Create SDL renderer
8089
guard let renderer = SDL_CreateRenderer(window, nil) else {
8190
print("Failed to create renderer")

main/idf_component.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## IDF Component Manager Manifest File
22
dependencies:
33
joltwallet/littlefs: "==1.14.8"
4-
georgik/sdl: "^3.1.2~8"
4+
georgik/sdl: "^3.1.2~9"
55
georgik/sdl_ttf: "^3.0.0~3"
66
idf:
77
version: ">=5.1.0"
@@ -10,3 +10,8 @@ dependencies:
1010
version: "3.0.1"
1111
rules:
1212
- if: "${BUILD_BOARD} == esp32_p4_function_ev_board_noglib"
13+
14+
espressif/esp32_c3_lcdkit:
15+
version: "^1.1.0~1"
16+
rules:
17+
- if: "${BUILD_BOARD} == esp32_c3_lcdkit"

sdkconfig.defaults.esp32_c3_lcdkit

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This file was generated using idf.py save-defconfig. It can be edited manually.
2+
# Espressif IoT Development Framework (ESP-IDF) 5.4.0 Project Minimal Configuration
3+
#
4+
CONFIG_IDF_TARGET="esp32c3"
5+
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
6+
CONFIG_PARTITION_TABLE_CUSTOM=y
7+
8+
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
9+
CONFIG_COMPILER_OPTIMIZATION_PERF=y
10+
CONFIG_SPIRAM=y
11+
CONFIG_SPIRAM_MODE_OCT=y
12+
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
13+
CONFIG_SPIRAM_RODATA=y
14+
CONFIG_SPIRAM_SPEED_80M=y
15+
CONFIG_FREERTOS_HZ=1000
16+
CONFIG_BSP_LCD_RGB_BUFFER_NUMS=2
17+
CONFIG_BSP_LCD_RGB_BOUNCE_BUFFER_MODE=y
18+
CONFIG_SPIRAM_MODE_HEX=y
19+
CONFIG_SPIRAM_SPEED_200M=y
20+
CONFIG_IDF_EXPERIMENTAL_FEATURES=y
21+
22+
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8912
23+

0 commit comments

Comments
 (0)