# ESP32-S3-N16R8-LVGL **Repository Path**: zlm678/esp32-s3-n16-r8-lvgl ## Basic Information - **Project Name**: ESP32-S3-N16R8-LVGL - **Description**: 自制的ESP32S3LVGL开发板 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 2 - **Created**: 2024-06-01 - **Last Updated**: 2025-09-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 自制的ESP32S3-N16R8-LVGL开发板 ## 配置 - **ESP32S3** 16MB-FLASH 8MB-PSRAM - 2.4 TFT SPI 240x320 **ili9341** - lcd touch **XPT2046** ## 架构 使用VSCODE+ESP-IDF进行开发,使用IDF包管理器安装驱动。 ## 包列表 - eil/i2cdev: "^1.5.1" - atanisoft/esp_lcd_touch_xpt2046: "^1.0.4" - idf: ">=4.4" - lvgl/lvgl: "~8.3.0" - esp_lcd_ili9341: "^1.0" - esp_lcd_gc9a01: "^1.0" - esp_lcd_touch_stmpe610: "^1.0" # 开发板展示 ----

# 接线定义 --- ``` ESP Board ILI9341 屏幕 + 触摸 ┌──────────────────────┐ ┌────────────────────┐ │ GND ├─────────────►│ GND │ │ │ │ │ │ 3V3 ├─────────────►│ VCC │ │ │ │ │ │ 10 ├─────────────►│ SCLK │ │ │ │ │ │ 8 ├─────────────►│ MOSI │ │ │ │ │ │ 18 |◄─────────────┤ MISO │ │ │ │ │ │ 13 ├─────────────►│ RES │ │ │ │ │ │ 12 ├─────────────►│ DC │ │ │ │ │ │ 14 ├─────────────►│ LCD CS │ │ │ │ │ │ 9 ├─────────────►│ TOUCH CS │ │ │ │ │ │ 11 ├─────────────►│ BLK │ └──────────────────────┘ └────────────────────┘ ``` # 包介绍 [esp_lcd](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/lcd.html) 提供了几个开箱即用的面板驱动程序,例如 ST7789、SSD1306、NT35510。 `esp_lcd` 允许用户在项目范围内添加自己的面板驱动程序(即面板驱动程序可以位于 esp-idf 之外),这样上层代码,如 LVGL 移植代码,就可以在不需要任何修改的情况下重用,只要用户实现的面板驱动遵循 `esp_lcd` 组件定义的接口。 本项目使用了 `esp_timer` 来生成 `LVGL` 所需的时钟节拍,并使用一个专用的任务来运行 `lv_timer_handler()` 函数。由于 `LVGL` 的 API 并不是线程安全的,因此在调用 `lv_timer_handler()` 之前需要先调用一个互斥锁,并在调用之后释放它。在其他任务和线程中,每次调用与` LVGL (lv_...)` 相关的函数和代码时,都需要使用同一个互斥锁。有关更多移植指南,请参考 `LVGL` 移植文档。 这段话的意思是,示例代码中使用了 `ESP-IDF` 中的 `esp_timer` 功能来提供 `LVGL` 库所需的定时器节拍,这是图形界面定时刷新所必需的。为了确保在多任务环境中正确地同步对 LVGL 库的访问,示例中使用了互斥锁`mutex`来避免可能的竞态条件。互斥锁确保了在任何时刻只有一个任务可以执行` lv_timer_handler() `或其他`LVGL` 函数,从而保护了图形界面的状态不受干扰。开发者在移植或使用 `LVGL` 库时,需要遵循类似的同步机制,以保证线程安全。 ## XTP2046触摸校准方法 > 目前使用手动校准的方法,后续会更新自动校准程序。 ```C // 屏幕自定义校准 // 最小点 (20,15) (223,287) #define _x_min 20 #define _y_min 15 #define _x_max 223 #define _y_max 287 // k = 1.18 = scr_width/(x_max-x_min) // d = 23.6 = 20 * k #define PROCESS_X(x_temp) (_x_min < x_temp && x_temp < _x_max) ? (1.18f * x_temp - 23.6f) : 0 #define PROCESS_Y(y_temp) (_y_min < y_temp && y_temp < _y_max) ? (1.1f * y_temp - 17.6f) : 0 static void _my_process_coordinates(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num) { *x = PROCESS_X(*x); *y = PROCESS_Y(*y); // ESP_LOGI(TAG_TOUCH, "X:%hu,Y:%hu", *x, *y); } ``` # 如何构建 注意版本问题,建议使用一样的版本,特别是idf和lvgl这两个包 ```c [1/10] atanisoft/esp_lcd_touch_xpt2046 (1.0.4) [2/10] eil/esp_idf_lib_helpers (1.2.1) [3/10] eil/i2cdev (1.5.1) [4/10] espressif/cmake_utilities (0.5.3) [5/10] espressif/esp_lcd_gc9a01 (1.2.0) [6/10] espressif/esp_lcd_ili9341 (1.2.0) [7/10] espressif/esp_lcd_touch (1.1.1) [8/10] espressif/esp_lcd_touch_stmpe610 (1.0.6) [9/10] idf (5.2.1) [10/10] lvgl/lvgl (8.3.11) ``` # 计划例子 1. 触摸屏校准 2. WIFI连接菜单 3. NTP时间显示 4. AHT10温湿度显示