diff --git a/.github/workflows/check_lib_versions.yml b/.github/workflows/check_lib_versions.yml index 48a48994..ebf83aad 100644 --- a/.github/workflows/check_lib_versions.yml +++ b/.github/workflows/check_lib_versions.yml @@ -26,4 +26,4 @@ jobs: echo "prerelease: ${{ steps.last_release.outputs.prerelease }}" echo "url: ${{ steps.last_release.outputs.url }}" - name: Check & Compare versions - run: bash ./.github/scripts/check_lib_versions.sh --latest_version=${{ steps.last_release.outputs.tag_name }} + run: bash ./tools/check_lib_versions.sh --latest_version=${{ steps.last_release.outputs.tag_name }} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 7111ea9c..cc477dbf 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -11,4 +11,4 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - - uses: pre-commit/action@v2.0.3 + - uses: pre-commit/action@v3.0.1 diff --git a/.gitlab/tools/executable-list.txt b/.gitlab/tools/executable-list.txt deleted file mode 100644 index 22439eee..00000000 --- a/.gitlab/tools/executable-list.txt +++ /dev/null @@ -1,4 +0,0 @@ -.github/scripts/check_lib_versions.sh -.gitlab/tools/check_executables.py -.gitlab/tools/check_readme_links.py -.gitlab/tools/push_to_github.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 21178af8..fa34ef28 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -77,33 +77,33 @@ repos: hooks: - id: check-executables name: Check File Permissions - entry: .gitlab/tools/check_executables.py --action executables + entry: ./tools/check_executables.py --action executables language: python types: [executable] exclude: '\.pre-commit/.+' - id: check-executable-list name: Validate executable-list.txt - entry: .gitlab/tools/check_executables.py --action list + entry: ./tools/check_executables.py --action list language: python pass_filenames: false always_run: true - id: sync-conf-files name: Update when configuration files change - entry: python3 tools/sync_conf_files.py ./ ./ + entry: python3 ./tools/sync_conf_files.py ./ ./ language: system files: '.*esp_panel_(board_custom|board_supported|drivers)_conf\.h' - id: sync-template-files name: Update when template files change - entry: python3 tools/sync_conf_files.py ./template_files ./ + entry: python3 ./tools/sync_conf_files.py ./template_files ./ language: system files: '(.*esp_utils_conf\.h|.*lv_conf\.h|.*lvgl_v8_port\.cpp|.*lvgl_v8_port\.h)' - id: check-file-versions name: Update when versions change - entry: python3 tools/check_file_version.py ./ + entry: python3 ./tools/check_file_version.py ./ language: system files: '(.*esp_panel_(board_custom|board_supported|drivers)_conf\.h|library.properties|.*esp_panel_versions.h)' - id: check-library-versions name: Check library versions - entry: ./.github/scripts/check_lib_versions.sh + entry: ./tools/check_lib_versions.sh language: system files: '(idf_component.yml|library.properties)' diff --git a/CHANGELOG.md b/CHANGELOG.md index 490d02c2..14c7f5a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # ChangeLog +## v1.0.3 - 2025-04-27 + +### Enhancements: + +* feat(docs): provides an example of how to integrate this library into micropython by @tsteinruecken (#190) + +## v1.0.2 - 2025-04-23 + +### Enhancements: + +* feat(backlight): add PWM parameters configuration (#188) + +### Bugfixes: + +* fix(io_expander): remove incompatible header (#175) +* fix(pre-commit): update the pre-commit script +* fix(docs): update README +* fix(conf): update comments of custom config file +* fix(examples): enable CPU 240M and task WDT default in esp_idf/lvgl_v8_port +* fix(lcd): fix ST7701 mirror issue + ## v1.0.1 - 2025-03-13 ### Enhancements: diff --git a/README.md b/README.md index 5c6e8ada..1e6defd2 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ The functional block diagram is shown below: * [ESP-IDF](./docs/envs/use_with_idf.md) * [Arduino IDE](./docs/envs/use_with_arduino.md) * [PlatformIO](./examples/platformio/lvgl_v8_port/README.md) +* [Micropython](./docs/envs/use_with_micropython.md) ## Supported Boards @@ -115,9 +116,10 @@ The functional block diagram is shown below: * [How to select and configure supported boards in Arduino IDE?](./docs/envs/use_with_arduino.md#how-to-select-and-configure-supported-boards-in-arduino-ide) * [How to use SquareLine exported UI source files in Arduino IDE?](./docs/envs/use_with_arduino.md#how-to-use-squareline-exported-ui-source-files-in-arduino-ide) * [How to debug when the screen doesn't light up using the library in Arduino IDE?](./docs/envs/use_with_arduino.md#how-to-debug-when-the-screen-doesnt-light-up-using-the-library-in-arduino-ide) - * [How to reduce Flash usage and speed up compilation when using ESP32_Display_Panel in Arduino IDE?](./docs/envs/use_with_arduino.md#how-to-reduce-flash-usage-and-speed-up-compilation-when-using-esp32_display_panel-in-arduino-ide) - * [Can't see log messages or messages are incomplete in Arduino IDE's Serial Monitor, how to fix?](./docs/envs/use_with_arduino.md#can-t-see-log-messages-or-messages-are-incomplete-in-arduino-ides-serial-monitor-how-to-fix) + * [How to fix the issue that log messages are missing or incomplete in Arduino IDE's Serial Monitor?](./docs/envs/use_with_arduino.md#how-to-fix-the-issue-that-log-messages-are-missing-or-incomplete-in-arduino-ides-serial-monitor) * [Solution for screen drift issue when using ESP32-S3 to drive RGB LCD in Arduino IDE](./docs/envs/use_with_arduino.md#solution-for-screen-drift-issue-when-using-esp32-s3-to-drive-rgb-lcd-in-arduino-ide) + * [How to reduce Flash usage and speed up compilation when using ESP32_Display_Panel in Arduino IDE?](./docs/envs/use_with_arduino.md#how-to-reduce-flash-usage-and-speed-up-compilation-when-using-esp32_display_panel-in-arduino-ide) + * [How to avoid I2C re-initialization when using ESP32_Display_Panel in Arduino IDE (e.g., when using Wire library)?](./docs/envs/use_with_arduino.md#how-to-avoid-i2c-re-initialization-when-using-esp32_display_panel-in-arduino-ide-eg-when-using-wire-library) * [ESP-IDF](./docs/envs/use_with_idf.md#faq) diff --git a/README_CN.md b/README_CN.md index ae80d0e0..08364cf8 100644 --- a/README_CN.md +++ b/README_CN.md @@ -45,6 +45,7 @@ ESP32_Display_Panel 的主要特性如下: * [ESP-IDF](./docs/envs/use_with_idf_cn.md) * [Arduino IDE](./docs/envs/use_with_arduino_cn.md) * [PlatformIO](./examples/platformio/lvgl_v8_port/README.md) +* [Micropython](./docs/envs/use_with_micropython_cn.md) ## 支持的开发板 @@ -118,6 +119,7 @@ ESP32_Display_Panel 的主要特性如下: * [在 Arduino IDE 中打开串口调试器看不到日志信息或日志信息显示不全,如何解决?](./docs/envs/use_with_arduino_cn.md#在-arduino-ide-中打开串口调试器看不到日志信息或日志信息显示不全如何解决) * [在 Arduino IDE 中使用 ESP32-S3 驱动 RGB LCD 时出现画面漂移问题的解决方案](./docs/envs/use_with_arduino_cn.md#在-arduino-ide-中使用-esp32-s3-驱动-rgb-lcd-时出现画面漂移问题的解决方案) * [在 Arduino IDE 中使用 ESP32_Display_Panel 时,如何降低其 Flash 占用及加快编译速度?](./docs/envs/use_with_arduino_cn.md#在-arduino-ide-中使用-esp32_display_panel-时如何降低其-flash-占用及加快编译速度) + * [在 Arduino IDE 中使用 ESP32_Display_Panel 时,如何避免 I2C 重复初始化(如使用 Wire 库)?](./docs/envs/use_with_arduino_cn.md#在-arduino-ide-中使用-esp32_display_panel-时如何避免-i2c-重复初始化如使用-wire-库) * [ESP-IDF](./docs/envs/use_with_idf_cn.md#常见问题及解答) diff --git a/docs/envs/use_with_arduino.md b/docs/envs/use_with_arduino.md index 5f5a0a0a..c127a60e 100644 --- a/docs/envs/use_with_arduino.md +++ b/docs/envs/use_with_arduino.md @@ -31,8 +31,8 @@ - [How to install ESP32\_Display\_Panel in Arduino IDE?](#how-to-install-esp32_display_panel-in-arduino-ide) - [How to select and configure supported boards in Arduino IDE?](#how-to-select-and-configure-supported-boards-in-arduino-ide) - [How to use SquareLine exported UI source files in Arduino IDE?](#how-to-use-squareline-exported-ui-source-files-in-arduino-ide) - - [Screen not working in Arduino IDE, how to debug?](#screen-not-working-in-arduino-ide-how-to-debug) - - [Can't see log messages or messages are incomplete in Arduino IDE's Serial Monitor, how to fix?](#cant-see-log-messages-or-messages-are-incomplete-in-arduino-ides-serial-monitor-how-to-fix) + - [How to debug when the screen doesn't light up using the library in Arduino IDE?](#how-to-debug-when-the-screen-doesnt-light-up-using-the-library-in-arduino-ide) + - [How to fix the issue that log messages are missing or incomplete in Arduino IDE's Serial Monitor?](#how-to-fix-the-issue-that-log-messages-are-missing-or-incomplete-in-arduino-ides-serial-monitor) - [Solution for screen drift issue when using ESP32-S3 to drive RGB LCD in Arduino IDE](#solution-for-screen-drift-issue-when-using-esp32-s3-to-drive-rgb-lcd-in-arduino-ide) - [How to reduce Flash usage and speed up compilation when using ESP32\_Display\_Panel in Arduino IDE?](#how-to-reduce-flash-usage-and-speed-up-compilation-when-using-esp32_display_panel-in-arduino-ide) - [How to avoid I2C re-initialization when using ESP32\_Display\_Panel in Arduino IDE (e.g., when using Wire library)?](#how-to-avoid-i2c-re-initialization-when-using-esp32_display_panel-in-arduino-ide-eg-when-using-wire-library) @@ -506,7 +506,7 @@ Please refer to [Configuring Arduino IDE](#configuring-arduino-ide). Please refer to [Porting SquareLine Projects](#porting-squareline-projects). -### Screen not working in Arduino IDE, how to debug? +### How to debug when the screen doesn't light up using the library in Arduino IDE? Please follow these steps to troubleshoot: @@ -515,7 +515,7 @@ Please follow these steps to troubleshoot: 3. Check detailed log information through the serial monitor to analyze the problem. 4. If the problem still cannot be solved through the above steps, please submit an issue report on [GitHub Issues](https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues) with complete log information. -### Can't see log messages or messages are incomplete in Arduino IDE's Serial Monitor, how to fix? +### How to fix the issue that log messages are missing or incomplete in Arduino IDE's Serial Monitor? Please follow these steps to resolve: @@ -553,7 +553,7 @@ Please follow these steps to resolve: c. **Configure LVGL Task** - - If using LVGL, setting the task that executes `lv_timer_handler()` to run on the same core as the RGB LCD initialization task can help mitigate the screen drift issue + - If using LVGL, setting the task that executes `lv_timer_handler()` to run on the same core as the task that executes `board->begin()` can help mitigate the screen drift issue 3. **Example Code** diff --git a/docs/envs/use_with_arduino_cn.md b/docs/envs/use_with_arduino_cn.md index 3b905d4d..87f9bea0 100644 --- a/docs/envs/use_with_arduino_cn.md +++ b/docs/envs/use_with_arduino_cn.md @@ -553,7 +553,7 @@ arduino-esp32 v3.x 版本的 SDK 位于默认安装路径下的 `tools > esp32-a c. **配置 LVGL 任务** - - 如果使用 LVGL,设置执行 `lv_timer_handler()` 任务与执行 RGB LCD 初始化任务在同一个核心上运行可以缓解画面漂移问题 + - 如果使用 LVGL,设置执行 `lv_timer_handler()` 的任务与执行 `board->begin()` 的任务在同一个核心上运行可以缓解画面漂移问题 3. **示例代码** diff --git a/docs/envs/use_with_idf.md b/docs/envs/use_with_idf.md index 25537644..6bdf9d05 100644 --- a/docs/envs/use_with_idf.md +++ b/docs/envs/use_with_idf.md @@ -106,7 +106,7 @@ Please follow these steps to resolve: c. **Configure LVGL Task** - - If using LVGL, setting the task that executes `lv_timer_handler()` to run on the same core as the RGB LCD initialization task can help mitigate the screen drift issue + - If using LVGL, setting the task that executes `lv_timer_handler()` to run on the same core as the task that executes `board->begin()` can help mitigate the screen drift issue 3. **Example Code** diff --git a/docs/envs/use_with_idf_cn.md b/docs/envs/use_with_idf_cn.md index 44d0c3fa..ed927b5f 100644 --- a/docs/envs/use_with_idf_cn.md +++ b/docs/envs/use_with_idf_cn.md @@ -106,7 +106,7 @@ ESP32_Display_Panel 已上传到 [Espressif 组件库](https://components.espres c. **配置 LVGL 任务** - - 如果使用 LVGL,设置执行 `lv_timer_handler()` 任务与执行 RGB LCD 初始化任务在同一个核心上运行可以缓解画面漂移问题 + - 如果使用 LVGL,设置执行 `lv_timer_handler()` 的任务与执行 `board->begin()` 的任务在同一个核心上运行可以缓解画面漂移问题 3. **示例代码** diff --git a/docs/envs/use_with_micropython.md b/docs/envs/use_with_micropython.md new file mode 100644 index 00000000..eaa64d2e --- /dev/null +++ b/docs/envs/use_with_micropython.md @@ -0,0 +1,193 @@ +# Using with micropython + +This is an example of how to integrate this library into micropython. It's written for an ESP32-S3, however it should be easy to adapt to different supported ESP-Chips. Please note, that you'll need at least 4mb of flash. + +## Step-by-Step instructions + +1. Install IDF and micropython + + ```bash + mkdir ~/esp32build + pushd ~/esp32build + git clone -b v5.2.2 --recursive https://github.com/espressif/esp-idf.git + pushd esp-idf + ./install.sh esp32 + source export.sh + popd + git clone https://github.com/micropython/micropython.git + pushd micropython + git submodule update --init --recursive + pushd mpy-cross + make + popd + ``` + +2. Ensure, you can build a working firmware + + ```bash + make BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT -C ports/esp32 + pushd ports/esp32 + python -m esptool --port /dev/ttyACM0 --chip esp32s3 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 4MB --flash_freq 80m 0x0 build-ESP32_GENERIC_S3-SPIRAM_OCT/bootloader/bootloader.bin 0x8000 build-ESP32_GENERIC_S3-SPIRAM_OCT/partition_table/partition-table.bin 0x10000 build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin + popd + popd + ``` + Now, test the board and ensure your build of micropython works. + +3. Download ESP32_Display_Panel and it's dependencies + + ```bash + git clone https://github.com/esp-arduino-libs/ESP32_Display_Panel.git + git clone https://github.com/esp-arduino-libs/esp-lib-utils.git + git clone https://github.com/esp-arduino-libs/ESP32_IO_Expander.git + ``` + +4. Create a custom user-module definition + + ```bash + cat > micropython.cmake << EOF + include(~/esp32build/ESP32_Display_Panel/micropython.cmake) + include(~/esp32build/esp-lib-utils/micropython.cmake) + include(~/esp32build/ESP32_IO_Expander/micropython.cmake) + EOF + ``` + +5. Copy some header-files + + ```bash + cp esp-idf/components/esp_lcd/include/esp_lcd_panel_commands.h ESP32_Display_Panel/mpy_support/ + cp esp-idf/components/esp_lcd/interface/esp_lcd_panel_interface.h ESP32_Display_Panel/mpy_support/ + cp esp-idf/components/esp_lcd/include/esp_lcd_panel_io.h ESP32_Display_Panel/mpy_support/ + cp esp-idf/components/esp_lcd/interface/esp_lcd_panel_io_interface.h ESP32_Display_Panel/mpy_support/ + cp esp-idf/components/esp_lcd/include/esp_lcd_panel_ops.h ESP32_Display_Panel/mpy_support/ + cp esp-idf/components/esp_lcd/include/esp_lcd_panel_rgb.h ESP32_Display_Panel/mpy_support/ + cp esp-idf/components/esp_lcd/include/esp_lcd_panel_vendor.h ESP32_Display_Panel/mpy_support/ + cp esp-idf/components/esp_lcd/include/esp_lcd_types.h ESP32_Display_Panel/mpy_support/ + ``` + +6. Rebuild micropython to include the new modules + + ```bash + pushd micropython + make BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT USER_C_MODULES=~/esp32build/micropython.cmake -C ports/esp32 + pushd ports/esp32 + python -m esptool --port /dev/ttyACM0 --chip esp32s3 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 4MB --flash_freq 80m 0x0 build-ESP32_GENERIC_S3-SPIRAM_OCT/bootloader/bootloader.bin 0x8000 build-ESP32_GENERIC_S3-SPIRAM_OCT/partition_table/partition-table.bin 0x10000 build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin + popd + popd + ``` + + This may fail if your chip has a small flash size, in this case you have to increase the size of the application partition. E.g. for a 4mb flash chip edit *micropython/ports/esp32/partitions-4MiB.csv* and change the last two lines from: + + ```csv + factory, app, factory, 0x10000, 0x1F0000, + vfs, data, fat, 0x200000, 0x200000, + ``` + + to + + ```csv + factory, app, factory, 0x10000, 0x2F0000, + vfs, data, fat, 0x300000, 0x100000, + ``` + +7. Test the module + + Connect to your board and run: + + ```python + from esp_panel import Board + board = Board() + board.init() + ``` + + `board.init()` should return False, as we yet have to define a board. + +8. Define your Board + + Edit *ESP32_Display_Panel/mpy_support/esp_panel_mp_board.cpp*. Add a Board definition: + + ```c++ + const BoardConfig BOARD_EXTERNAL_CONFIG = { + /* General */ + .name = "ESP_PANEL_BOARD_NAME", + .lcd = BoardConfig::LCD_Config{ + .bus_config = esp_panel::drivers::BusSPI::Config{ + .host_id = 1, + // Host + .host = esp_panel::drivers::BusSPI::HostPartialConfig{ + .mosi_io_num = 6, //ESP_PANEL_BOARD_LCD_SPI_IO_MOSI, + .miso_io_num = 8, //ESP_PANEL_BOARD_LCD_SPI_IO_MISO, + .sclk_io_num = 7, //ESP_PANEL_BOARD_LCD_SPI_IO_SCK, + }, + // Control Panel + .control_panel = esp_panel::drivers::BusSPI::ControlPanelPartialConfig{ + .cs_gpio_num = 5, //ESP_PANEL_BOARD_LCD_SPI_IO_CS, + .dc_gpio_num = 4, //ESP_PANEL_BOARD_LCD_SPI_IO_DC, + .spi_mode = 0, //ESP_PANEL_BOARD_LCD_SPI_MODE, + .pclk_hz = 40 * 1000 * 1000, //ESP_PANEL_BOARD_LCD_SPI_CLK_HZ, + .lcd_cmd_bits = 8, //ESP_PANEL_BOARD_LCD_SPI_CMD_BITS, + .lcd_param_bits = 8, //ESP_PANEL_BOARD_LCD_SPI_PARAM_BITS, + }, + }, + .device_name = "ILI9341", + .device_config = { + // Device + .device = esp_panel::drivers::LCD::DevicePartialConfig{ + .reset_gpio_num = 48, //ESP_PANEL_BOARD_LCD_RST_IO, + .rgb_ele_order = 0, //ESP_PANEL_BOARD_LCD_COLOR_BGR_ORDER, + .bits_per_pixel = 18, //ESP_PANEL_BOARD_LCD_COLOR_BITS, 16/18/24 + .flags_reset_active_high = 0, //ESP_PANEL_BOARD_LCD_RST_LEVEL, + }, + // Vendor + .vendor = esp_panel::drivers::LCD::VendorPartialConfig{ + .hor_res = 320, //ESP_PANEL_BOARD_WIDTH, + .ver_res = 480, //ESP_PANEL_BOARD_HEIGHT, + }, + }, + .pre_process = { + .invert_color = 0, //ESP_PANEL_BOARD_LCD_COLOR_INEVRT_BIT, + }, + }, + }; + ``` + + Then replace the constructor + + ```c++ + self->board = utils::make_shared() + ``` + + with + + ```c++ + self->board = utils::make_shared(BOARD_EXTERNAL_CONFIG); + ``` + +9. Edit esp_panel_drivers_conf.h + + Edit *ESP32_Display_Panel/esp_panel_drivers_conf.h* and ensure, the drivers referenced in your board config are being + build. **Warning**: `ESP_PANEL_DRIVERS_BUS_USE_ALL` does not seem to work. Set to 0 and manually include the bus driver + you need. Same goes for `ESP_PANEL_DRIVERS_BUS_COMPILE_UNUSED_DRIVERS`. + +10. Repeat **Step 6** to rebuild micropython + +11. Test your display + + Connect to your board and run: + + ```python + from esp_panel import Board + board = Board() + board.init() + board.begin() + board.color_bar_test() + ``` + +12. Profit! :) + + To include touch support, see *ESP32_Display_Panel/examples/arduino/board/board_dynamic_config/board_external_config.cpp* for an example touch definition. + +## Known Pitfalls + +1. When `board.init()` returns false, likely your driver-definition in *esp_panel_drivers_conf.h* does not match. +2. `board.begin()` crashes, if you rely on `ESP_PANEL_DRIVERS_BUS_USE_ALL` +3. If you edit *ESP32_Display_Panel/esp_panel_drivers_conf.h*, also modify *ESP32_Display_Panel/mpy_support/esp_panel_mp_board.cpp* (like add or remove an empty line). Otherwise, changes to *esp_panel_drivers_conf.h* will not be recognized. diff --git a/docs/envs/use_with_micropython_cn.md b/docs/envs/use_with_micropython_cn.md new file mode 100644 index 00000000..4e476f50 --- /dev/null +++ b/docs/envs/use_with_micropython_cn.md @@ -0,0 +1,193 @@ +# 在 micropython 中使用 + +这是一个如何将此库集成到 micropython 的示例。它是为 ESP32-S3 编写的,但应该很容易适应不同的受支持的 ESP 芯片。请注意,您至少需要 4MB 的闪存。 + +## 逐步说明 + +1. 安装 IDF 和 micropython + + ```bash + mkdir ~/esp32build + pushd ~/esp32build + git clone -b v5.2.2 --recursive https://github.com/espressif/esp-idf.git + pushd esp-idf + ./install.sh esp32 + source export.sh + popd + git clone https://github.com/micropython/micropython.git + pushd micropython + git submodule update --init --recursive + pushd mpy-cross + make + popd + ``` + +2. 确保您可以构建一个可工作的固件 + + ```bash + make BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT -C ports/esp32 + pushd ports/esp32 + python -m esptool --port /dev/ttyACM0 --chip esp32s3 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 4MB --flash_freq 80m 0x0 build-ESP32_GENERIC_S3-SPIRAM_OCT/bootloader/bootloader.bin 0x8000 build-ESP32_GENERIC_S3-SPIRAM_OCT/partition_table/partition-table.bin 0x10000 build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin + popd + popd + ``` + 现在,测试开发板并确保您构建的 micropython 可以正常工作。 + +3. 下载 ESP32_Display_Panel 及其依赖项 + + ```bash + git clone https://github.com/esp-arduino-libs/ESP32_Display_Panel.git + git clone https://github.com/esp-arduino-libs/esp-lib-utils.git + git clone https://github.com/esp-arduino-libs/ESP32_IO_Expander.git + ``` + +4. 创建自定义用户模块定义 + + ```bash + cat > micropython.cmake << EOF + include(~/esp32build/ESP32_Display_Panel/micropython.cmake) + include(~/esp32build/esp-lib-utils/micropython.cmake) + include(~/esp32build/ESP32_IO_Expander/micropython.cmake) + EOF + ``` + +5. 复制一些头文件 + + ```bash + cp esp-idf/components/esp_lcd/include/esp_lcd_panel_commands.h ESP32_Display_Panel/mpy_support/ + cp esp-idf/components/esp_lcd/interface/esp_lcd_panel_interface.h ESP32_Display_Panel/mpy_support/ + cp esp-idf/components/esp_lcd/include/esp_lcd_panel_io.h ESP32_Display_Panel/mpy_support/ + cp esp-idf/components/esp_lcd/interface/esp_lcd_panel_io_interface.h ESP32_Display_Panel/mpy_support/ + cp esp-idf/components/esp_lcd/include/esp_lcd_panel_ops.h ESP32_Display_Panel/mpy_support/ + cp esp-idf/components/esp_lcd/include/esp_lcd_panel_rgb.h ESP32_Display_Panel/mpy_support/ + cp esp-idf/components/esp_lcd/include/esp_lcd_panel_vendor.h ESP32_Display_Panel/mpy_support/ + cp esp-idf/components/esp_lcd/include/esp_lcd_types.h ESP32_Display_Panel/mpy_support/ + ``` + +6. 重新构建 micropython 以包含新模块 + + ```bash + pushd micropython + make BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT USER_C_MODULES=~/esp32build/micropython.cmake -C ports/esp32 + pushd ports/esp32 + python -m esptool --port /dev/ttyACM0 --chip esp32s3 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 4MB --flash_freq 80m 0x0 build-ESP32_GENERIC_S3-SPIRAM_OCT/bootloader/bootloader.bin 0x8000 build-ESP32_GENERIC_S3-SPIRAM_OCT/partition_table/partition-table.bin 0x10000 build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin + popd + popd + ``` + + 如果您的芯片闪存大小较小,这可能会失败,在这种情况下,您必须增加应用程序分区的大小。例如,对于 4MB 闪存芯片,编辑 *micropython/ports/esp32/partitions-4MiB.csv* 并将最后两行从: + + ```csv + factory, app, factory, 0x10000, 0x1F0000, + vfs, data, fat, 0x200000, 0x200000, + ``` + + 改为: + + ```csv + factory, app, factory, 0x10000, 0x2F0000, + vfs, data, fat, 0x300000, 0x100000, + ``` + +7. 测试模块 + + 连接到您的开发板并运行: + + ```python + from esp_panel import Board + board = Board() + board.init() + ``` + + `board.init()` 应该返回 False,因为我们还需要定义一个开发板。 + +8. 定义您的开发板 + + 编辑 *ESP32_Display_Panel/mpy_support/esp_panel_mp_board.cpp*。添加一个开发板定义: + + ```c++ + const BoardConfig BOARD_EXTERNAL_CONFIG = { + /* General */ + .name = "ESP_PANEL_BOARD_NAME", + .lcd = BoardConfig::LCD_Config{ + .bus_config = esp_panel::drivers::BusSPI::Config{ + .host_id = 1, + // Host + .host = esp_panel::drivers::BusSPI::HostPartialConfig{ + .mosi_io_num = 6, //ESP_PANEL_BOARD_LCD_SPI_IO_MOSI, + .miso_io_num = 8, //ESP_PANEL_BOARD_LCD_SPI_IO_MISO, + .sclk_io_num = 7, //ESP_PANEL_BOARD_LCD_SPI_IO_SCK, + }, + // Control Panel + .control_panel = esp_panel::drivers::BusSPI::ControlPanelPartialConfig{ + .cs_gpio_num = 5, //ESP_PANEL_BOARD_LCD_SPI_IO_CS, + .dc_gpio_num = 4, //ESP_PANEL_BOARD_LCD_SPI_IO_DC, + .spi_mode = 0, //ESP_PANEL_BOARD_LCD_SPI_MODE, + .pclk_hz = 40 * 1000 * 1000, //ESP_PANEL_BOARD_LCD_SPI_CLK_HZ, + .lcd_cmd_bits = 8, //ESP_PANEL_BOARD_LCD_SPI_CMD_BITS, + .lcd_param_bits = 8, //ESP_PANEL_BOARD_LCD_SPI_PARAM_BITS, + }, + }, + .device_name = "ILI9341", + .device_config = { + // Device + .device = esp_panel::drivers::LCD::DevicePartialConfig{ + .reset_gpio_num = 48, //ESP_PANEL_BOARD_LCD_RST_IO, + .rgb_ele_order = 0, //ESP_PANEL_BOARD_LCD_COLOR_BGR_ORDER, + .bits_per_pixel = 18, //ESP_PANEL_BOARD_LCD_COLOR_BITS, 16/18/24 + .flags_reset_active_high = 0, //ESP_PANEL_BOARD_LCD_RST_LEVEL, + }, + // Vendor + .vendor = esp_panel::drivers::LCD::VendorPartialConfig{ + .hor_res = 320, //ESP_PANEL_BOARD_WIDTH, + .ver_res = 480, //ESP_PANEL_BOARD_HEIGHT, + }, + }, + .pre_process = { + .invert_color = 0, //ESP_PANEL_BOARD_LCD_COLOR_INEVRT_BIT, + }, + }, + }; + ``` + + 然后替换构造函数 + + ```c++ + self->board = utils::make_shared() + ``` + + 为 + + ```c++ + self->board = utils::make_shared(BOARD_EXTERNAL_CONFIG); + ``` + +9. 编辑 esp_panel_drivers_conf.h + + 编辑 *ESP32_Display_Panel/esp_panel_drivers_conf.h* 并确保在您的开发板配置中引用的驱动程序被构建。 + **警告**:`ESP_PANEL_DRIVERS_BUS_USE_ALL` 似乎不起作用。设置为 0 并手动包含您需要的总线驱动程序。 + `ESP_PANEL_DRIVERS_BUS_COMPILE_UNUSED_DRIVERS` 也是如此。 + +10. 重复 **步骤 6** 重新构建 micropython + +11. 测试您的显示屏 + + 连接到您的开发板并运行: + + ```python + from esp_panel import Board + board = Board() + board.init() + board.begin() + board.color_bar_test() + ``` + +12. 大功告成!:) + + 要包含触摸支持,请参阅 *ESP32_Display_Panel/examples/arduino/board/board_dynamic_config/board_external_config.cpp* 获取触摸定义示例。 + +## 已知陷阱 + +1. 当 `board.init()` 返回 false 时,很可能是您在 *esp_panel_drivers_conf.h* 中的驱动程序定义不匹配。 +2. 如果您依赖 `ESP_PANEL_DRIVERS_BUS_USE_ALL`,`board.begin()` 会崩溃。 +3. 如果您编辑 *ESP32_Display_Panel/esp_panel_drivers_conf.h*,还需要修改 *ESP32_Display_Panel/mpy_support/esp_panel_mp_board.cpp*(比如添加或删除一个空行)。否则,对 *esp_panel_drivers_conf.h* 的更改将不会被识别。 diff --git a/esp_panel_board_custom_conf.h b/esp_panel_board_custom_conf.h index 1b119178..aa417d4b 100644 --- a/esp_panel_board_custom_conf.h +++ b/esp_panel_board_custom_conf.h @@ -476,6 +476,22 @@ #define ESP_PANEL_BOARD_BACKLIGHT_IO (38) // Output GPIO pin number #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (1) // Active level, 0: low, 1: high +#if ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC + /** + * @brief PWM parameters configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ (5000) // LEDC timer frequency. + // Different backlight driver chips may have different + // frequency limits, please refer to the datasheet of + // the specific chip. + // https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues/188 + + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION (10) // LEDC timer duty resolution. + // The frequency and duty resolution of the LEDC timer + // need to be properly matched, please refer to: + // https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html#supported-range-of-frequency-and-duty-resolutions +#endif + #elif ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_CUSTOM /** @@ -735,9 +751,9 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 -#endif // ESP_PANEL_BOARD_USE_CUSTOM +#endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM // *INDENT-ON* diff --git a/examples/arduino/board/board_static_config/esp_panel_board_custom_conf.h b/examples/arduino/board/board_static_config/esp_panel_board_custom_conf.h index 1b119178..aa417d4b 100644 --- a/examples/arduino/board/board_static_config/esp_panel_board_custom_conf.h +++ b/examples/arduino/board/board_static_config/esp_panel_board_custom_conf.h @@ -476,6 +476,22 @@ #define ESP_PANEL_BOARD_BACKLIGHT_IO (38) // Output GPIO pin number #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (1) // Active level, 0: low, 1: high +#if ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC + /** + * @brief PWM parameters configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ (5000) // LEDC timer frequency. + // Different backlight driver chips may have different + // frequency limits, please refer to the datasheet of + // the specific chip. + // https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues/188 + + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION (10) // LEDC timer duty resolution. + // The frequency and duty resolution of the LEDC timer + // need to be properly matched, please refer to: + // https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html#supported-range-of-frequency-and-duty-resolutions +#endif + #elif ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_CUSTOM /** @@ -735,9 +751,9 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 -#endif // ESP_PANEL_BOARD_USE_CUSTOM +#endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM // *INDENT-ON* diff --git a/examples/arduino/gui/lvgl_v8/simple_port/esp_panel_board_custom_conf.h b/examples/arduino/gui/lvgl_v8/simple_port/esp_panel_board_custom_conf.h index 1b119178..aa417d4b 100644 --- a/examples/arduino/gui/lvgl_v8/simple_port/esp_panel_board_custom_conf.h +++ b/examples/arduino/gui/lvgl_v8/simple_port/esp_panel_board_custom_conf.h @@ -476,6 +476,22 @@ #define ESP_PANEL_BOARD_BACKLIGHT_IO (38) // Output GPIO pin number #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (1) // Active level, 0: low, 1: high +#if ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC + /** + * @brief PWM parameters configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ (5000) // LEDC timer frequency. + // Different backlight driver chips may have different + // frequency limits, please refer to the datasheet of + // the specific chip. + // https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues/188 + + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION (10) // LEDC timer duty resolution. + // The frequency and duty resolution of the LEDC timer + // need to be properly matched, please refer to: + // https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html#supported-range-of-frequency-and-duty-resolutions +#endif + #elif ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_CUSTOM /** @@ -735,9 +751,9 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 -#endif // ESP_PANEL_BOARD_USE_CUSTOM +#endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM // *INDENT-ON* diff --git a/examples/arduino/gui/lvgl_v8/simple_rotation/esp_panel_board_custom_conf.h b/examples/arduino/gui/lvgl_v8/simple_rotation/esp_panel_board_custom_conf.h index 1b119178..aa417d4b 100644 --- a/examples/arduino/gui/lvgl_v8/simple_rotation/esp_panel_board_custom_conf.h +++ b/examples/arduino/gui/lvgl_v8/simple_rotation/esp_panel_board_custom_conf.h @@ -476,6 +476,22 @@ #define ESP_PANEL_BOARD_BACKLIGHT_IO (38) // Output GPIO pin number #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (1) // Active level, 0: low, 1: high +#if ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC + /** + * @brief PWM parameters configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ (5000) // LEDC timer frequency. + // Different backlight driver chips may have different + // frequency limits, please refer to the datasheet of + // the specific chip. + // https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues/188 + + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION (10) // LEDC timer duty resolution. + // The frequency and duty resolution of the LEDC timer + // need to be properly matched, please refer to: + // https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html#supported-range-of-frequency-and-duty-resolutions +#endif + #elif ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_CUSTOM /** @@ -735,9 +751,9 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 -#endif // ESP_PANEL_BOARD_USE_CUSTOM +#endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM // *INDENT-ON* diff --git a/examples/arduino/gui/lvgl_v8/squareline_port/esp_panel_board_custom_conf.h b/examples/arduino/gui/lvgl_v8/squareline_port/esp_panel_board_custom_conf.h index 1b119178..aa417d4b 100644 --- a/examples/arduino/gui/lvgl_v8/squareline_port/esp_panel_board_custom_conf.h +++ b/examples/arduino/gui/lvgl_v8/squareline_port/esp_panel_board_custom_conf.h @@ -476,6 +476,22 @@ #define ESP_PANEL_BOARD_BACKLIGHT_IO (38) // Output GPIO pin number #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (1) // Active level, 0: low, 1: high +#if ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC + /** + * @brief PWM parameters configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ (5000) // LEDC timer frequency. + // Different backlight driver chips may have different + // frequency limits, please refer to the datasheet of + // the specific chip. + // https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues/188 + + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION (10) // LEDC timer duty resolution. + // The frequency and duty resolution of the LEDC timer + // need to be properly matched, please refer to: + // https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html#supported-range-of-frequency-and-duty-resolutions +#endif + #elif ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_CUSTOM /** @@ -735,9 +751,9 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 -#endif // ESP_PANEL_BOARD_USE_CUSTOM +#endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM // *INDENT-ON* diff --git a/examples/arduino/gui/lvgl_v8/squareline_wifi_clock/esp_panel_board_custom_conf.h b/examples/arduino/gui/lvgl_v8/squareline_wifi_clock/esp_panel_board_custom_conf.h index 1b119178..aa417d4b 100644 --- a/examples/arduino/gui/lvgl_v8/squareline_wifi_clock/esp_panel_board_custom_conf.h +++ b/examples/arduino/gui/lvgl_v8/squareline_wifi_clock/esp_panel_board_custom_conf.h @@ -476,6 +476,22 @@ #define ESP_PANEL_BOARD_BACKLIGHT_IO (38) // Output GPIO pin number #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (1) // Active level, 0: low, 1: high +#if ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC + /** + * @brief PWM parameters configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ (5000) // LEDC timer frequency. + // Different backlight driver chips may have different + // frequency limits, please refer to the datasheet of + // the specific chip. + // https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues/188 + + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION (10) // LEDC timer duty resolution. + // The frequency and duty resolution of the LEDC timer + // need to be properly matched, please refer to: + // https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html#supported-range-of-frequency-and-duty-resolutions +#endif + #elif ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_CUSTOM /** @@ -735,9 +751,9 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 -#endif // ESP_PANEL_BOARD_USE_CUSTOM +#endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM // *INDENT-ON* diff --git a/examples/esp_idf/lvgl_v8_port/sdkconfig.defaults b/examples/esp_idf/lvgl_v8_port/sdkconfig.defaults index 1cd128bb..8f3d26ec 100644 --- a/examples/esp_idf/lvgl_v8_port/sdkconfig.defaults +++ b/examples/esp_idf/lvgl_v8_port/sdkconfig.defaults @@ -1,4 +1,3 @@ -CONFIG_ESP_TASK_WDT_EN=n CONFIG_FREERTOS_HZ=1000 CONFIG_COMPILER_CXX_EXCEPTIONS=y diff --git a/examples/esp_idf/lvgl_v8_port/sdkconfig.defaults.esp32s3 b/examples/esp_idf/lvgl_v8_port/sdkconfig.defaults.esp32s3 index 8770213f..4a53adb8 100644 --- a/examples/esp_idf/lvgl_v8_port/sdkconfig.defaults.esp32s3 +++ b/examples/esp_idf/lvgl_v8_port/sdkconfig.defaults.esp32s3 @@ -1,3 +1,5 @@ +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y + CONFIG_COMPILER_OPTIMIZATION_PERF=y CONFIG_SPIRAM=y diff --git a/examples/platformio/lvgl_v8_port/src/esp_panel_board_custom_conf.h b/examples/platformio/lvgl_v8_port/src/esp_panel_board_custom_conf.h index 1b119178..aa417d4b 100644 --- a/examples/platformio/lvgl_v8_port/src/esp_panel_board_custom_conf.h +++ b/examples/platformio/lvgl_v8_port/src/esp_panel_board_custom_conf.h @@ -476,6 +476,22 @@ #define ESP_PANEL_BOARD_BACKLIGHT_IO (38) // Output GPIO pin number #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (1) // Active level, 0: low, 1: high +#if ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC + /** + * @brief PWM parameters configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ (5000) // LEDC timer frequency. + // Different backlight driver chips may have different + // frequency limits, please refer to the datasheet of + // the specific chip. + // https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues/188 + + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION (10) // LEDC timer duty resolution. + // The frequency and duty resolution of the LEDC timer + // need to be properly matched, please refer to: + // https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html#supported-range-of-frequency-and-duty-resolutions +#endif + #elif ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_CUSTOM /** @@ -735,9 +751,9 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 -#endif // ESP_PANEL_BOARD_USE_CUSTOM +#endif // ESP_PANEL_BOARD_DEFAULT_USE_CUSTOM // *INDENT-ON* diff --git a/idf_component.yml b/idf_component.yml index 2b04706c..4e1f039e 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.0.1" +version: "1.0.3" description: ESP32_Display_Panel is a display driver and GUI porting library designed by Espressif specifically for ESP series SoCs (ESP32, ESP32-S3, ESP32-P4, etc.) url: https://github.com/esp-arduino-libs/ESP32_Display_Panel repository: https://github.com/esp-arduino-libs/ESP32_Display_Panel.git diff --git a/library.properties b/library.properties index 2733fd27..7f9996d3 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ESP32_Display_Panel -version=1.0.1 +version=1.0.3 author=espressif maintainer=espressif sentence=ESP32_Display_Panel is a display driver and GUI porting library designed by Espressif specifically for ESP series SoCs (ESP32, ESP32-S3, ESP32-P4, etc.) diff --git a/src/board/custom/Kconfig.board_custom.backlight b/src/board/custom/Kconfig.board_custom.backlight index 9411de34..ffa5f5e5 100644 --- a/src/board/custom/Kconfig.board_custom.backlight +++ b/src/board/custom/Kconfig.board_custom.backlight @@ -57,6 +57,23 @@ if ESP_PANEL_BOARD_USE_BACKLIGHT Active level for backlight control. endmenu + menu "PWM parameters" + depends on ESP_PANEL_BOARD_BACKLIGHT_TYPE_PWM_LEDC + + config ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ + int "Frequency" + default 5000 + help + Frequency for PWM control. + + config ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION + int "Duty resolution" + default 10 + range 1 20 + help + Duty resolution for PWM control. + endmenu + config ESP_PANEL_BOARD_BACKLIGHT_IDLE_OFF bool "Idle off" default n diff --git a/src/board/custom/esp_panel_board_kconfig_custom_backlight.h b/src/board/custom/esp_panel_board_kconfig_custom_backlight.h index c9501fd5..ba6c8f94 100644 --- a/src/board/custom/esp_panel_board_kconfig_custom_backlight.h +++ b/src/board/custom/esp_panel_board_kconfig_custom_backlight.h @@ -42,6 +42,26 @@ #error "Missing configuration: ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL" #endif #endif + + #if (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + #ifndef ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ + #ifdef CONFIG_ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ CONFIG_ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ + #else + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ 5000 // Keep the backward compatibility + #endif + #endif + #endif + + #if (ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC) + #ifndef ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION + #ifdef CONFIG_ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION CONFIG_ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION + #else + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION 10 // Keep the backward compatibility + #endif + #endif + #endif #endif #ifndef ESP_PANEL_BOARD_BACKLIGHT_IDLE_OFF diff --git a/src/board/esp_panel_board_default_config.cpp b/src/board/esp_panel_board_default_config.cpp index 4cdfe7c2..9733e64d 100644 --- a/src/board/esp_panel_board_default_config.cpp +++ b/src/board/esp_panel_board_default_config.cpp @@ -293,6 +293,10 @@ const BoardConfig ESP_PANEL_BOARD_DEFAULT_CONFIG = { }, #elif ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC .config = BacklightPWM_LEDC::Config{ + .ledc_timer = BacklightPWM_LEDC::LEDC_TimerPartialConfig{ + .freq_hz = ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ, + .duty_resolution = ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION, + }, .ledc_channel = BacklightPWM_LEDC::LEDC_ChannelPartialConfig{ .io_num = ESP_PANEL_BOARD_BACKLIGHT_IO, .on_level = ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL, diff --git a/src/board/supported/jingcai/BOARD_JINGCAI_ESP32_4848S040C_I_Y_3.h b/src/board/supported/jingcai/BOARD_JINGCAI_ESP32_4848S040C_I_Y_3.h index 20e78e1f..ec2c2004 100644 --- a/src/board/supported/jingcai/BOARD_JINGCAI_ESP32_4848S040C_I_Y_3.h +++ b/src/board/supported/jingcai/BOARD_JINGCAI_ESP32_4848S040C_I_Y_3.h @@ -345,6 +345,23 @@ #define ESP_PANEL_BOARD_BACKLIGHT_IO (38) // Output GPIO pin number #define ESP_PANEL_BOARD_BACKLIGHT_ON_LEVEL (1) // Active level, 0: low, 1: high + +#if ESP_PANEL_BOARD_BACKLIGHT_TYPE == ESP_PANEL_BACKLIGHT_TYPE_PWM_LEDC + /** + * @brief PWM parameters configuration + */ + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_FREQ_HZ (1000) // LEDC timer frequency. + // Different backlight driver chips may have different + // frequency limits, please refer to the datasheet of + // the specific chip. + // https://github.com/esp-arduino-libs/ESP32_Display_Panel/issues/188 + + #define ESP_PANEL_BOARD_BACKLIGHT_PWM_DUTY_RESOLUTION (10) // LEDC timer duty resolution. + // The frequency and duty resolution of the LEDC timer + // need to be properly matched, please refer to: + // https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html#supported-range-of-frequency-and-duty-resolutions +#endif + #endif // ESP_PANEL_BOARD_BACKLIGHT_TYPE /** @@ -381,7 +398,7 @@ * 3. Patch version mismatch: No impact on functionality */ #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 0 +#define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_MINOR 1 #define ESP_PANEL_BOARD_CUSTOM_FILE_VERSION_PATCH 0 // *INDENT-ON* diff --git a/src/drivers/io_expander/esp_panel_io_expander_adapter.hpp b/src/drivers/io_expander/esp_panel_io_expander_adapter.hpp index 0c463cc8..521ffda8 100644 --- a/src/drivers/io_expander/esp_panel_io_expander_adapter.hpp +++ b/src/drivers/io_expander/esp_panel_io_expander_adapter.hpp @@ -5,7 +5,6 @@ */ #pragma once -#include #include "utils/esp_panel_utils_log.h" #include "utils/esp_panel_utils_cxx.hpp" #include "drivers/host/esp_panel_host_i2c.hpp" diff --git a/src/drivers/lcd/port/esp_lcd_st7701_rgb.c b/src/drivers/lcd/port/esp_lcd_st7701_rgb.c index d14a3cd0..36c26fb4 100644 --- a/src/drivers/lcd/port/esp_lcd_st7701_rgb.c +++ b/src/drivers/lcd/port/esp_lcd_st7701_rgb.c @@ -348,9 +348,20 @@ static esp_err_t panel_st7701_mirror(esp_lcd_panel_t *panel, bool mirror_x, bool } else { st7701->madctl_val &= ~LCD_CMD_ML_BIT; } + + // Enable the Command2 BK0 + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, ST7701_CMD_CND2BKxSEL, (uint8_t []) { + ST7701_CMD_BKxSEL_BYTE0, ST7701_CMD_BKxSEL_BYTE1, ST7701_CMD_BKxSEL_BYTE2, ST7701_CMD_BKxSEL_BYTE3, + ST7701_CMD_BKxSEL_BK0 | ST7701_CMD_CN2_BIT, + }, 5), TAG, "send command failed"); ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, ST7701_CMD_SDIR, (uint8_t[]) { sdir_val, }, 1), TAG, "send command failed");; + + // Disable Command2 + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, ST7701_CMD_CND2BKxSEL, (uint8_t []) { + ST7701_CMD_BKxSEL_BYTE0, ST7701_CMD_BKxSEL_BYTE1, ST7701_CMD_BKxSEL_BYTE2, ST7701_CMD_BKxSEL_BYTE3, 0, + }, 5), TAG, "send command failed"); ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, (uint8_t[]) { st7701->madctl_val, }, 1), TAG, "send command failed");; diff --git a/src/esp_panel_versions.h b/src/esp_panel_versions.h index fb172c5b..648505fd 100644 --- a/src/esp_panel_versions.h +++ b/src/esp_panel_versions.h @@ -8,7 +8,7 @@ /* Library Version */ #define ESP_PANEL_VERSION_MAJOR 1 #define ESP_PANEL_VERSION_MINOR 0 -#define ESP_PANEL_VERSION_PATCH 1 +#define ESP_PANEL_VERSION_PATCH 3 /* File `esp_panel_drivers_conf.h` */ #define ESP_PANEL_DRIVERS_CONF_VERSION_MAJOR 1 @@ -17,8 +17,8 @@ /* File `esp_panel_board_custom_conf.h` */ #define ESP_PANEL_BOARD_CUSTOM_VERSION_MAJOR 1 -#define ESP_PANEL_BOARD_CUSTOM_VERSION_MINOR 0 -#define ESP_PANEL_BOARD_CUSTOM_VERSION_PATCH 1 +#define ESP_PANEL_BOARD_CUSTOM_VERSION_MINOR 1 +#define ESP_PANEL_BOARD_CUSTOM_VERSION_PATCH 0 /* File `esp_panel_board_supported_conf.h` */ #define ESP_PANEL_BOARD_SUPPORTED_VERSION_MAJOR 1 diff --git a/.gitlab/tools/check_executables.py b/tools/check_executables.py similarity index 96% rename from .gitlab/tools/check_executables.py rename to tools/check_executables.py index 64260f86..d959fa5f 100755 --- a/.gitlab/tools/check_executables.py +++ b/tools/check_executables.py @@ -25,7 +25,7 @@ def _strip_each_item(iterable: Iterable) -> List: COMPONENT_PATH = os.getenv('COMPONENT_PATH', os.getcwd()) -EXECUTABLE_LIST_FN = os.path.join(COMPONENT_PATH, '.gitlab/tools/executable-list.txt') +EXECUTABLE_LIST_FN = os.path.join(COMPONENT_PATH, 'tools/executable-list.txt') known_executables = _strip_each_item(open(EXECUTABLE_LIST_FN).readlines()) diff --git a/tools/check_file_version.py b/tools/check_file_version.py index 4f88afe3..99148ccd 100644 --- a/tools/check_file_version.py +++ b/tools/check_file_version.py @@ -7,6 +7,7 @@ exclude_dirs = [ './build', + './examples/platformio/lvgl_v8_port/.pio' ] internal_version_file = 'src/esp_panel_versions.h' include_files = [ diff --git a/.github/scripts/check_lib_versions.sh b/tools/check_lib_versions.sh similarity index 100% rename from .github/scripts/check_lib_versions.sh rename to tools/check_lib_versions.sh diff --git a/tools/executable-list.txt b/tools/executable-list.txt new file mode 100644 index 00000000..120e11ce --- /dev/null +++ b/tools/executable-list.txt @@ -0,0 +1,7 @@ +.gitlab/tools/check_readme_links.py +.gitlab/tools/push_to_github.sh + +tools/check_executables.py +tools/check_file_version.py +tools/check_lib_versions.sh +tools/sync_conf_files.py diff --git a/.gitlab/tools/idf_ci_utils.py b/tools/idf_ci_utils.py similarity index 100% rename from .gitlab/tools/idf_ci_utils.py rename to tools/idf_ci_utils.py diff --git a/tools/sync_conf_files.py b/tools/sync_conf_files.py index e14c6090..46197479 100644 --- a/tools/sync_conf_files.py +++ b/tools/sync_conf_files.py @@ -10,8 +10,8 @@ './examples/platformio/lvgl_v8_port/src/lv_conf.h', ] exclude_dirs = [ - './build', - './examples/platformio/lvgl_v8_port/.pio', + r'.*build.*', + r'.*pio.*', ] @@ -25,13 +25,21 @@ def is_same_path(path1, path2): def is_in_directory(file_path, directory): - directory = os.path.realpath(directory) + import re file_path = os.path.realpath(file_path) - return file_path.startswith(directory) + # Check if the file path matches any of the exclude directory patterns + for pattern in exclude_dirs: + if re.search(pattern, file_path): + return True + return False def is_same_file(file1, file2): + # Check if both files exist + if not os.path.exists(file1) or not os.path.exists(file2): + return False + with open(file1, 'r') as f1, open(file2, 'r') as f2: file1_content = f1.read() file2_content = f2.read() @@ -53,7 +61,7 @@ def replace_files(template_directory, search_directory, file_path): filename = os.path.basename(file_path) src_file = os.path.join(template_directory, filename) - if is_exclude_file(file_path): + if is_exclude_file(file_path) or not os.path.exists(src_file): print(f"Skip '{file_path}'") return