90 Degree HW Rotation of the Screen with LVGL v9

Description

I use NXP Imx RT1170 EVK board and NXP’s own ide, MCU Xpresso. I use lvgl v9 and I need 90 degree screen rotation by HW.

What MCU/Processor/Board and compiler are you using?

IMXRT1176EVK MCUXPRESSO, arm-none-eabi-gcc command is used.

What LVGL version are you using?

v9.0.0

What do you want to achieve?

Rotating 90 degree the screen.

What have you tried so far?

I have tried adding filling buffers, no success there.

Code to reproduce

//normally width is 720, h is 1280

#define LVGL_BUFFER_WIDTH  1280
#define LVGL_BUFFER_HEIGHT 720
	lv_display_t * disp = lv_display_create(DEMO_BUFFER_WIDTH, DEMO_BUFFER_HEIGHT);

    memset(s_frameBuffer, 0, sizeof(s_frameBuffer));

    lv_display_set_flush_cb(disp, (void *)DEMO_FlushDisplay);

// Normally I use dual buffer. But here I use single buffer according to some sdk examples. I may change here if needed.

lv_display_set_buffers(disp, s_lvglBuffer[0], NULL, DEMO_BUFFER_WIDTH*DEMO_BUFFER_HEIGHT*DEMO_BUFFER_BYTE_PER_PIXEL, LV_DISPLAY_RENDER_MODE_FULL);

//lv_display_set_buffers(disp, s_frameBuffer[0], s_frameBuffer[1], DEMO_BUFFER_WIDTH*DEMO_BUFFER_HEIGHT*DEMO_BUFFER_BYTE_PER_PIXEL, LV_DISPLAY_RENDER_MODE_DIRECT);
    s_inactiveFrameBuffer = (void *)s_frameBuffer[0];

    /* lvgl starts render in frame buffer 0, so show frame buffer 1 first. */
    g_dc.ops->setFrameBuffer(&g_dc, 0, (void *)s_frameBuffer[1]);

    /* Wait for frame buffer sent to display controller video memory. */
    if ((g_dc.ops->getProperty(&g_dc) & kDC_FB_ReserveFrameBuffer) == 0)
    {
        DEMO_WaitBufferSwitchOff();
    }

    g_dc.ops->enableLayer(&g_dc, 0);
lv_display_flush_cb_t DEMO_FlushDisplay(lv_display_t * disp, const lv_area_t * area, uint8_t * px_map)
{
    static bool firstFlush = true;

    if (firstFlush)
    {	firstFlush = false;}
    else
    {   DEMO_WaitBufferSwitchOff();}

    DEMO_FLUSH_DCACHE();

    void *inactiveFrameBuffer = s_inactiveFrameBuffer;

    for (uint32_t y = 0; y < LVGL_BUFFER_HEIGHT; y++)
    {
       for (uint32_t x = 0; x < LVGL_BUFFER_WIDTH; x++)
        {
            ((uint8_t *)inactiveFrameBuffer)[(DEMO_BUFFER_HEIGHT - x) * DEMO_BUFFER_WIDTH + y] =
            		px_map[y * LVGL_BUFFER_WIDTH + x];
       }
    }

    g_dc.ops->setFrameBuffer(&g_dc, 0, inactiveFrameBuffer);

    lv_disp_flush_ready(disp);
}