#include "custom_lcd_display.h" #include "lcd_display.h" #include #include #include #include #include "assets/lang_config.h" #include #include "settings.h" #include "esp_lcd_panel_io.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" #include "config.h" #include "board.h" #define TAG "CustomLcdDisplay" static SemaphoreHandle_t trans_done_sem = NULL; static uint16_t *trans_buf_1; #if (DISPLAY_ROTATION_90 == true) static uint16_t *dest_map; #endif bool CustomLcdDisplay::lvgl_port_flush_io_ready_callback(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx) { BaseType_t taskAwake = pdFALSE; lv_display_t *disp_drv = (lv_display_t *)user_ctx; assert(disp_drv != NULL); if (trans_done_sem) { xSemaphoreGiveFromISR(trans_done_sem, &taskAwake); } return false; } void CustomLcdDisplay::lvgl_port_flush_callback(lv_display_t *drv, const lv_area_t *area, uint8_t *color_map) { assert(drv != NULL); esp_lcd_panel_handle_t panel_handle = (esp_lcd_panel_handle_t)lv_display_get_user_data(drv); assert(panel_handle != NULL); lv_draw_sw_rgb565_swap(color_map, lv_area_get_width(area) * lv_area_get_height(area)); #if (DISPLAY_ROTATION_90 == true) lv_display_rotation_t rotation = lv_display_get_rotation(drv); lv_area_t rotated_area; if(rotation != LV_DISPLAY_ROTATION_0) { lv_color_format_t cf = lv_display_get_color_format(drv); /*Calculate the position of the rotated area*/ rotated_area = *area; lv_display_rotate_area(drv, &rotated_area); /*Calculate the source stride (bytes in a line) from the width of the area*/ uint32_t src_stride = lv_draw_buf_width_to_stride(lv_area_get_width(area), cf); /*Calculate the stride of the destination (rotated) area too*/ uint32_t dest_stride = lv_draw_buf_width_to_stride(lv_area_get_width(&rotated_area), cf); /*Have a buffer to store the rotated area and perform the rotation*/ int32_t src_w = lv_area_get_width(area); int32_t src_h = lv_area_get_height(area); lv_draw_sw_rotate(color_map, dest_map, src_w, src_h, src_stride, dest_stride, rotation, cf); /*Use the rotated area and rotated buffer from now on*/ area = &rotated_area; } #endif const int flush_coun = (LVGL_SPIRAM_BUFF_LEN / LVGL_DMA_BUFF_LEN); const int offgap = (DISPLAY_HEIGHT / flush_coun); const int dmalen = (LVGL_DMA_BUFF_LEN / 2); int offsetx1 = 0; int offsety1 = 0; int offsetx2 = DISPLAY_WIDTH; int offsety2 = offgap; #if (DISPLAY_ROTATION_90 == true) uint16_t *map = (uint16_t*)dest_map; #else uint16_t *map = (uint16_t*)color_map; #endif xSemaphoreGive(trans_done_sem); for(int i = 0; i