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:
parent
bb0e3a1f27
commit
17eb416ef8
14 changed files with 309 additions and 148 deletions
|
@ -50,20 +50,29 @@ static void guiTask(void *pvParameter)
|
|||
{
|
||||
(void) pvParameter;
|
||||
lv_init();
|
||||
lvgl_driver_init();
|
||||
|
||||
/* Initialize the needed peripherals */
|
||||
lvgl_interface_init();
|
||||
/* Initialize needed GPIOs, e.g. backlight, reset GPIOs */
|
||||
display_bsp_init_io();
|
||||
/* ToDo Initialize used display driver passing registered lv_disp_drv_t as parameter */
|
||||
|
||||
lv_color_t* buf1 = heap_caps_malloc(DISP_BUF_SIZE * sizeof(lv_color_t), MALLOC_CAP_DMA);
|
||||
size_t display_buffer_size = lvgl_get_display_buffer_size();
|
||||
lv_color_t* buf1 = heap_caps_malloc(display_buffer_size * sizeof(lv_color_t), MALLOC_CAP_DMA);
|
||||
assert(buf1 != NULL);
|
||||
|
||||
static lv_disp_draw_buf_t disp_buf;
|
||||
lv_disp_draw_buf_init(&disp_buf, buf1, NULL, DISP_BUF_SIZE * 8);
|
||||
lv_disp_draw_buf_init(&disp_buf, buf1, NULL, display_buffer_size * 8);
|
||||
|
||||
lv_disp_drv_t disp_drv;
|
||||
lv_disp_drv_init(&disp_drv);
|
||||
disp_drv.flush_cb = disp_driver_flush;
|
||||
disp_drv.rounder_cb = disp_driver_rounder;
|
||||
disp_drv.set_px_cb = disp_driver_set_px;
|
||||
disp_drv.draw_buffer = &disp_buf;
|
||||
disp_drv.draw_buf = &disp_buf;
|
||||
/* LVGL v8: Set display horizontal and vertical resolution (in pixels), it's no longer done with lv_conf.h */
|
||||
disp_drv.hor_res = 128u;
|
||||
disp_drv.ver_res = 64u;
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
|
||||
/* Create and start a periodic timer interrupt to call lv_tick_inc */
|
||||
|
@ -77,6 +86,8 @@ static void guiTask(void *pvParameter)
|
|||
|
||||
/* Create a Hellow World label on the currently active screen */
|
||||
lv_obj_t *scr = lv_disp_get_scr_act(NULL);
|
||||
|
||||
/* LVGL v8 lv_label_create no longer takes 2 parameters */
|
||||
lv_obj_t *label1 = lv_label_create(scr);
|
||||
lv_label_set_text(label1, "Hello\nworld");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue