How to protect drawing objects from being interrupted?


What’s in your opinion the best way to make sure the drawing of an object is not interrupted by the drawing of another object? I introduced a flag that locks drawing of object B during the drawing-process of object A. But how can I make sure the drawing-attempt of object B isn’t lost? My idea was a timer to delay object B in this case but the function call of object B contains other data like label-texts, position etc. So I’d need to save all these parameters and recall the drawing-function when the timer elapses. That’s a lot of overhead, especially if there are more objects involved. Is there a better way? In the LVGL-documentation there’s the description of a built-in task-system, but I couldn’t find it anywhere in the library. Is it deprecated?

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

STM32F439 with STM32CubeIDE

What LVGL version are you using?


Hi @Aardvark ,

I think you will need to try and describe what you are trying to achieve as it is hard to understand.

LVGL takes care of drawing all objects simultaneously. You can hide/show and create them at runtime.

I would suggest sharing a little information about your application and what you want it to do also which platform you are using, whether you have an OS or not etc…

If there is more information we can help you with the structure of your application to achieve your goals.

With regard to the “built-in task-system” this has been refactored as a timer handler see the newer documentation here. The refactor removed the prioritisation, which really wasn’t particularly useful, I personally use the timers frequently in LVGL and they work very well.

I hope that helps. :slight_smile:

Kind Regards,


Hello pete-pjb, thanks for your reply; I’m using an STM32 with FreeRtos, the lv_timer_handler is called periodically every 10 ms inside a task, the lv_tick inside the Systick-handler every ms. I’m doing nothing fancy, just showing and removing objects and labels based on external events. However if I call one function to draw button A, followed by another function to draw button B often either button A is not fully drawn (e.g. the label is missing) or button B is not drawn at all. If I add a delay between them it works without problems but that’s not an ideal solution

Hi @Aardvark ,

This sounds like there is something broken somewhere! Do you have caching enabled on the draw buffers? If so are the appropriate cache flushing operations being performed?

You could also try adding a call to:


after the creation of each object to see if it changes anything…

Kind Regards,