Dynamic table update of sensor readings using LVGL with Arduino

Description
Hello everyone,

I’m using the LVGL library for the first time and trying to create a GUI for my Arduino Giga R1 project. A sensor is used to take readings at a certain time interval, which I want to display in a table on my Giga Display for all time intervals. Apparently LVGL tables can only display text and not numerics, so I have already tried to convert the numerics to char. The code compiled and uploaded to my Arduino, but the Mbed OS crashes and it seems like the issue is with the table. Does anyone have any ideas? :slight_smile:

What MCU/Processor/Board and compiler are you using?
STM32H747XI - Arduino Giga R1

What LVGL version are you using?
9.1.0

What do you want to achieve?
New sensor readings should be added to a new row in the table.

What have you tried so far?
See below.

Code to reproduce

The code block(s) should be formatted like:

void addRowAndUpdateTable(lv_obj_t *table, const char *col1, const char *col2, const char *col3) {
    uint16_t rowCount = lv_table_get_row_cnt(table);
    lv_table_set_row_cnt(table, rowCount + 1);

    lv_table_set_cell_value_fmt(table, rowCount, 0, "%s", col1);
    lv_table_set_cell_value_fmt(table, rowCount, 1, "%s", col2);
    lv_table_set_cell_value_fmt(table, rowCount, 2, "%s", col3);
}

...

void continuousODMeasurement(unsigned long currentMillis) {
    
    Serial.println("Continuous OD measurements ongoing");

    currentMillis = millis();

    if (currentMillis - previousMillis >= ODInterval) {
      elapsedMillis = currentMillis - startMillis;

      int sampleRawIntensity = takeMultipleReadings(turbidostatPin);
      float ODValue = -1.0 * log10(sampleRawIntensity - darkRef) / (blankRef - darkRef);

      Serial.print(elapsedSeconds);
      Serial.print(ODValue);
      Serial.println(sampleRawIntensity);

      char elapsedMillisBuffer[20];  
      char currentODValueBuffer[20];
      char currentSampleIntensityBuffer[20];

      sprintf(elapsedMillisBuffer, "%lu", elapsedMillis);  
      sprintf(currentODValueBuffer, "%.3f", ODValue);     
      sprintf(currentSampleIntensityBuffer, "%d", sampleRawIntensity);  

addRowAndUpdateTable(measurementTable, elapsedMillisBuffer, currentODValueBuffer, currentSampleIntensityBuffer);

        lv_task_handler();

      previousMillis = currentMillis; 
    }

...

Hi,

Being a little lazy I simply use strings, but thats because I want to show it’s degrees centigrade…:

    String printtemp = String(temp) + "°c";
    lv_table_set_cell_value(sensorTable, arraypos, 1, printtemp.c_str());