How to increment an arc in a timer without a crash


I’m trying to set a value of an arc in a timer, but I think I’m getting a crash. I want to use an arc as an indicator of a gauge value, from 1 to 100. I’ve created the screen and arc in SquareLine studio, latest versions.

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

RP2040 Connect, Arduino C++, IDE 2.x latest.

What LVGL version are you using?


What do you want to achieve?

I want to be able to set the value of an arc (between 1 and 100) depending on the value of a variable, say an integer.

What have you tried so far?

I have an int counter is a global (for testing).
For the screen that my arc is on, I have a SCREEN_LOADED event that starts an LVGL timer, set to fire every second. The timer works nicely. The callback function calls lv_arc_set_value(ui_VacuumPressure, counter);

The first time the timer gets called, all is good. The second time it gets called (counter == 2), it crashes. the label “ui_GaugeValueLabel” (see snippet below) updates correctly, then it crashes. If I comment out "lv_arc_set_value(ui_VacuumPressure, counter);", it works perfectly. If I have “lv_arc_set_value” use an absolute for the value, such as "lv_arc_set_value(ui_VacuumPressure, 50)", it doesn’t crash.

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:

void updateGaugeScreen_timer(lv_timer_t *timer) {
  char buffer[4];
  sprintf(buffer, "%d", counter);
  lv_label_set_text(ui_GaugeValueLabel, buffer);
  lv_arc_set_value(ui_VacuumPressure, counter);
    if (counter == 100) {
    counter = 1;

## Screenshot and/or video
I don't have one  - there doesn't seem to be an option to upload one.

could you post the code that creates your arc?

Also, you could simplify your code with

lv_label_set_text_fmt(ui_GaugeValueLabel, "%d", counter);