Update helpers and drivers to handle LVGLv7 and v8 versions (#161)

* [lvgl_helpers] Cleanup and misc code cleanup

Checks for SPI_HOST_MAX symbol before using it.

Rename lvgl_driver_init to lvgl_interface_init because it now only initialize
the interface bus for display drivers, we still need to remove the indev
drivers from here.

Use types defined in spi_types.h for spi host (spi_host_device_t) and
spi dma channels (spi_dma_chan_t).

Also add a couple of symbols to avoid using magic numbers

* [lvgl_helpers] Reduce usage of if defined in lvgl_interface_init

* [lvgl_helpers] Fix spi dma channel for ESP-IDF versions <= 4.2

* [examples] Update hello_world to call lvgl_interface_init

* Add lvgl_get_display_buffer_size helper

This helper will allow us to get the calculated display buffer size instead of using a global symbol.

* Implement lvgl_get_display_buffer_size

This API will be used to get the calculation of display buffer size.

* Delete DISP_BUF_SIZE symbols

The same functionality is handled by lvgl_get_display_buffer_size

* Move SPI max transfer size calculation to helper

Use calculate_spi_max_transfer_size to calculate the SPI max transfer size for the SPI master configuration

* Remove SPI_BUS_MAX_TRANSFER_SZ definition

Same functionality is now handled in calculate_spi_max_transfer_size

* Update display buffer size calculation

Use lvgl_get_display_buffer_size helper instead of DISP_BUF_SIZE symbol

* Update example to LVGL v8

Add comments about changes from:
- LVGL v7 to LVGL v8
- Configuration helpers and display drivers

* Update lvgl_helpers.c

* Update sh1107 driver

* Update EVE driver

Check for symbols used in previous implementations before trying to use them
and add a fallback temporary implementation when not found.

The falback implementation isn't tested with hardware.

Symbols:
- DISP_BUF_SIZE
- SPI_TRANSFER_SIZE

* Update uc8151d driver

* Update jd79653a driver

* Update ra8875 driver

* Update il3820.h

Check for LV_HOR_RES_MAX and LV_VER_RES_MAX before trying to use them

* Update lvgl_helpers.c

Check for ESP-IDF version before trying to use spi_dma_chan_t type
This commit is contained in:
Carlos Diaz 2022-01-07 17:22:11 -06:00 committed by GitHub
parent bb0e3a1f27
commit 17eb416ef8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 309 additions and 148 deletions

View file

@ -26,8 +26,19 @@
#define BYTES_PER_PIXEL (LV_COLOR_DEPTH / 8)
#if defined (LV_HOR_RES_MAX)
#define HDWR_VAL (LV_HOR_RES_MAX/8 - 1)
#else
/* ToDo Remove magic number 256u */
#define HDWR_VAL (256u/8u - 1u)
#endif
#if defined (LV_VER_RES_MAX)
#define VDHR_VAL (LV_VER_RES_MAX - 1)
#else
/* ToDo Remove magic number 128u */
#define VDHR_VAL (128u - 1u)
#endif
#define VDIR_MASK (1 << 2)
#define HDIR_MASK (1 << 3)
@ -234,7 +245,16 @@ void ra8875_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
// Set window if needed
if ((x1 != area->x1) || (x2 != area->x2)) {
LV_LOG_INFO("flush: set window (x1,x2): %d,%d -> %d,%d", x1, x2, area->x1, area->x2);
ra8875_set_window(area->x1, area->x2, 0, LV_VER_RES_MAX-1);
unsigned int ye = 0;
#if LVGL_VERSION_MAJOR < 8
ye = LV_VER_RES_MAX - 1;
#else
/* ToDo Get y end from driver information */
#endif
ra8875_set_window(area->x1, area->x2, 0, ye);
x1 = area->x1;
x2 = area->x2;
}
@ -248,7 +268,16 @@ void ra8875_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
// Update to future cursor location
y = area->y2 + 1;
if (y >= LV_VER_RES_MAX) {
lv_coord_t ver_max = 0;
#if LVGL_VERSION_MAJOR < 8
ver_max = LV_VER_RES_MAX;
#else
/* ToDo Get vertical max from driver information */
ver_max = lv_disp_get_ver_res((lv_disp_t *) drv);
#endif
if (y >= ver_max) {
y = 0;
}