How to change LVGL's line chart value's max range from 2 bytes to 4 bytes on stm32

Description

I am currently using the line chart example in LVGL V8.0. I realised that the max value of for the plots and Y-axis is 2 bytes but I need to display values greater than 100,000 as 2^(16)-1 gives a range of -32,768 to 32,767 only. How do I change it so that it can show values greater than 2 bytes? thank you for your help

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

stm32f769i-disco

What LVGL version are you using?

V8.0

What do you want to achieve?

I would like to display large values >100,000 on a line chart

What have you tried so far?

I have tried to change the plot values to a value <2 bytes and it displays correctly. However, when a value e.g., 100,000 is entered, the value shown is negative as there is buffer overflow.

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 lv_example_chart_1(void)
{
    /*Create a chart*/
    lv_obj_t * chart;
    chart = lv_chart_create(lv_scr_act());
    lv_obj_set_size(chart, 200, 150);
    lv_obj_center(chart);
    lv_chart_set_type(chart, LV_CHART_TYPE_LINE);   /*Show lines and points too*/
    lv_chart_set_range(chart, LV_CHART_AXIS_SECONDARY_Y, 0, 100000);  //shows negative value
    lv_chart_series_t * ser2 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_GREEN), LV_CHART_AXIS_SECONDARY_Y);


    /*Directly set points on 'ser2'*/
    ser2->y_points[0] = 90;
    ser2->y_points[1] = 100000; //shows negative value
    ser2->y_points[2] = 65;
    ser2->y_points[3] = 65;
    ser2->y_points[4] = 65;
    ser2->y_points[5] = 65;
    ser2->y_points[6] = 65;
    ser2->y_points[7] = 65;
    ser2->y_points[8] = 65;
    ser2->y_points[9] = 65;

    lv_chart_refresh(chart); /*Required after direct set*/
}

I have solved the problem. Just go to lv_conf.h to change LV_USE_LARGE_COORD to 1. Thanks to the developers accounting for this problem.

1 Like