Skip to content

Commit bcc2043

Browse files
committed
Use esp-idf-scv v0.51, lv_binding_rust commit d83b374
1 parent 11191d6 commit bcc2043

File tree

6 files changed

+68
-60
lines changed

6 files changed

+68
-60
lines changed

.cargo/config.toml

+10-12
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,23 @@ target = "xtensa-esp32s3-espidf"
33

44
[target.xtensa-esp32s3-espidf]
55
linker = "ldproxy"
6-
# runner = "espflash --monitor" # Select this runner for espflash v1.x.x
7-
runner = "espflash flash --monitor" # Select this runner for espflash v2.x.x
8-
rustflags = [
9-
# Extending time_t for ESP IDF 5: https://github.com/esp-rs/rust/issues/110
10-
"--cfg",
11-
"espidf_time64",
12-
]
6+
runner = "espflash flash --monitor"
7+
rustflags = [ "--cfg", "espidf_time64",]
8+
139
[unstable]
1410
build-std = ["std", "panic_abort"]
1511

1612
[env]
1713
MCU="esp32s3"
14+
1815
# Note: this variable is not used by the pio builder (`cargo build --features pio`)
19-
ESP_IDF_VERSION = "v5.2.2"
16+
ESP_IDF_VERSION = "v5.2.3"
2017

2118
# The directory that has the lvgl config files - lv_conf.h, lv_drv_conf.h
2219
DEP_LV_CONFIG_PATH = { relative = true, value = "lvgl-configs" }
2320

24-
# Required to make lvgl build correctly otherwise get wrong file type
25-
CROSS_COMPILE = "xtensa-esp32-elf"
21+
# Required to make lvgl build correctly otherwise get wrong file type (ie compiled for a big endian system and target is little endian)
22+
CROSS_COMPILE = "xtensa-esp32s3-elf"
2623

2724
# Required for lvgl otherwise the build would fail with the error -> dangerous relocation: call8: call target out of range
2825
# for some lvgl functions
@@ -31,5 +28,6 @@ CFLAGS_xtensa_esp32s3_espidf="-mlongcalls"
3128
# Directory for custom fonts (written in C) that Lvgl can use
3229
LVGL_FONTS_DIR = {relative = true, value = "custom-fonts"}
3330

34-
# If you are getting string.h NOT FOUND try including this. Edit for your correct path and toolchain version
35-
C_INCLUDE_PATH = "/home/ed/.rustup/toolchains/esp/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/xtensa-esp-elf/include"
31+
# Required for lvgl to build otherwise you will get string.h not found.
32+
# Verfiy path and toolchain version being used on your PC (esp-14.2.0_20240906)
33+
TARGET_C_INCLUDE_PATH = "/home/ed/.rustup/toolchains/esp/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/xtensa-esp-elf/include"

.github/workflows/rust_ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1313

1414
# Required otherwise lgvl-sys would fail to build with string.h not found
15-
C_INCLUDE_PATH: "/home/runner/.rustup/toolchains/esp/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/xtensa-esp-elf/include"
15+
TARGET_C_INCLUDE_PATH: "/home/runner/.rustup/toolchains/esp/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/xtensa-esp-elf/include"
1616

1717
jobs:
1818
rust-checks:

Cargo.toml

+17-13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ edition = "2021"
66
resolver = "2"
77
rust-version = "1.77"
88

9+
[[bin]]
10+
name = "rust-esp32s3-lvgl-clickme"
11+
harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors
12+
913
[profile.release]
1014
opt-level = "s"
1115

@@ -14,43 +18,43 @@ debug = true # Symbols are nice and they don't increase the size on Flash
1418
opt-level = "z"
1519

1620
[features]
17-
default = ["std", "embassy", "esp-idf-svc/native"]
21+
default = []
1822

19-
pio = ["esp-idf-svc/pio"]
20-
std = ["alloc", "esp-idf-svc/binstart", "esp-idf-svc/std"]
21-
alloc = ["esp-idf-svc/alloc"]
22-
nightly = ["esp-idf-svc/nightly"]
2323
experimental = ["esp-idf-svc/experimental"]
24-
embassy = ["esp-idf-svc/embassy-sync", "esp-idf-svc/critical-section", "esp-idf-svc/embassy-time-driver"]
2524

2625
[dependencies]
26+
# Logging
2727
log = { version = "0.4", default-features = false }
28-
esp-idf-svc = { version = "0.49.1", default-features = false }
2928

30-
cstr_core = "0.2.1"
31-
embedded-graphics-core = "0.4.0"
29+
# ESP specifics
30+
esp-idf-svc = { version = "0.51", features = ["critical-section", "embassy-time-driver", "embassy-sync", "alloc"] }
3231

32+
# LVGL
3333
lvgl = { version = "0.6.2", default-features = false, features = [
3434
"embedded_graphics",
3535
"unsafe_no_autoinit",
3636
#"lvgl_alloc",
37+
#"alloc"
3738
] }
3839

3940
lvgl-sys = { version = "0.6.2" }
4041

42+
# Hardware IO Abstraction Layer
4143
embedded-hal = {version = "1.0.0"}
44+
embedded-graphics-core = "0.4.0"
4245

46+
# Error
4347
anyhow = "1.0"
4448

49+
# C String
50+
cstr_core = "0.2.1"
51+
4552

4653
[build-dependencies]
47-
embuild = "0.32.0"
54+
embuild = "0.33"
4855

4956

5057
[patch.crates-io]
5158
lvgl = { git = "https://github.com/enelson1001/lv_binding_rust"}
5259
lvgl-sys = { git = "https://github.com/enelson1001/lv_binding_rust"}
5360

54-
[[bin]]
55-
name = "rust-esp32s3-lvgl-clickme"
56-
harness = false

README.md

+31-22
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,40 @@ CONFIG_SPIRAM_RODATA=y
4141
```
4242

4343
## Cargo.toml project file
44-
I added the following to the "dependencies" section.
44+
I have the following to the "dependencies" section.
4545
```
46-
esp-idf-hal = { version = "0.42.5" }
47-
esp-idf-sys = { version = "0.33.7"}
46+
[dependencies]
47+
# Logging
48+
log = { version = "0.4", default-features = false }
4849
49-
cstr_core = "0.2.1"
50-
embedded-graphics-core = "0.4.0"
50+
# ESP specifics
51+
esp-idf-svc = { version = "0.51", features = ["critical-section", "embassy-time-driver", "embassy-sync", "alloc"] }
5152
53+
# LVGL
5254
lvgl = { version = "0.6.2", default-features = false, features = [
5355
"embedded_graphics",
5456
"unsafe_no_autoinit",
57+
#"lvgl_alloc",
58+
#"alloc"
5559
] }
5660
5761
lvgl-sys = { version = "0.6.2" }
5862
59-
embedded-hal = {version = "1.0.0-rc.1"}
63+
# Hardware IO Abstraction Layer
64+
embedded-hal = {version = "1.0.0"}
65+
embedded-graphics-core = "0.4.0"
6066
67+
# Error
6168
anyhow = "1.0"
6269
70+
# C String
71+
cstr_core = "0.2.1"
72+
6373
```
6474

6575
I also included patch.crates-io section to patch esp-idf-sys, lvgl and lvgl-sys
6676
```
6777
[patch.crates-io]
68-
esp-idf-sys = { git = "https://github.com/esp-rs/esp-idf-sys"}
6978
lvgl = { git = "https://github.com/enelson1001/lv_binding_rust"}
7079
lvgl-sys = { git = "https://github.com/enelson1001/lv_binding_rust"}
7180
@@ -79,26 +88,23 @@ target = "xtensa-esp32s3-espidf"
7988
8089
[target.xtensa-esp32s3-espidf]
8190
linker = "ldproxy"
82-
# runner = "espflash --monitor" # Select this runner for espflash v1.x.x
83-
runner = "espflash flash --monitor" # Select this runner for espflash v2.x.x
84-
rustflags = [
85-
# Extending time_t for ESP IDF 5: https://github.com/esp-rs/rust/issues/110
86-
"--cfg",
87-
"espidf_time64",
88-
]
91+
runner = "espflash flash --monitor"
92+
rustflags = [ "--cfg", "espidf_time64",]
93+
8994
[unstable]
9095
build-std = ["std", "panic_abort"]
9196
9297
[env]
9398
MCU="esp32s3"
99+
94100
# Note: this variable is not used by the pio builder (`cargo build --features pio`)
95-
ESP_IDF_VERSION = "v5.2.2"
101+
ESP_IDF_VERSION = "v5.2.3"
96102
97103
# The directory that has the lvgl config files - lv_conf.h, lv_drv_conf.h
98104
DEP_LV_CONFIG_PATH = { relative = true, value = "lvgl-configs" }
99105
100-
# Required to make lvgl build correctly otherwise get wrong file type
101-
CROSS_COMPILE = "xtensa-esp32-elf"
106+
# Required to make lvgl build correctly otherwise get wrong file type (ie compiled for a big endian system and target is little endian)
107+
CROSS_COMPILE = "xtensa-esp32s3-elf"
102108
103109
# Required for lvgl otherwise the build would fail with the error -> dangerous relocation: call8: call target out of range
104110
# for some lvgl functions
@@ -107,14 +113,14 @@ CFLAGS_xtensa_esp32s3_espidf="-mlongcalls"
107113
# Directory for custom fonts (written in C) that Lvgl can use
108114
LVGL_FONTS_DIR = {relative = true, value = "custom-fonts"}
109115
110-
# If you are getting string.h NOT FOUND try including this. Edit for your correct path.
111-
#C_INCLUDE_PATH = "/home/runner/.rustup/toolchains/esp/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/xtensa-esp-elf/include"
116+
# Required for lvgl to build otherwise you will get string.h not found.
117+
# Verfiy path and toolchain version being used on your PC (esp-14.2.0_20240906)
118+
TARGET_C_INCLUDE_PATH = "/home/ed/.rustup/toolchains/esp/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/xtensa-esp-elf/include"
112119
```
113-
## string.h Not Found
114-
If you are getting string.h not found try uncommenting the last entry in config.toml.
120+
115121

116122
## lv-binding-rust fork
117-
I updated my fork of lv-binding-rust to include PR153 ie the changes recommended by madwizard-thomas.
123+
I updated my fork of lv-binding-rust to include PR153 ie the changes recommended by madwizard-thomas and merged with Master commit d83b374
118124

119125
## Flashing the ESP32S3 device
120126
I used the following command to flash the ESP32S3 device.
@@ -135,3 +141,6 @@ The clicked
135141
# Versions
136142
### v1.0 :
137143
- initial release
144+
145+
## Change History
146+
Feb 04, 2025 - Use latest lv_binding_rust commit d83b374, use esp-idf-svc v0.51

src/gt911.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ pub struct TouchPoint {
4949
/// - The I2C Slave address of the GT911
5050
/// - The I2C Bus used to communicate with the GT911
5151
/// - The screen/panel orientation
52-
/// - The scree/panel dimesions
53-
52+
/// - The screen/panel dimensions
5453
pub struct GT911<I2C>
5554
where
5655
I2C: I2c<SevenBitAddress>,

src/main.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ fn main() -> anyhow::Result<()> {
4343

4444
info!("=================== Starting APP! =========================");
4545

46-
const HOR_RES: u32 = 800;
47-
const VER_RES: u32 = 480;
48-
const LINES: u32 = 4; // The number of lines (rows) that will be refreshed was 12
49-
5046
let peripherals = Peripherals::take()?;
5147

5248
#[allow(unused)]
@@ -76,7 +72,8 @@ fn main() -> anyhow::Result<()> {
7672
.unwrap(),
7773
pins.gpio2,
7874
)?;
79-
channel.set_duty(channel.get_max_duty() / 2)?;
75+
//channel.set_duty(channel.get_max_duty() / 2)?;
76+
channel.set_duty(channel.get_max_duty())?;
8077
info!("Backlight turned on");
8178

8279
//============================================================================================================
@@ -99,6 +96,9 @@ fn main() -> anyhow::Result<()> {
9996
.unwrap();
10097

10198
info!("============= Registering Display ====================");
99+
const HOR_RES: u32 = 800;
100+
const VER_RES: u32 = 480;
101+
const LINES: u32 = 4; // The number of lines (rows) that will be refreshed was 12
102102
let draw_buffer = DrawBuffer::<{ (HOR_RES * LINES) as usize }>::default();
103103
let display = Display::register(draw_buffer, HOR_RES, VER_RES, |refresh| {
104104
lcd_panel
@@ -181,9 +181,7 @@ fn main() -> anyhow::Result<()> {
181181
// Create button label, align in center of button
182182
let mut btn_lbl = Label::create(&mut button).unwrap();
183183
btn_lbl.set_align(Align::Center, 0, 0);
184-
btn_lbl
185-
.set_text(CString::new("Click me!").unwrap().as_c_str())
186-
.unwrap();
184+
btn_lbl.set_text(CString::new("Click me!").unwrap().as_c_str());
187185

188186
let mut btn_state = false;
189187
button
@@ -192,10 +190,10 @@ fn main() -> anyhow::Result<()> {
192190
println!("Clicked Event");
193191
if btn_state {
194192
let nt = CString::new("Click me!").unwrap();
195-
btn_lbl.set_text(nt.as_c_str()).unwrap();
193+
btn_lbl.set_text(nt.as_c_str());
196194
} else {
197195
let nt = CString::new("Clicked!").unwrap();
198-
btn_lbl.set_text(nt.as_c_str()).unwrap();
196+
btn_lbl.set_text(nt.as_c_str());
199197
}
200198
btn_state = !btn_state;
201199
}

0 commit comments

Comments
 (0)