Updating Labels and Widgets, get stuck


I want to display some I2C Values for temperature and Window Shades. The problem is im currently updating all widgets and labels with a timer (currently 5) and the code gets always stuck at the highest value of my bar (40 degrees).
I dont know how to update everything at once. Im not that deep into programming (only Arduino).

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


What LVGL version are you using?


What do you want to achieve?

Updating everything at once

What have you tried so far?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.


Its like this i have a bigger function where i wrote everything, so this function is like 300 lines. But in this function i declare the sytles and so on.
Do you need more ?

lv_obj_t* screen;
lv_obj_t* bar;
lv_obj_t* tab;
lv_obj_t* tab_j;
lv_obj_t* lamelle;
lv_obj_t* jAnim;
lv_obj_t* jbild;
lv_obj_t* Neigung;
lv_obj_t* JalousienAnzeige;
lv_obj_t* label;

void setup() {

void loop(){

  unsigned int tickPeriod = millis() - lasTickMillies;
  lasTickMillies = millis();

static void timer_anzeige(lv_timer_t* timer) {
  label = (lv_obj_t*)(timer->user_data);
  lv_label_set_text_fmt(label, "%d°C", temperatur);

static void timer_callback(lv_timer_t* timer) {
  bar = (lv_obj_t*)(timer->user_data);
  lv_bar_set_value(bar, temperatur, LV_ANIM_OFF);

static void JalousienLabel(lv_timer_t* labeltimer) {
  JalousienAnzeige = (lv_obj_t*)(labeltimer->user_data);
  lv_label_set_text_fmt(JalousienAnzeige, "%d%%", jalousieStand);

static void JalousienAnim(lv_timer_t* Animtimer) {

  jAnim = (lv_obj_t*)(Animtimer->user_data);
  lv_obj_set_size(jAnim, 110, (15 + (100 - jalousieStand)));

static void NeigungBalken(lv_timer_t* Neigungtimer) {

  lamelle = (lv_obj_t*)(Neigungtimer->user_data);
  lv_bar_set_value(lamelle, neigung, LV_ANIM_OFF);
void ui_init()

label = lv_label_create(tab);
  lv_style_set_text_font(&style_base, &lv_font_montserrat_20);
  lv_obj_add_style(label, &style_base, LV_PART_MAIN);
  lv_obj_align(label, LV_ALIGN_RIGHT_MID, -70, 10);
  lv_label_set_text_fmt(label, "%d°C", temperatur);
  lv_timer_create(timer_anzeige, 1000, label);

// Temperatur Balken
  static lv_style_t style_bar;
  bar = lv_bar_create(tab);
  lv_obj_add_style(bar, &style_bar, LV_PART_INDICATOR);
  lv_obj_set_size(bar, 30, 190);
  lv_obj_align(bar, LV_ALIGN_RIGHT_MID, -10, 0);
  lv_bar_set_range(bar, -20, 40);
  lv_style_set_bg_color(&style_bar, lv_palette_main(LV_PALETTE_RED));
  lv_style_set_bg_grad_color(&style_bar, lv_palette_main(LV_PALETTE_BLUE));
  lv_style_set_bg_grad_dir(&style_bar, LV_GRAD_DIR_VER);
  lv_bar_set_value(bar, temperatur, LV_ANIM_ON);
  lv_timer_create(timer_callback, 1000, bar);

  JalousienAnzeige = lv_label_create(tab_j);
  lv_style_set_text_font(&style_base, &lv_font_montserrat_20);
  lv_obj_add_style(JalousienAnzeige, &style_base, LV_PART_MAIN);
  lv_obj_align(JalousienAnzeige, LV_ALIGN_RIGHT_MID, 5, 70);
  lv_label_set_text_fmt(JalousienAnzeige, "%d%%", jalousieStand);
  lv_timer_create(JalousienLabel, 100, JalousienAnzeige);

 jAnim = lv_obj_create(jbild);                              
  lv_obj_set_size(jAnim, 110, (15 + (100 - jalousieStand))); 
  lv_obj_align(jAnim, LV_ALIGN_BOTTOM_MID, 0, 5);
  lv_obj_clear_flag(jAnim, LV_OBJ_FLAG_SCROLLABLE);
  lv_obj_add_style(jAnim, &style_base, LV_PART_MAIN);
  lv_timer_create(JalousienAnim, 100, jAnim);

lamelle = lv_bar_create(tab_j);
  lv_obj_remove_style_all(lamelle); /*To have a clean start*/
  lv_obj_add_style(lamelle, &style_bge, 0);
  lv_obj_add_style(lamelle, &style_indi, LV_PART_INDICATOR);
  lv_obj_set_size(lamelle, 20, 100);
  lv_obj_align(lamelle, LV_ALIGN_LEFT_MID, 10, 0);
  lv_bar_set_range(lamelle, 90, 0);
  lv_bar_set_value(lamelle, neigung, LV_ANIM_ON);
  lv_timer_create(NeigungBalken, 3000, lamelle);


is global ? and here isnt show labels and widgets… Too where you update Stand value

I2C_Init cant be in loop and too better is inc_tick outside loop hw based irq or alternative get tick func

Yes its global. I have a global variable, where i store the values. In the moment I have a slave taht sends me data and i store it in the variable. But whats confusing is that the code always get stuck at the same value. Just before i get the value 40 the code gets stuck.

I2C_init() is where i get my data. So should I get tick func in ui_init()?

Normal UI can work based on timers or on changed values events. Too you init name invoke that you init some periphery repeatly, isnt good idea. When you only read, this require be no longer as 1ms process, otherwise is better place it in separate task.

But back to stuck. Locate real source , use some debug prints for locate issue or jtag debug if you have it.

I will use some debug prints and come back to you.

and you dont require many timers and sending user data, here is it waste of mcu power. Create for equal time only one timer and in cb manage many objects

`lv_timer_create(tt100, 100, NULL);`

and in tt100 both code…

Now you overwrite objects with same objects

lamelle = (lv_obj_t*)(Neigungtimer->user_data);