1111#include " lvgl_v8_port.h"
1212#include " lv_demos.h"
1313
14+ #define EXAMPLE_LCD_USE_EXTERNAL_INIT_CMD (0 )
15+
1416using namespace esp_panel ::drivers;
1517using namespace esp_panel ::board;
1618
1719static const char *TAG = " example" ;
20+ #if EXAMPLE_LCD_USE_EXTERNAL_INIT_CMD
21+ static const esp_panel_lcd_vendor_init_cmd_t external_init_cmd[] = {
22+ // {cmd, { data }, data_size, delay_ms}
23+ // {0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x13}, 5, 0},
24+ // {0xEF, (uint8_t []){0x08}, 1, 0},
25+ // {0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0},
26+ // ...
27+ };
28+ #endif // EXAMPLE_LCD_USE_EXTERNAL_INIT_CMD
1829
1930extern " C" void app_main ()
2031{
@@ -23,22 +34,41 @@ extern "C" void app_main()
2334
2435 ESP_LOGI (TAG, " Initializing board" );
2536 ESP_UTILS_CHECK_FALSE_EXIT (board->init (), " Board init failed" );
37+
2638#if LVGL_PORT_AVOID_TEARING_MODE
27- auto lcd = board->getLCD ();
28- // When avoid tearing function is enabled, the frame buffer number should be set in the board driver
29- lcd->configFrameBufferNumber (LVGL_PORT_DISP_BUFFER_NUM);
30- #if ESP_PANEL_DRIVERS_BUS_ENABLE_RGB && CONFIG_IDF_TARGET_ESP32S3
31- auto lcd_bus = lcd->getBus ();
39+ {
40+ auto lcd = board->getLCD ();
41+ // When avoid tearing function is enabled, the frame buffer number should be set in the board driver
42+ lcd->configFrameBufferNumber (LVGL_PORT_DISP_BUFFER_NUM);
43+ # if ESP_PANEL_DRIVERS_BUS_ENABLE_RGB && CONFIG_IDF_TARGET_ESP32S3
44+ auto lcd_bus = lcd->getBus ();
45+ /* *
46+ * As the anti-tearing feature typically consumes more PSRAM bandwidth, for the ESP32-S3, we need to utilize the
47+ * "bounce buffer" functionality to enhance the RGB data bandwidth.
48+ * This feature will consume `bounce_buffer_size * bytes_per_pixel * 2` of SRAM memory.
49+ */
50+ if (lcd_bus->getBasicAttributes ().type == ESP_PANEL_BUS_TYPE_RGB) {
51+ static_cast <BusRGB *>(lcd_bus)->configRGB_BounceBufferSize (lcd->getFrameWidth () * 10 );
52+ }
53+ # endif
54+ }
55+ #endif // LVGL_PORT_AVOID_TEARING_MODE
56+
57+ #if EXAMPLE_LCD_USE_EXTERNAL_INIT_CMD
58+ ESP_LOGI (TAG, " Using external LCD init command" );
59+ {
60+ auto lcd = board->getLCD ();
61+ ESP_UTILS_CHECK_FALSE_EXIT (
62+ lcd->configVendorCommands (external_init_cmd, sizeof (external_init_cmd) / sizeof (external_init_cmd[0 ])),
63+ " LCD init failed"
64+ );
65+ }
3266 /* *
33- * As the anti-tearing feature typically consumes more PSRAM bandwidth, for the ESP32-S3, we need to utilize the
34- * "bounce buffer" functionality to enhance the RGB data bandwidth.
35- * This feature will consume `bounce_buffer_size * bytes_per_pixel * 2` of SRAM memory.
67+ * In addition, you can also get handles to any other devices (like touch) and use `config*()` functions to
68+ * configure or replace default parameters, but this must be completed before `board->begin()`
3669 */
37- if (lcd_bus->getBasicAttributes ().type == ESP_PANEL_BUS_TYPE_RGB) {
38- static_cast <BusRGB *>(lcd_bus)->configRGB_BounceBufferSize (lcd->getFrameWidth () * 10 );
39- }
40- #endif
41- #endif
70+ #endif // EXAMPLE_LCD_USE_EXTERNAL_INIT_CMD
71+
4272 ESP_UTILS_CHECK_FALSE_EXIT (board->begin (), " Board begin failed" );
4373
4474 ESP_LOGI (TAG, " Initializing LVGL" );
0 commit comments