Skip to content

Commit

Permalink
use esp-idf-sys master, misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
enelson1001 committed Dec 5, 2023
1 parent 380c1ce commit f9f1903
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Enable caching
uses: Swatinem/rust-cache@v2
- name: Install gcc-multilib
run: sudo apt-get install g++-multilib
run: sudo apt-get install gcc-multilib
- name: Setup Rust
uses: esp-rs/[email protected]
with:
Expand Down
15 changes: 9 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,24 @@ embassy = ["esp-idf-svc/embassy-sync", "esp-idf-svc/critical-section", "esp-idf-
log = { version = "0.4", default-features = false }
esp-idf-svc = { version = "0.47.3", default-features = false }

esp-idf-hal = { version = "0.42.1" }
esp-idf-sys = { version = "0.33.3" }
esp-idf-hal = { version = "0.42.5" }
esp-idf-sys = { version = "0.33.7"}

cstr_core = "0.2.1"
embedded-graphics-core = "0.4.0"

lvgl = { git = "https://github.com/enelson1001/lv_binding_rust", version = "0.6.2", default-features = false, features = [
lvgl = { version = "0.6.2", default-features = false, features = [
"embedded_graphics",
"unsafe_no_autoinit",
] }

lvgl-sys = { git = "https://github.com/enelson1001/lv_binding_rust", version = "0.6.2" }
lvgl-sys = { version = "0.6.2" }

[build-dependencies]
embuild = "0.31.3"

[package.metadata.esp-idf-sys]
extra_components = [{ bindings_header = "bindings.h" }]

[patch.crates-io]
esp-idf-sys = { git = "https://github.com/esp-rs/esp-idf-sys"}
lvgl = { git = "https://github.com/enelson1001/lv_binding_rust"}
lvgl-sys = { git = "https://github.com/enelson1001/lv_binding_rust"}
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ Aliexpress ESP32-8048S070 - 7 inch 800x400 TN RGB with ESP32S3, 8M PSRAM, 16M Fl
This application shows how to use lv-binding-rust crate on a ESP32S3 device. The program will display a clock time on a blue backgound screen.
The clock time is a simulated time of 21:00 to 21::59 where the seconds are incremented each second and repeats the 00-59 seconds forever.

## Comments
I use linux-mint as my development PC and I had to install gcc-multilib or else I got an error 'bits/libc-header-start.h' file not found.

```
$ sudo apt update
$ sudo apt upgrade
$ sudo apt-get install gcc-multilib
```

## partition-table folder
The partition-table folder contains a file called partitons.csv. This file increases the default factory/app partiton from the default of 1M to 3M.
This allows us more space for our program and since the flash size is 16M this should not be a problem. This file will be called when we flash the device.
The partition-table folder contains a file called partitons.csv. This file increases the default factory/app partiton from the default of 1M to 3M. This allows us more space for our program and since the flash size is 16M this should not be a problem. This file will be called when we flash the device.

## custom-fonts folder
The custom-fonts folder contains our custom fonts. The customs fonts are converted from TTF fonts using lvgl online font converter at https://lvgl.io/tools/fontconverter. I used https://ttfonts.net to find a font I liked and then downloaded the font. In the lvgl-online-font-converter I used the font name plus the font size for the name of the font. I chose Bpp of 2 bit-per-pixel and set the range of 0x30-0x3A since I only need numbers and the ":" character. After clicking on "Convert" the file will be downloaded. I placed this downloaded file (*.c) into the custom-fonts folder. Then I created a header file which has an extern to my *.c file, along with changing the ifndef and define names.
Expand All @@ -39,31 +46,30 @@ CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
CONFIG_SPIRAM_RODATA=y
```

## bindings.h file in project root directory
This file contains additional bindings required for using esp_lcd_panel esp-idf component that is available on the ESP32S3 device.

## Cargo.toml project file
I added the following to the "dependencies" section.
```
esp-idf-hal = { version = "0.42.1" }
esp-idf-sys = { version = "0.33.3" }
esp-idf-hal = { version = "0.42.5" }
esp-idf-sys = { version = "0.33.7"}
cstr_core = "0.2.1"
embedded-graphics-core = "0.4.0"
lvgl = { git = "https://github.com/enelson1001/lv_binding_rust", version = "0.6.2", default-features = false, features = [
lvgl = { version = "0.6.2", default-features = false, features = [
"embedded_graphics",
"unsafe_no_autoinit",
] }
lvgl-sys = { git = "https://github.com/enelson1001/lv_binding_rust", version = "0.6.2" }
lvgl-sys = { version = "0.6.2" }
```

You need to a 'package.metadata.esp-idf-sys' section so the bindings.h file will be include.
Also included patch.crates-io section to patch esp-idf-sys, lvgl and lvgl-sys
```
[package.metadata.esp-idf-sys]
extra_components = [{ bindings_header = "bindings.h" }]
[patch.crates-io]
esp-idf-sys = { git = "https://github.com/esp-rs/esp-idf-sys"}
lvgl = { git = "https://github.com/enelson1001/lv_binding_rust"}
lvgl-sys = { git = "https://github.com/enelson1001/lv_binding_rust"}
```

Expand Down Expand Up @@ -108,11 +114,6 @@ LVGL_FONTS_DIR = {relative = true, value = "custom-fonts"}
## lv-binding-rust fork
I updated my fork of lv-binding-rust to include PR153 ie the changes recommended by madwizard-thomas.


## Building the project
The changes to config.toml, Cargo.toml and to build.rs allowed me to build lv-binding-rust without any errors. I do get 2 warnings about va_list not being FFI-safe.


## Flashing the ESP32S3 device
I used the following command to flash the ESP32S3 device.
```
Expand Down
2 changes: 1 addition & 1 deletion src/lcd_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::ptr::null_mut;
use core::cell::UnsafeCell;

use esp_idf_sys::{
esp,
esp_lcd_new_rgb_panel,
esp_lcd_panel_del,
esp_lcd_panel_draw_bitmap,
Expand All @@ -19,7 +20,6 @@ use esp_idf_sys::{
esp_lcd_rgb_timing_t__bindgen_ty_1,
soc_periph_lcd_clk_src_t,
soc_periph_lcd_clk_src_t_LCD_CLK_SRC_PLL160M,
esp,
EspError,
};

Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn main() {
refresh.area.y1.into(),
(refresh.area.x2 + 1i16).into(),
(refresh.area.y2 + 1i16).into(),
refresh.colors.into_iter(),
refresh.colors,
)
.unwrap();
})
Expand Down Expand Up @@ -117,7 +117,7 @@ fn main() {

let val = CString::new(format!("21:{:02}", i)).unwrap();
time.set_text(&val).unwrap();
i = 1 + i;
i += 1;

lvgl::task_handler();

Expand Down

0 comments on commit f9f1903

Please sign in to comment.