The chart does not draw


I want the values from the sensor to be transmitted and displayed in the chart

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


What do you want to achieve?

correct display of values on the chart

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:

lv_obj_t * chart_test(lv_obj_t * cont){

	chart_one = lv_chart_create(cont, NULL);
	lv_obj_set_size(chart_one, 270, 400);
	lv_obj_align(chart_one, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
	lv_chart_set_type(chart_one, LV_CHART_TYPE_LINE);
	lv_chart_set_series_opa(chart_one, LV_OPA_70);
	lv_chart_set_series_width(chart_one, 4);
	lv_chart_set_range(chart_one, 0, 100);
	lv_chart_set_style(chart_one, LV_CHART_STYLE_MAIN, &lv_style_transp);
    ser_one = lv_chart_add_series(chart_one, LV_COLOR_DEEPSKYBLUE);
    lv_chart_set_next(chart_one, ser_one,0);
	return chart_one;
from the sensor

lv_task_create( chart_refresher_task, 1024, LV_TASK_PRIO_MID, NULL);   
void chart_refresher_task(void *p)
    int arr[2];
    sprintf(arr, "%d", (int)sensor_data.temp);
    lv_chart_set_next(chart_1, ser_one,arr);


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

I assume chart_test gets called. Can you put a debug statement in chart_refresher_task and see if it gets called?

he called, watch the video what is happening on the (3.2 MB)

I think the data is just out of scope

It looks weird:

void chart_refresher_task(void *p)
    int arr[2];
    sprintf(arr, "%d", (int)sensor_data.temp);
    lv_chart_set_next(chart_1, ser_one,arr);

sptrinf creates a string which you put into an int array, an pass it to lv_chart_set_next which needs a single int.

It should work:

    lv_chart_set_next(chart_1, ser_one, sensor_data.temp);
1 Like

it worked with labele so i thought it would work for chart too, but ok, i`am testing

its worked)))
thancks so much)

A good place to check that is the documentation.

lv_chart_set_next takes an integer as the new value. lv_label_set_text takes a char * (string) as the new value.

1 Like

You are welcome!
Probably there was a warning for it too. I suggest checking them carefully because they help to identify issues like this.

1 Like