From a6ddcc030f6025268588d5a0817002e0f1a16060 Mon Sep 17 00:00:00 2001 From: Rene Date: Wed, 2 Oct 2024 08:35:31 +0200 Subject: [PATCH 01/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 16addc1..c0d2dea 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ This library integrates seamlessly in [PlatformIO](https://platformio.org/) and With the boards, there is a link supplied and there are a lot of examples present and this looks fine.... If you know your way around.... -These examples for [LVGL](https://lvgl.io/) depend on external libraries ([LCD_eSPI](https://github.com/Bodmer/LCD_eSPI) or [LovyanGFX](https://github.com/lovyan03/LovyanGFX)) but also different touch drivers. +These examples for [LVGL](https://lvgl.io/) depend on external libraries ([TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) or [LovyanGFX](https://github.com/lovyan03/LovyanGFX)) but also different touch drivers. However, when working with these libraries, I found out that these libraries had their flaws using these boards: - Lots of configuring to do before it all works, From 8ba252e798c4c6306fe00222841edc260d24196c Mon Sep 17 00:00:00 2001 From: Rene Date: Fri, 8 Nov 2024 20:39:27 +0100 Subject: [PATCH 02/10] Develop (#216) * Minor fix: add != NULL * Fixed typo in log * Pinned LVGL version to 9.2.0 (exact) * Changed the order of enabling interrupts (#196) Corrected interrupts leven pos/neg edge * Remove sw_rotate (#210) * Remove sw_rotate * Removed unused code * LVGL version to 9.2.2 * Enable all devices * Updated markdown * Lvgl9.2.2 (#211) * Remove sw_rotate * Removed unused code * LVGL version to 9.2.2 * Enable all devices * Updated markdown * Test hardware rotation st7701 * Test use underlying driver for swap and mirror * Reenabled code * test * Use define for DISPLAY_SOFTWARE_ROTATION * Update boards to develop * Added check for rst_gpio_num == GPIO_NUM_NC (#215) --- README.md | 2 + boards | 2 +- library.json | 2 +- platformio.ini | 2 +- src/esp32_smartdisplay.c | 19 +++++---- src/esp_touch_cst816s.c | 47 +++++++++++++--------- src/esp_touch_gt911.c | 78 ++++++++++++++++++------------------ src/esp_touch_xpt2046.c | 5 +-- src/lvgl_panel_gc9a01_spi.c | 5 +-- src/lvgl_panel_ili9341_spi.c | 5 +-- src/lvgl_panel_st7262_par.c | 5 +-- src/lvgl_panel_st7701_par.c | 48 +++++++++++++++++++--- src/lvgl_panel_st7789_i80.c | 5 +-- src/lvgl_panel_st7789_spi.c | 5 +-- src/lvgl_panel_st7796_spi.c | 5 +-- 15 files changed, 132 insertions(+), 103 deletions(-) diff --git a/README.md b/README.md index c0d2dea..47e8aeb 100644 --- a/README.md +++ b/README.md @@ -595,6 +595,8 @@ The following libraries are used from the [Espressif component registry](https:/ ## Version history +- October 2024 + - Fix for LVGL 9.2.2 that removed the sw_rotate flag - August 2024 - LVGL 9.2 - New boards diff --git a/boards b/boards index ae8d611..35fd2d6 160000 --- a/boards +++ b/boards @@ -1 +1 @@ -Subproject commit ae8d611a0ed8dacc744246bcaabd6711ccf793e9 +Subproject commit 35fd2d6067e1ce49e4460dff2be6c84c432042f6 diff --git a/library.json b/library.json index e31567d..d33e2d9 100644 --- a/library.json +++ b/library.json @@ -35,6 +35,6 @@ "frameworks": "arduino", "platforms": "espressif32", "dependencies": { - "lvgl/lvgl": "^9.2.0" + "lvgl/lvgl": "^9.2.2" } } \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index d2f7403..870b320 100644 --- a/platformio.ini +++ b/platformio.ini @@ -59,7 +59,7 @@ build_flags = '-D ESP_LCD_PANEL_IO_ADDITIONS_VER_PATCH=1' lib_deps = - lvgl/lvgl@^9.2.0 + lvgl/lvgl@^9.2.2 # The platformio.test_dir contains the test_main.cpp just to have an setup() and loop() function # so it will compile ${platformio.test_dir} diff --git a/src/esp32_smartdisplay.c b/src/esp32_smartdisplay.c index ccf1809..b7f46ea 100644 --- a/src/esp32_smartdisplay.c +++ b/src/esp32_smartdisplay.c @@ -94,11 +94,11 @@ void smartdisplay_lcd_set_brightness_cb(smartdisplay_lcd_adaptive_brightness_cb_ log_v("adaptive_brightness_cb:0x%08x, interval:%u", cb, interval); // Delete current timer if any - if (update_brightness_timer) + if (update_brightness_timer != NULL) lv_timer_del(update_brightness_timer); // Use callback for intensity or 50% default - if (cb && interval > 0) + if (cb != NULL && interval > 0) update_brightness_timer = lv_timer_create(adaptive_brightness, interval, cb); else smartdisplay_lcd_set_backlight(0.5f); @@ -107,7 +107,7 @@ void smartdisplay_lcd_set_brightness_cb(smartdisplay_lcd_adaptive_brightness_cb_ #ifdef BOARD_HAS_RGB_LED void smartdisplay_led_set_rgb(bool r, bool g, bool b) { - log_d("R:%d, G:%d, B:%d", r, b, b); + log_d("R:%d, G:%d, B:%d", r, g, b); digitalWrite(RGB_LED_R, !r); digitalWrite(RGB_LED_G, !g); @@ -193,9 +193,11 @@ void smartdisplay_init() #endif // Setup TFT display display = lvgl_lcd_init(); + +#ifndef DISPLAY_SOFTWARE_ROTATION // Register callback for hardware rotation - if (!display->sw_rotate) - lv_display_add_event_cb(display, lvgl_display_resolution_changed_callback, LV_EVENT_RESOLUTION_CHANGED, NULL); + lv_display_add_event_cb(display, lvgl_display_resolution_changed_callback, LV_EVENT_RESOLUTION_CHANGED, NULL); +#endif // Clear screen lv_obj_clean(lv_scr_act()); @@ -214,10 +216,11 @@ void smartdisplay_init() #endif } +#ifndef DISPLAY_SOFTWARE_ROTATION // Called when driver resolution is updated (including rotation) // Top of the display is top left when connector is at the bottom // The rotation values are relative to how you would rotate the physical display in the clockwise direction. -// Thus, LV_DISPLAY_ROTATION_90 means you rotate the hardware 90 degrees clockwise, and the display rotates 90 degrees counterclockwise to compensate. +// So, LV_DISPLAY_ROTATION_90 means you rotate the hardware 90 degrees clockwise, and the display rotates 90 degrees counterclockwise to compensate. void lvgl_display_resolution_changed_callback(lv_event_t *event) { const esp_lcd_panel_handle_t panel_handle = display->user_data; @@ -240,4 +243,6 @@ void lvgl_display_resolution_changed_callback(lv_event_t *event) ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, !DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y)); break; } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/esp_touch_cst816s.c b/src/esp_touch_cst816s.c index 1ca139b..4d3ff8f 100644 --- a/src/esp_touch_cst816s.c +++ b/src/esp_touch_cst816s.c @@ -86,6 +86,12 @@ esp_err_t cst816s_reset(esp_lcd_touch_handle_t th) if (th == NULL) return ESP_ERR_INVALID_ARG; + if (th->config.rst_gpio_num == GPIO_NUM_NC) + { + log_w("No RST pin defined"); + return ESP_OK; + } + esp_err_t res; // Set RST active if ((res = gpio_set_level(th->config.rst_gpio_num, th->config.levels.reset)) != ESP_OK) @@ -259,14 +265,29 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons memcpy(&th->config, config, sizeof(esp_lcd_touch_config_t)); portMUX_INITIALIZE(&th->data.lock); + // Reset controller + if ((res = cst816s_reset(th)) != ESP_OK) + { + log_e("GT911 reset failed"); + cst816s_del(th); + return res; + } + + // Read type and resolution + if ((res = cst816s_read_info(th)) != ESP_OK) + { + log_e("GT911 read info failed"); + cst816s_del(th); + return res; + } + if (config->int_gpio_num != GPIO_NUM_NC) { esp_rom_gpio_pad_select_gpio(config->int_gpio_num); const gpio_config_t cfg = { .pin_bit_mask = BIT64(config->int_gpio_num), .mode = GPIO_MODE_INPUT, - // If the user has provided a callback routine for the interrupt enable the interrupt mode on the negative edge. - .intr_type = config->interrupt_callback ? GPIO_INTR_NEGEDGE : GPIO_INTR_DISABLE}; + .intr_type = config->levels.interrupt ? GPIO_INTR_POSEDGE : GPIO_INTR_NEGEDGE}; if ((res = gpio_config(&cfg)) != ESP_OK) { free(th); @@ -278,9 +299,11 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons { if ((res = esp_lcd_touch_register_interrupt_callback(th, config->interrupt_callback)) != ESP_OK) { - gpio_reset_pin(th->config.int_gpio_num); + if (config->int_gpio_num != GPIO_NUM_NC) + gpio_reset_pin(th->config.int_gpio_num); + free(th); - log_e("Registering INT callback failed"); + log_e("Registering interrupt callback failed"); return res; } } @@ -306,22 +329,6 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons return res; } } - - // Reset controller - if ((res = cst816s_reset(th)) != ESP_OK) - { - log_e("GT911 reset failed"); - cst816s_del(th); - return res; - } - - // Read type and resolution - if ((res = cst816s_read_info(th)) != ESP_OK) - { - log_e("GT911 read info failed"); - cst816s_del(th); - return res; - } } log_d("handle:0x%08x", th); diff --git a/src/esp_touch_gt911.c b/src/esp_touch_gt911.c index d79930c..7e15308 100644 --- a/src/esp_touch_gt911.c +++ b/src/esp_touch_gt911.c @@ -82,6 +82,12 @@ esp_err_t gt911_reset(esp_lcd_touch_handle_t th) if (th == NULL) return ESP_ERR_INVALID_ARG; + if (th->config.rst_gpio_num == GPIO_NUM_NC) + { + log_w("No RST pin defined"); + return ESP_OK; + } + esp_err_t res; // Set RST active if ((res = gpio_set_level(th->config.rst_gpio_num, th->config.levels.reset)) != ESP_OK) @@ -397,53 +403,19 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const memcpy(&th->config, config, sizeof(esp_lcd_touch_config_t)); portMUX_INITIALIZE(&th->data.lock); - if (config->int_gpio_num != GPIO_NUM_NC) + // Initialize RST pin + if (config->rst_gpio_num != GPIO_NUM_NC) { - esp_rom_gpio_pad_select_gpio(config->int_gpio_num); + esp_rom_gpio_pad_select_gpio(config->rst_gpio_num); const gpio_config_t cfg = { - .pin_bit_mask = BIT64(config->int_gpio_num), - .mode = GPIO_MODE_INPUT, - // If the user has provided a callback routine for the interrupt enable the interrupt mode on the negative edge. - .intr_type = config->interrupt_callback ? GPIO_INTR_NEGEDGE : GPIO_INTR_DISABLE}; + .pin_bit_mask = BIT64(config->rst_gpio_num), + .mode = GPIO_MODE_OUTPUT}; if ((res = gpio_config(&cfg)) != ESP_OK) { free(th); - log_e("Configuring GPIO for INT failed"); + log_e("Configuring or setting GPIO for RST failed"); return res; } - - if (config->interrupt_callback != NULL) - { - if ((res = esp_lcd_touch_register_interrupt_callback(th, config->interrupt_callback)) != ESP_OK) - { - gpio_reset_pin(th->config.int_gpio_num); - free(th); - log_e("Registering INT callback failed"); - return res; - } - } - - if (config->rst_gpio_num != GPIO_NUM_NC) - { - esp_rom_gpio_pad_select_gpio(config->rst_gpio_num); - const gpio_config_t cfg = { - .pin_bit_mask = BIT64(config->rst_gpio_num), - .mode = GPIO_MODE_OUTPUT}; - if ((res = gpio_config(&cfg)) != ESP_OK) - { - if (th->config.int_gpio_num != GPIO_NUM_NC) - { - if (config->interrupt_callback != NULL) - gpio_isr_handler_remove(th->config.int_gpio_num); - - gpio_reset_pin(th->config.int_gpio_num); - } - - free(th); - log_e("Configuring or setting GPIO for RST failed"); - return res; - } - } } // Reset controller @@ -462,6 +434,32 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const return res; } + if (config->int_gpio_num != GPIO_NUM_NC) + { + esp_rom_gpio_pad_select_gpio(config->int_gpio_num); + const gpio_config_t cfg = { + .pin_bit_mask = BIT64(config->int_gpio_num), + .mode = GPIO_MODE_INPUT, + .intr_type = config->levels.interrupt ? GPIO_INTR_POSEDGE : GPIO_INTR_NEGEDGE}; + if ((res = gpio_config(&cfg)) != ESP_OK) + { + free(th); + log_e("Configuring GPIO for INT failed"); + return res; + } + + if (config->interrupt_callback != NULL) + { + if ((res = esp_lcd_touch_register_interrupt_callback(th, config->interrupt_callback)) != ESP_OK) + { + gpio_reset_pin(th->config.int_gpio_num); + free(th); + log_e("Registering interrupt callback failed"); + return res; + } + } + } + log_d("handle:0x%08x", th); *handle = th; diff --git a/src/esp_touch_xpt2046.c b/src/esp_touch_xpt2046.c index 27ff477..8c52434 100644 --- a/src/esp_touch_xpt2046.c +++ b/src/esp_touch_xpt2046.c @@ -204,8 +204,7 @@ esp_err_t esp_lcd_touch_new_spi_xpt2046(const esp_lcd_panel_io_handle_t io, cons const gpio_config_t cfg = { .pin_bit_mask = BIT64(config->int_gpio_num), .mode = GPIO_MODE_INPUT, - // If the user has provided a callback routine for the interrupt enable the interrupt mode on the negative edge. - .intr_type = config->interrupt_callback ? GPIO_INTR_NEGEDGE : GPIO_INTR_DISABLE}; + .intr_type = config->levels.interrupt ? GPIO_INTR_POSEDGE : GPIO_INTR_NEGEDGE}; if ((res = gpio_config(&cfg)) != ESP_OK) { free(th); @@ -219,7 +218,7 @@ esp_err_t esp_lcd_touch_new_spi_xpt2046(const esp_lcd_panel_io_handle_t io, cons { gpio_reset_pin(th->config.int_gpio_num); free(th); - log_e("Registering INT callback failed"); + log_e("Registering interrupt callback failed"); return res; } } diff --git a/src/lvgl_panel_gc9a01_spi.c b/src/lvgl_panel_gc9a01_spi.c index 7360336..b6c0b85 100644 --- a/src/lvgl_panel_gc9a01_spi.c +++ b/src/lvgl_panel_gc9a01_spi.c @@ -17,6 +17,7 @@ bool gc9a01_color_trans_done(esp_lcd_panel_io_handle_t panel_io_handle, esp_lcd_ void gc9a01_lv_flush(lv_display_t *display, const lv_area_t *area, uint8_t *px_map) { + // Hardware rotation is supported log_v("display:0x%08x, area:%0x%08x, color_map:0x%08x", display, area, px_map); esp_lcd_panel_handle_t panel_handle = display->user_data; @@ -40,10 +41,6 @@ lv_display_t *lvgl_lcd_init() void *drawBuffer = heap_caps_malloc(drawBufferSize, LVGL_BUFFER_MALLOC_FLAGS); lv_display_set_buffers(display, drawBuffer, NULL, drawBufferSize, LV_DISPLAY_RENDER_MODE_PARTIAL); - // Hardware rotation is supported - display->sw_rotate = 0; - display->rotation = LV_DISPLAY_ROTATION_0; - // Create SPI bus const spi_bus_config_t spi_bus_config = { .mosi_io_num = GC9A01_SPI_BUS_MOSI_IO_NUM, diff --git a/src/lvgl_panel_ili9341_spi.c b/src/lvgl_panel_ili9341_spi.c index 62f20f7..a36d53e 100644 --- a/src/lvgl_panel_ili9341_spi.c +++ b/src/lvgl_panel_ili9341_spi.c @@ -15,6 +15,7 @@ bool ili9341_color_trans_done(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_ void ili9341_lv_flush(lv_display_t *display, const lv_area_t *area, uint8_t *px_map) { + // Hardware rotation is supported esp_lcd_panel_handle_t panel_handle = display->user_data; uint32_t pixels = lv_area_get_size(area); uint16_t *p = (uint16_t *)px_map; @@ -36,10 +37,6 @@ lv_display_t *lvgl_lcd_init() void *drawBuffer = heap_caps_malloc(drawBufferSize, LVGL_BUFFER_MALLOC_FLAGS); lv_display_set_buffers(display, drawBuffer, NULL, drawBufferSize, LV_DISPLAY_RENDER_MODE_PARTIAL); - // Hardware rotation is supported - display->sw_rotate = 0; - display->rotation = LV_DISPLAY_ROTATION_0; - // Create SPI bus const spi_bus_config_t spi_bus_config = { .mosi_io_num = ILI9341_SPI_BUS_MOSI_IO_NUM, diff --git a/src/lvgl_panel_st7262_par.c b/src/lvgl_panel_st7262_par.c index a34adaa..81025d7 100644 --- a/src/lvgl_panel_st7262_par.c +++ b/src/lvgl_panel_st7262_par.c @@ -13,6 +13,7 @@ bool direct_io_frame_trans_done(esp_lcd_panel_handle_t panel, esp_lcd_rgb_panel_ void direct_io_lv_flush(lv_display_t *display, const lv_area_t *area, uint8_t *px_map) { + // Hardware rotation is not supported const esp_lcd_panel_handle_t panel_handle = display->user_data; lv_display_rotation_t rotation = lv_display_get_rotation(display); @@ -68,10 +69,6 @@ lv_display_t *lvgl_lcd_init() void *drawBuffer = heap_caps_malloc(drawBufferSize, LVGL_BUFFER_MALLOC_FLAGS); lv_display_set_buffers(display, drawBuffer, NULL, drawBufferSize, LV_DISPLAY_RENDER_MODE_PARTIAL); - // Hardware rotation is not supported - display->sw_rotate = 1; - display->rotation = LV_DISPLAY_ROTATION_0; - // Create direct_io panel handle const esp_lcd_rgb_panel_config_t rgb_panel_config = { .clk_src = ST7262_PANEL_CONFIG_CLK_SRC, diff --git a/src/lvgl_panel_st7701_par.c b/src/lvgl_panel_st7701_par.c index 95a2078..d2861c3 100644 --- a/src/lvgl_panel_st7701_par.c +++ b/src/lvgl_panel_st7701_par.c @@ -15,9 +15,49 @@ bool direct_io_frame_trans_done(esp_lcd_panel_handle_t panel, esp_lcd_rgb_panel_ void direct_io_lv_flush(lv_display_t *display, const lv_area_t *area, uint8_t *px_map) { + // Hardware rotation is not supported const esp_lcd_panel_handle_t panel_handle = display->user_data; - // LV_COLOR_16_SWAP is handled by mapping of the data - ESP_ERROR_CHECK(esp_lcd_panel_draw_bitmap(panel_handle, area->x1, area->y1, area->x2 + 1, area->y2 + 1, px_map)); + + lv_display_rotation_t rotation = lv_display_get_rotation(display); + if (rotation == LV_DISPLAY_ROTATION_0) + { + ESP_ERROR_CHECK(esp_lcd_panel_draw_bitmap(panel_handle, area->x1, area->y1, area->x2 + 1, area->y2 + 1, px_map)); + return; + } + + // Rotated + int32_t w = lv_area_get_width(area); + int32_t h = lv_area_get_height(area); + lv_color_format_t cf = lv_display_get_color_format(display); + uint32_t px_size = lv_color_format_get_size(cf); + size_t buf_size = w * h * px_size; + log_v("alloc rotation buffer to: %u bytes", buf_size); + void *rotation_buffer = heap_caps_malloc(buf_size, LVGL_BUFFER_MALLOC_FLAGS); + assert(rotation_buffer != NULL); + + uint32_t w_stride = lv_draw_buf_width_to_stride(w, cf); + uint32_t h_stride = lv_draw_buf_width_to_stride(h, cf); + + switch (rotation) + { + case LV_DISPLAY_ROTATION_90: + lv_draw_sw_rotate(px_map, rotation_buffer, w, h, w_stride, h_stride, rotation, cf); + ESP_ERROR_CHECK(esp_lcd_panel_draw_bitmap(panel_handle, area->y1, display->ver_res - area->x1 - w, area->y1 + h, display->ver_res - area->x1, rotation_buffer)); + break; + case LV_DISPLAY_ROTATION_180: + lv_draw_sw_rotate(px_map, rotation_buffer, w, h, w_stride, w_stride, rotation, cf); + ESP_ERROR_CHECK(esp_lcd_panel_draw_bitmap(panel_handle, display->hor_res - area->x1 - w, display->ver_res - area->y1 - h, display->hor_res - area->x1, display->ver_res - area->y1, rotation_buffer)); + break; + case LV_DISPLAY_ROTATION_270: + lv_draw_sw_rotate(px_map, rotation_buffer, w, h, w_stride, h_stride, rotation, cf); + ESP_ERROR_CHECK(esp_lcd_panel_draw_bitmap(panel_handle, display->hor_res - area->y2 - 1, area->x2 - w + 1, display->hor_res - area->y2 - 1 + h, area->x2 + 1, rotation_buffer)); + break; + default: + assert(false); + break; + } + + free(rotation_buffer); }; lv_display_t *lvgl_lcd_init() @@ -29,10 +69,6 @@ lv_display_t *lvgl_lcd_init() void *drawBuffer = heap_caps_malloc(drawBufferSize, LVGL_BUFFER_MALLOC_FLAGS); lv_display_set_buffers(display, drawBuffer, NULL, drawBufferSize, LV_DISPLAY_RENDER_MODE_PARTIAL); - // Hardware rotation is not supported - display->sw_rotate = 1; - display->rotation = LV_DISPLAY_ROTATION_0; - // Install 3-wire SPI panel IO esp_lcd_panel_io_3wire_spi_config_t io_3wire_spi_config = { .line_config = { diff --git a/src/lvgl_panel_st7789_i80.c b/src/lvgl_panel_st7789_i80.c index 5ef0558..19cbef5 100644 --- a/src/lvgl_panel_st7789_i80.c +++ b/src/lvgl_panel_st7789_i80.c @@ -14,6 +14,7 @@ bool st7789_color_trans_done(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_i void st7789_lv_flush(lv_display_t *drv, const lv_area_t *area, uint8_t *px_map) { + // Hardware rotation is supported const esp_lcd_panel_handle_t panel_handle = drv->user_data; uint32_t pixels = lv_area_get_size(area); uint16_t *p = (uint16_t *)px_map; @@ -35,10 +36,6 @@ lv_display_t *lvgl_lcd_init(uint32_t hor_res, uint32_t ver_res) void *drawBuffer = heap_caps_malloc(drawBufferSize, LVGL_BUFFER_MALLOC_FLAGS); lv_display_set_buffers(display, drawBuffer, NULL, drawBufferSize, LV_DISPLAY_RENDER_MODE_PARTIAL); - // Hardware rotation is supported - display->sw_rotate = 0; - display->rotation = LV_DISPLAY_ROTATION_0; - pinMode(ST7789_RD_GPIO, OUTPUT); digitalWrite(ST7789_RD_GPIO, HIGH); diff --git a/src/lvgl_panel_st7789_spi.c b/src/lvgl_panel_st7789_spi.c index cfdfa9a..24ab2cd 100644 --- a/src/lvgl_panel_st7789_spi.c +++ b/src/lvgl_panel_st7789_spi.c @@ -15,6 +15,7 @@ bool st7789_color_trans_done(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_i void st7789_lv_flush(lv_display_t *display, const lv_area_t *area, uint8_t *px_map) { + // Hardware rotation is supported esp_lcd_panel_handle_t panel_handle = display->user_data; uint32_t pixels = lv_area_get_size(area); uint16_t *p = (uint16_t *)px_map; @@ -36,10 +37,6 @@ lv_display_t *lvgl_lcd_init(uint32_t hor_res, uint32_t ver_res) void *drawBuffer = heap_caps_malloc(drawBufferSize, LVGL_BUFFER_MALLOC_FLAGS); lv_display_set_buffers(display, drawBuffer, NULL, drawBufferSize, LV_DISPLAY_RENDER_MODE_PARTIAL); - // Hardware rotation is supported - display->sw_rotate = 0; - display->rotation = LV_DISPLAY_ROTATION_0; - // Create SPI bus const spi_bus_config_t spi_bus_config = { .mosi_io_num = ST7789_SPI_BUS_MOSI_IO_NUM, diff --git a/src/lvgl_panel_st7796_spi.c b/src/lvgl_panel_st7796_spi.c index 08c9807..5e55a48 100644 --- a/src/lvgl_panel_st7796_spi.c +++ b/src/lvgl_panel_st7796_spi.c @@ -16,6 +16,7 @@ bool st7796_color_trans_done(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_i void st7796_lv_flush(lv_display_t *display, const lv_area_t *area, uint8_t *px_map) { + // Hardware rotation is supported esp_lcd_panel_handle_t panel_handle = display->user_data; uint32_t pixels = lv_area_get_size(area); uint16_t *p = (uint16_t *)px_map; @@ -37,10 +38,6 @@ lv_display_t *lvgl_lcd_init(uint32_t hor_res, uint32_t ver_res) void *drawBuffer = heap_caps_malloc(drawBufferSize, LVGL_BUFFER_MALLOC_FLAGS); lv_display_set_buffers(display, drawBuffer, NULL, drawBufferSize, LV_DISPLAY_RENDER_MODE_PARTIAL); - // Hardware rotation is supported - display->sw_rotate = 0; - display->rotation = LV_DISPLAY_ROTATION_0; - // Create SPI bus const spi_bus_config_t spi_bus_config = { .mosi_io_num = ST7796_SPI_BUS_MOSI_IO_NUM, From e8017c7d8d525c06e5e77c7e42a231498df53144 Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Fri, 8 Nov 2024 20:54:30 +0100 Subject: [PATCH 03/10] Boards updated --- README.md | 5 +++++ boards | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 47e8aeb..f51bcc9 100644 --- a/README.md +++ b/README.md @@ -595,6 +595,11 @@ The following libraries are used from the [Espressif component registry](https:/ ## Version history +- Noember 2024 + - LVGL 9.2.2 + - Software rotation flag + - Fix for non connected RST in touch drivers + - Fix for - October 2024 - Fix for LVGL 9.2.2 that removed the sw_rotate flag - August 2024 diff --git a/boards b/boards index 35fd2d6..c7615a5 160000 --- a/boards +++ b/boards @@ -1 +1 @@ -Subproject commit 35fd2d6067e1ce49e4460dff2be6c84c432042f6 +Subproject commit c7615a55e607154dd8772dd2e0f4ac9b973a1b74 From 60d3242a3e8984841d46a6d761d10d1c68ece75e Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Fri, 8 Nov 2024 20:54:49 +0100 Subject: [PATCH 04/10] Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f51bcc9..282ad0d 100644 --- a/README.md +++ b/README.md @@ -595,7 +595,7 @@ The following libraries are used from the [Espressif component registry](https:/ ## Version history -- Noember 2024 +- November 2024 - LVGL 9.2.2 - Software rotation flag - Fix for non connected RST in touch drivers From fdda5cb4ad1e8ac23d5896e7c9d1942d2ec5515e Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Fri, 8 Nov 2024 21:02:57 +0100 Subject: [PATCH 05/10] Updated markdown --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 282ad0d..182da85 100644 --- a/README.md +++ b/README.md @@ -599,7 +599,7 @@ The following libraries are used from the [Espressif component registry](https:/ - LVGL 9.2.2 - Software rotation flag - Fix for non connected RST in touch drivers - - Fix for + - Fix for esp32-3248S035C buffer size - October 2024 - Fix for LVGL 9.2.2 that removed the sw_rotate flag - August 2024 From 6860af2274133c0e7bba183e729fc8d8cefe7258 Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Sat, 9 Nov 2024 17:18:43 +0100 Subject: [PATCH 06/10] Updated martkdown --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 182da85..f2920c3 100644 --- a/README.md +++ b/README.md @@ -596,6 +596,7 @@ The following libraries are used from the [Espressif component registry](https:/ ## Version history - November 2024 + - Version 2.1.0 - LVGL 9.2.2 - Software rotation flag - Fix for non connected RST in touch drivers From b66ed7bda5db98d43fdfbe81e239db62fbfd0c07 Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Sat, 9 Nov 2024 17:20:17 +0100 Subject: [PATCH 07/10] Updated version to 2.1.0 --- library.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library.json b/library.json index d33e2d9..b7f777f 100644 --- a/library.json +++ b/library.json @@ -1,8 +1,8 @@ { "$schema": "https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/schema/library.json", "name": "esp32_smartdisplay", - "version": "3.0.0", - "description": "LVGL v9.2 driver for Sunton ESP32 Cheap Yellow Display display boards", + "version": "2.1.0", + "description": "LVGL v9.2.2 driver for Sunton ESP32 Cheap Yellow Display display boards", "keywords": "LVGL Sunton CYD LCD TFT Touch", "repository": { "type": "git", From 76f83e7038db9cacf8e0b5fee996ef04dcad6084 Mon Sep 17 00:00:00 2001 From: Rene Date: Sat, 9 Nov 2024 17:26:55 +0100 Subject: [PATCH 08/10] Create dependabot.yml --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5990d9c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" From 4fb0c69536cf310b1de05d735dd142ba2d1dbcbe Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Thu, 26 Dec 2024 20:41:12 +0100 Subject: [PATCH 09/10] Updated boards --- boards | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards b/boards index c7615a5..ff4ef01 160000 --- a/boards +++ b/boards @@ -1 +1 @@ -Subproject commit c7615a55e607154dd8772dd2e0f4ac9b973a1b74 +Subproject commit ff4ef01c23cdb6ffe1e0033c2c62fd76a8a1b0c0 From 319048d3e3a97b0a6873a77c68438842189eb9ca Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Thu, 26 Dec 2024 20:49:42 +0100 Subject: [PATCH 10/10] Updated md with feedback from https://github.com/smileymiley --- README.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f2920c3..2de0c3c 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ This will automatically download the library, the LVGL library (as a dependency) LVGL needs a configuration file; `lv_conf.h`. This file contains information about the fonts, color depths, default background, styles, etc... The default LVGL template can be found in the LVGL library at the location: `lvgl/lv_conf_template.h`. -This file must be copied to the include directory and renamed to `lvgl_conf.h`. Also the `#if 0` must be removed to enable the file to be included. +This file must be copied to the include directory and renamed to `lv_conf.h`. Also the `#if 0` must be removed to enable the file to be included. This file can immediately be used and is valid. Some modifications might be required fore additional features. @@ -203,20 +203,21 @@ More information about the LVGL configuration can be found in the excellent [LVG ### Step 6: Copy the build flags below in your project -Especially the definition of the LV_CONF_PATH is critical, this must point to an **absolute path** where the `lv_conf.h` file is located. More about this in the [section below](#more-on-lv_confh). +Especially the definition of the LV_CONF_PATH is critical, this must point to an **absolute path** where the `lv_conf.h` file is located. +More about this in the [section below](#more-on-lv_confh). See below how this can be done with the use of the platformIO defines: ```ini build_flags = -Ofast -Wall - #-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE - #-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG - #-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO - # LVGL settings. Point to your lv_conf.h file - -D LV_CONF_PATH="${PROJECT_DIR}/example/lv_conf.h" + '-D BOARD_NAME="${this.board}"' + '-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO' + #'-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG' + #'-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE' + '-D LV_CONF_PATH=${platformio.include_dir}/lv_conf.h' ``` -The line in the settings logs to the serial console but can be omitted for production builds: +The line in the settings logs the INFO level to the serial console but can be omitted for production builds: ```ini -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE @@ -229,6 +230,9 @@ The -Wall flag can also be removed but outputs all the warnings. To enable to display in your project call the void `smartdisplay_init()` function at startup and optionally set the orientation: ```cpp +#include +#include + void setup() { smartdisplay_init(); @@ -247,6 +251,7 @@ auto lv_last_tick = millis(); void loop() { + auto const now = millis(); // Update the ticker lv_tick_inc(now - lv_last_tick); lv_last_tick = now;