Example of a dynamic label in Arduino and switching screens


I was following the LVGL_Arduino example in Arduino, but it seems like the layout is created in the setup and the loop just calls lv_timer_handler();. Is this representative of the way lvgl should work in Arduino or is it more likely that work will be done in the loop to change the display if it is dynamic. I think an example, like a simple clock, for Arduino might help reduce my learning curve. Does such an example exist?

Should I keep the screens as global variables and load them? Do I put something in the loop to repaint the display or do I just update the message on the display?

I think it crashes too because the screen is supposed to sleep but it stops after the 2nd call to this function.

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

nRF52, ST7789, Arduino 2.0.4

What LVGL version are you using?


What do you want to achieve?

Update a label on a screen dynamically and swap between two screens.

What have you tried so far?

Making the label a global variable and creating and loading screens.

Code to reproduce

void screen_message(char* blemessage)

  lv_obj_t * scr1 = lv_obj_create(NULL);
  lv_obj_set_style_bg_color(scr1, lv_color_black(), LV_PART_MAIN);
  lv_obj_t* gtLabel = lv_label_create(scr1);
  lv_obj_set_style_text_color(scr1, lv_color_white(), LV_PART_MAIN);
  lv_obj_align(gtLabel, LV_ALIGN_CENTER, 0, 0);

Screenshot and/or video