How to delay the display of a text on a screen within a label

Hi all,
I am new with LVGL. I could properly set it up and make it run with my project (M5Stack Core2) but I now have a more conceptual question.
I have built an Init Screen in which I would like to display label with some connection/init information like “connecting to wifi…please wait”, “connected to wifi!!” etc…
I have created a label for this but when I run the code all outputs are flushed at the same time…
I would like to see the screen refreshing live info like “connecting to wifi…please wait” then a few seconds later “connected”…but here it is all displayed at the same time (using only one label displays the last string output). If I use 2 labels with a delay between them (using delay()) they are both displayed at the same time

Thanks a lot for your help!

setup info

M5Stack Core 2 / VSCode / PIO / Arduino framework
LVGL 8.1 (latest available on PIO)

I think you can use timers

@glory-man thanks a lot, I will check and give it a try.
I am totally new to the concept of this LVGL lib but after a few days I already see the huge potential.
However the learning curve is not easy for me as an average hobbyist

i understand using the M5 Core embedded graphic lib is way easier but at the same time much more limited.
Also I understand using delay() to delay the display of text is very bad practice and in any case it does not work with LVGL

Again thanks for the tip I’ll check this and give you some feedback!

I think you can use only one label, just change displayed text. At the begining setup “connecting to wifi…please wait” and create timer. After time-delay will be ended in timer-callback change text of the label to “connected” and delete timer.

you can call: lv_refr_now(NULL); where you want refresh screen …in my example i use this label named LabelToast first to go in connection routine:

lv_label_set_text(LabelToast, “Connecting to Wifi.”); lv_obj_align(LabelToast, Screen1, LV_ALIGN_IN_TOP_MID, 0, 10); lv_obj_move_foreground(LabelToast);
lv_refr_now(NULL);
delay(100);
wifiConn();// <<<< connection routine

my complete example is here:

hi all,

First off, I wish you all Happy New Year!

@gabriele_ponte thanks a million! the lv_refr_now is exactly what I was looking for!
I tested it and it now does exactly what I want

The only think I need to investigate:
I want to keep the previous text on the screen, like:
“Connecting to my wifi network” and then once it is connected, I want to keep this text and write just below “Connected”.
I can achieve this by using 2 different labels but I would like to kind of append the second text within the same label.

Do you know if there’s such a function in LVLG? I mean using lv_label_set_text to set text within a given label and then append some text to the same label so that you don’t ‘lose’ the first text.

Thanks again!

Just answering to myself.
I tried some code and ended up with this (sample):

String strcon = "Connecting to " MY_SSID;
strcon = strcon + “…”;
lv_label_set_text(pageLabel1, strcon.c_str());
lv_refr_now(NULL);

My wifi start function
strcon = strcon + “\nConnected!”;
lv_label_set_text(pageLabel1, strcon.c_str());

This code is working however I am far from being a C expert so maybe there’s something better.
In any case I could achieve what I wanted!

Not need 2 labels, just insert new text with command:
lv_label_ins_text(LabelName, LV_LABEL_POS_LAST, “\nCreate NEW file”);

and you can realign text label with new size with commands:
lv_obj_align(LabelToast, Screen1, LV_ALIGN_IN_TOP_MID, 0, 10); lv_obj_move_foreground(LabelToast);

Bye

Thank you very much!