Widgets Rotation

Important: unclear posts may not receive useful answers.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the FAQ and read the relevant part of the documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.


How to rotate Widgets in RGB565 16 bit Color format. based on lv_conf.h header it needs 32 bit color format but my lcd doesn’t support 32 bit Color format (it supports RGB888 but not ARGB8888)

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

Stm32f769igt6 (similar to Stm32f769-Discovery Board)

What LVGL version are you using?


What do you want to achieve?

is it possible to rotate objects with 16 bit color format and how?

What have you tried so far?

with 32 bit config on lv_conf.h but using 24 bit on LCD, it didnt work in proper way

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

RGB888 is not currently supported, it is something that is going to be added in a future release. RGB565 is what you would use.

I am not sure what you mean by rotating the widgets is only supported by 32 bit color. you are going to have to elaborate on that more.

based on lv_con.h header it requires LV_COLOR_DEPTH = 32, which means the only option is ARGB888 color format.
actually, I want to rotate all the screens by 90 degrees (change portrait to landscape orientation).

That’s done at the driver level and not in LVGL itself. you have to instruct the display you are using as to the screen orientation.

my display is based on ILI9806e which doesn’t support orientation changes. for that, I want to change the orientation in the code.

how to change this code so it can handle orientation by lvgl itself (it’s part of the stm32f769discovery board lvgl template code)


static void tft_flush_cb(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_p)
// lv_disp_flush_ready(drv);
// return;
// SCB_CleanInvalidateDCache();

/*Truncate the area to the screen*/
int32_t act_x1 = area->x1 < 0 ? 0 : area->x1;
int32_t act_y1 = area->y1 < 0 ? 0 : area->y1;
int32_t act_x2 = area->x2 > TFT_HOR_RES - 1 ? TFT_HOR_RES - 1 : area->x2;
int32_t act_y2 = area->y2 > TFT_VER_RES - 1 ? TFT_VER_RES - 1 : area->y2;

x1_flush = act_x1;
y1_flush = act_y1;
x2_flush = act_x2;
y2_flush = act_y2;
y_flush_act = act_y1;
buf_to_flush = color_p;

/*Use DMA instead of DMA2D to leave it free for GPU*/
HAL_StatusTypeDef err;
err = HAL_DMA_Start_IT(&DmaHandle,(uint32_t)buf_to_flush, (uint32_t)&my_fb[y_flush_act * TFT_HOR_RES + x1_flush],
		  (x2_flush - x1_flush + 1));
if(err != HAL_OK)
	while(1);	/*Halt on error*/



This is the function you need

void lv_disp_set_rotation(lv_disp_t * disp, lv_disp_rot_t rotation);

set rotation to one the following


The LV_COLOR_SCREEN_TRANSP macro means that the displa supports having an alpha byte sent to it. That’s pretty much all it means. Screens that support this feature support 24 bit color plus the additional 8 bits for the alpha. It’s how the display functions. If that macro is set to a zero the other option you have is to use RGB565 or 16 bit color. This is because LVGL is not set up to handle 24 bit color. if your display does support RGB888 you could run 32 bit color and strip off the alpha byte in your flush function.

lv_disp_t * dispp = lv_disp_get_default();
lv_disp_set_rotation(dispp, LV_DISP_ROT_90);
lv_theme_t * theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED),
                                           false, LV_FONT_DEFAULT);
lv_disp_set_theme(dispp, theme);

Many Thanks!
it works after adding
disp_drv.sw_rotate = 1;

There ya go.

Glad to have helped and it didn’t require any funky code in your flush callback to get it done.