Display a float/int number in runtime

I’d like to print out the number (int/float) and per this thread’s code can be done as https://forum.lvgl.io/t/how-to-display-a-float-int/3098

example:

float  bla = 255.55;
lv_obj_t * label1 = lv_label_create(lv_scr_act(), NULL);
lv_label_set_long_mode(label1, LV_LABEL_LONG_BREAK);     /*Break the long lines*/
lv_label_set_recolor(label1, true);                      /*Enable re-coloring by commands in the text*/
lv_label_set_text_fmt(percentage_power,"%f",bla );
lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, 0);

And recommended in lv_conf.h setting #define LV_SPRINTF_CUSTOM to 1 and changing LV_SPRINTF_DISABLE_FLOAT in your lv_conf.h file.

How to display a number which value is changed in runtime and update it regularly?

Thank you!

Use the code above to create the label once.

Then call lv_label_set_text_fmt periodically to update the value.
Make sure your object is declared on a global scope and not local