Changing a centered text label value?

I am running into a problem where some pixels are not getting rendered as expected.

My use case is, I have a text label that I change values on based on user input. The text label is centered inside another object.

To set the text label to “value” (for example), I use:
lv_label_set_text(label_obj, “value”);
lv_obj_align(label_obj, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -10);

To clear out the text label, I use a space character:
lv_label_set_text(label_obj, " ");
lv_obj_align(label_obj, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -10);

This seems to work OK, but I see a few pixels hanging around in the VDB from the previous value, so I get a few incorrect pixels showing up on the display when the values change.

What is the best way to set a new text label value and keep it centered, based on the new value?

It’s very strange because the changing the text of label is very well tested and used a lot.

  • Can you send a photo about the issue?
  • Can you reproduce it in the Simulator?

I tried it in the PC simulator with the same code, and it doesn’t happen.

On my MCU I am using DMA, so maybe it is an issue with memory updates/caching?

Is there a good breakpoint in the lvgl VDB routines to see exactly what is written to the VDB for each pixel and memory location? When I break during the flush, I can see in memory that the bad pixels are present before being sent out. It looks like the bad pixels are the last word that was used for the previous update in memory.

Here is a video and VDB memory captures.

Setting the text label to “5”:

When blanking out the text label:

Video of the update/error:
lvgl_vdb_err.mp4.zip (2.7 MB)

In 99% of cases that means the problem is with your board/driver, not the code.

@jking I agree with @embeddedt, probably it’s a driver issue. Do you call lv_flush_ready() when the DMA is ready?

Do you use the builtin fonts?

For the simulator I use the built in fonts, but for my MCU I use a custom font.
I do call lv_flush_ready() when the DMA transfer completes.

Can you try the simulator with the custom font?

OK, I tried with a custom font in the simulator, but don’t see the issue then either. I took some debug from the MCU when updating the label, both with and without alignment, and I see why it isn’t updating correctly, but not sure how to fix it.

Here are the two updates without alignment. This is captured inside the display_flush, notice the total pixels being updated (tot_pix) are equal for both “5” and " ".


Now here are the same updates when alignment is performed to recenter the label. The number of pixels updated are no longer equal for “5” and " ":


It’s fine because when it draw “5” the area of “5” needs to drawn. When " " is drawn the area of “5” also needs to be drawn with only the background.

That’s very interesting. Is it true for the simulator too? If so, can you share the code as you change the text and the custom font?