The screen I purchased is portrait orientation, but I need it to be displayed in landscape mode. I used guiguider to generate the basic display code for the RT1052.
And add software rotation
#if FB_USE_SRAM
static void DEMO_WaitVsync(lv_disp_drv_t *disp_drv)
{
s_framePending = true;
#if defined(SDK_OS_FREE_RTOS)
if (xSemaphoreTake(s_frameSema, portMAX_DELAY) != pdTRUE)
{
PRINTF("Display flush failed\r\n");
assert(0);
}
#else
while (s_framePending)
{
}
#endif
}
static void copy_area(const lv_area_t *area, lv_color_t *color_p, uint8_t *fb, uint32_t fbStrideBytes)
{
uint32_t y;
uint32_t areaWidth = lv_area_get_width(area);
fb += (area->y1 * fbStrideBytes + area->x1 * sizeof(lv_color_t));
for (y = area->y1; y <= area->y2; y++)
{
lv_memcpy(fb, color_p, areaWidth * sizeof(lv_color_t));
fb += fbStrideBytes;
color_p += areaWidth;
}
}
static void DEMO_FlushDisplay(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
{
/* Wait VSYNC for each small update. /
DEMO_WaitVsync(disp_drv);
/* Copy data from draw buffer to frame buffer./
copy_area(area, color_p, (uint8_t*) s_frameBuffer, LCD_WIDTH * LCD_FB_BYTE_PER_PIXEL);
SCB_CleanInvalidateDCache();
lv_disp_flush_ready(disp_drv);
}
#else
static void DEMO_FlushDisplay(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
{
// DCACHE_CleanByRange((uint32_t)color_p, DEMO_FB_SIZE);
DCACHE_CleanInvalidateByRange((uint32_t)color_p, DEMO_FB_SIZE);
ELCDIF_SetNextBufferAddr(LCDIF, (uint32_t)color_p);
s_framePending = true;
#if defined(SDK_OS_FREE_RTOS)
if (xSemaphoreTake(s_frameSema, portMAX_DELAY) == pdTRUE)
{
/* IMPORTANT!!!
* Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);
}
else
{
PRINTF("Display flush failed\r\n");
assert(0);
}
#else
while (s_framePending)
{
}
/* IMPORTANT!!!
* Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);
#endif
}
#endif
Hi @dsd ,
Thank you for your question!
First, please check the following LVGL limitations: Screen rotation is not supported when full_refresh=1 is enabled. Please refer to:
Helllo,
When using NXP i.MX RT1052 with Guiguider (LVGL) for screen rotation development, the "slow single-buffer refresh and black screen with double-buffer" problem you encounter is mainly due to the mismatch between software rotation and the hardware ELCDIF controller, double-buffer switching mechanism, and memory address index.
Best Regards