How to update text on a page periodically

Description

Hi, I have a stream of text coming from the serial port and I would like to display the text on a page. I know how to display static text to a page from studying the examples on the official document, but I am having trouble finding a way to update the label on a page

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

ESP-32 nodeMCU-32s

What LVGL version are you using?

v7.9.0

What do you want to achieve?

Display a stream of text on to a page

What have you tried so far?

I am reading about task as it can be executed periodically.
However, my label on the page is created with:

lv_obj_t * label = lv_label_create(page, NULL);

and this label is inside of the page function.
I am having troubles to see have to update the same label with a task.

Store the label reference in a global variable.

1 Like

Sorry do you mean creating the page and the label(child of the page) outside of the setup() so they will be global? How do you store the label reference in a global variable?

I think I figured it out. Thanks for the support!

@kev if you figured it out, its always worth explaining how, so the next person with the same issue(me) doesnt want to shout at the screen because this is the only relevantly titled search result

As embeddedt suggested, storing the label reference as a global variable is the solution

#include <stdio.h>

/* global variable declaration */
int g = 20;

int main () {

/* local variable declaration */
int g = 10;

printf (“value of g = %d\n”, g);

return 0;
}

thank you, i misunderstood which thing needed to be global i think