How to rotate a screen in the app ?

Hi all:
In my application, Sometimes i need to rotate the screen 90 degrees, or rotate the font 90 degrees, Is there such a function to do that,how can i do ?
I use lvgl v5.3.
Thanks.

It is something that many are interested in but nobody gives help. Also how to rotate the screen before compiling

Both @kisvegabor and I are working on this mainly during our free time. While we try to respond to issues in a prompt fashion, we can’t guarantee you an immediate answer.

Please be patient; @kisvegabor should be able to help you soon.

Forgive me, I didn’t want to be rude, or impatient. It’s just that I’ve always received answers that are not exhaustive or unclear, I don’t speak English well and maybe I didn’t understand. Thanks and good work, we wait patiently for your updates.

1 Like

LittlevGL can not rotate the screen. In other words, it can draw only in lines from top to bottom (not in columns left to right).

To rotate the screen you need to modify the “fill direction” of the display (or similar term depending on the display controller or periphery you use).

You need to adjust LV_HOR_RES and LV_VER_RES according to the rotated resolution.

In v6.0 you can change the resolution in run time (or set disp_driver->rotated = 1 to swap hor. and ver. resolution), but the driver still needs to be reconfigures to change the “fill direction”.

Thanks a lot for the answer.
How can I change the file direction?
It would be enough for me to be able to rotate a label or a 90 ° button. I saw your example on a stm32 that has the screen vertically but I couldn’t figure out how you did it.
Thanks you are very kind and congratulations for your great work.

Exactly as you showed in this example:

example

Note that it’s FILL direction (or scan direction). It depends on the display controller or periphery you use.
E.g. in SSD1963 (or similar) display controller it’s just a different value in a configuration register.

For example I have an esp32 and an ili9341. How should I proceed?

Take a look at the 8.2.29. section of the datasheet.

thanks i try it.

Thansk for your answer.
I’m sorry,my English is poor.
The version I used was v6.0.I want to rotate the screen,so I tried the following:
in monitor.c ,i write a function called void Rotate90_(lv_color_t *src)
the code as

void Rotate90_(lv_color_t *src) 
{
	lv_color_t *des = NULL;
	int width = 480;//LV_HOR_RES_MAX;
	int height = 320;//LV_VER_RES_MAX;
	int wh = width * height;
	int k = 0;
	des = (lv_color_t  *)malloc(sizeof(lv_color_t)*width*height);
	printf("ox%x\n", sizeof(lv_color_t)*width*height);
	for (int j = width - 1; j >= 0; j--)
	{
		for (int i = 0; i < height; i++)
		{
			des[k] = src[i*width + j];
			k++;
		}
	}
	memcpy(src, des, sizeof(lv_color_t)*width*height);
	free(des);
	return ;
}

this is just a tools for demo to rotate the date for 90
but in fact, the screen shows only part of it . I think the reason for this is screen can auto to change its size.But i want to know how to reconfigures to change the “fill direction”.
Looking forward to your reply!

Take a look at this comment.

1 Like

Thanks for your reply,it could solve my question what i need to face.
But there are some small changes in practical application.

1 Like