Description
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?
8.3.8
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. 
Kind Regards,
Pete
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:
lv_refr_now(NULL);
after the creation of each object to see if it changes anything…
Kind Regards,
Pete
Sorry for the late answer; where can caching of the drawbuffers be enabled? In lv_conf.h I set the lvgl-memory at an address in the external RAM with LV_MEM_SIZE 512KB, my drawbuffers are also in the external RAM. The display resolution is 1440x900. I’m not exactly sure what happens in this memory region (maybe caching?) and how to choose the correct size.
In the flush-callback I’m waiting for the last flush (lv_disp_flush_is_last) and draw the object to the physical display. lv_disp_flush_ready gets called every time the flush-callback is called, I’m not sure if this is good practice or if it should be called only if lv_disp_flush_is_last is true? Thank you!
Hi @Aardvark ,
When I mentioned caching I didn’t mean with regard to LVGL, I was referring to platform specific caching, you will need to check if it is enabled for the region of memory your draw buffers are declared in. If your draw buffers are in cacheable memory you need to flush the cache before the DMA collects the data (I am assuming the STM32 is using DMA). If the cache is not flushed bits of screen go missing and don’t display correctly because the physical memory hasn’t been updated.
Another thing you can try is to call:
lv_obj_update_layout( your_btn );
after you create the button, set the text and position the object on the screen.
Your really want to try and avoid adding delays as this will totally destroy the performance of the system.
The display resolution is quite high is your CPU managing to cope well with the load? Is it worth perhaps enabling the FPS and CPU monitoring if you haven’t already to see how well it is coping?
You can enable it in lv_conf.h like this:
/*1: Show CPU usage and FPS count*/
#define LV_USE_PERF_MONITOR 1
#if LV_USE_PERF_MONITOR
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
#endif
Kind Regards,
Pete