How to optimize image rotation to get 30fps and above


we are gonna make a same GUI demo in several platforms to see which one is suitable for us , and one of them is LVGL of course ;
and the issue is after i completed the LVGL version , u can see some frame drops half of the times and fps actually drops down to 24 sometimes and cpu usage goes up to 100% as well which is not ideal.
we designed this demo with exact same rotations and animations in TouchGFX and we have got around 40% cpu usage at most and fixed 33fps all the time ;
so what can i do to optimize it ? is there any solution at all ?
would be appreciated if anybody helps;
thanks in advance.

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

i’m using STM32F746 Discovery board with this project :

What LVGL version are you using?


What do you want to achieve?

stable 33fps at least

What have you tried so far?

i used 16 bits RGB colors for my images instead of 24 bit ( i’m using True Color images with alpha ),
i tried Timer interrupt instead of HAL_Delay for lv-task_handler()
enabled IAR optimization , Level is High and mode is Speed , that helps a lot but still isn’t enough.

Code to reproduce

lemme know if needed

Screenshot and/or video

these images rotating at the same time : ( 2x of middle image + another 2 images ) , so 4 animations in total , black images rotate to cover the blue background while gauge is rotating.
Temp_Gauge_ColorGauge_Light Fuel_Gauge_Color
and the demo is like this :
Screenshot (2)
i can upload a gif a bit later maybe , to show u how it works.

Have you enabled DMA2D support?

im actually new to LVGL and i used this project as i mentioned above ,
and if u mean this define : LV_USE_GPU_STM32_DMA2D in lv_conf.h file , yes thats 1 and enabled , but i didn’t do anything about DMA2D myself.

and another thing is looks like DMA2D doesn’t work with 16 bit color depth( True color Alpha mode ) , and when i checked my stm32f746 datasheet , i realized that DMA2D does not support such format ( 16 bit RGB + 8 bit alpha ) , so the only format that i can use is 24 bit RGB + 8 bit alpha ( LV_COLOR_DEPTH = 32 in LVGL library )
anyway with 32 bit colors and DMA2D on it is still not ideal and we have frame drops

LVGL uses 16-bit RGB and no alpha (RGB565), not 16-bit RGB + 8 alpha. Alpha is only used internally for rendering. DMA2D supports RGB565.

alright ,
anyway what should i do next ? any idea ?
problem still exist btw

Where is your LVGL display buffer located (disp_buf)? Is it in SRAM or SDRAM?

SDRAM of course , its not possible to allocate 2 display buffer in 240KB SRAM i think

There seems to be a little confusion:

If you have a (dump) display which is directly connected to STM32Fxx LCD hardware,
you use a frame buffer which is of course located in SDRAM (because of the size needed).
LVGL’s working buffer (I think this is what embeddedt is talking about) is (has to be!?) located within the internal SRAM because the internal SRAM has the better performance.
The working buffer hasn’t to be the size of a full frame buffer size. Of course, because the internal RAM is normally not large enough.
In this case you only need a single buffer. That is what you setup with the call of lv_disp_buf_init (…).
According what is available you can set this buffer smaller or larger (e.g. lv_color_t working_buffer[LV_HOR_RES_MAX * 40];).

Correct. It can be placed in either RAM type but SRAM working buffers usually give better performance.

you’re right ,my project has 2 working buffers like this :

static lv_color_t buf1_1[LV_HOR_RES_MAX * 68];
static lv_color_t buf1_2[LV_HOR_RES_MAX * 68];

and these 2 were located in SRAM from the beginning actually.

and my frame buffer that is located in SDRAM should be this one :

static __IO uintpixel_t * my_fb = (__IO uintpixel_t*) (SDRAM_DEVICE_ADDR); 

anyways , as i said my working buffers were located in SRAM from beginning , so the issue still exist , are there any more steps to optimize it ? thx for your tips up to now btw