How to input-output data in LVGL with ArduinoIDE?

For example, I ran the lv_demo_widgets() example. I want to send data through the terminal and change the value of label “name”. (In the example, it is “Elena Smith”). It should be code like:

  if (Serial.available()>0){
    int val = Serial.parseInt();
    lv_label_set_text(name, val);

But where and how to insert this code to make it work? (The example uses files LvglWidgets.ino, lv_demo_widgets.c, lv_demo_widgets.h)
And how to send data from widgets to the terminal or I2C?
What is the best protocol to use to communicate with another board? Serial, I2C, other?

First, create a global object for your label, outside of the setup/loop functions.
lv_obj_t * name;

In your setup code, after initializing your display/touch/serial/lvgl etc, create your label using the relevant api.
You create the object only once to avoid a memory leak.

Then place your code example in the main loop.

Super simple

The problem is that the label name is created in the lv_demo_widgets.c file, while loop() is executed in the LvglWidgets.ino file. And the .ino file does not see the name variable, even if extern is used. Probably because they are in different folders.

Oh, you want to modify the lvgl demo app.
Perhaps add a function to the demo app .c file where ypu can feed it a char pointer, declare it in the demo widget .h file so that you can use it externally

Then call it in your main loop function with the serial data.

There are many simple and creative ways to achieve it - keep trying, you’ll get it to work

Perhaps I can declare in the demo_widget.h file the variable name as well?

Can you help me with another question?
How to work in LvglWindowsSimulator with Microsoft Visual Studio? I create a new project and put my .h and .c files in it, do #inclued lvgl/lvgl.h in .c file. But it doesn’t work.