Chart updating lag


We had a discussion in the "Useless whole screen refresh" topic about this problem and as @kisvegabor suggested I opened this topic in order to talk about it more.
As I wrote there too, When I scroll the menu fast, I can see a lag in updating the chart, which was not in ver 6.
Here is the ver 6, with acceptable lag in updating the chart:

And here is the ver 7 one, you can see the updating lag in chart:

I also checked it with both states of LV_USE_ANIMATION and I saw no difference. Not sure but even felt that disabling the animation makes it worse.

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

stm32f429, stm32cubeide, gcc

What LVGL version are you using?

v 7

What do you want to achieve?

having less lag, as in ver 6 I had.

Code to reproduce

        chart = lv_chart_create(lv_scr_act(), NULL);
		lv_obj_set_size(chart, 704, 190);

		lv_obj_set_style_local_bg_opa(chart, LV_CHART_PART_BG, LV_STATE_DEFAULT, LV_OPA_TRANSP);
		lv_obj_set_style_local_border_opa(chart, LV_CHART_PART_BG, LV_STATE_DEFAULT, LV_OPA_TRANSP);
		lv_obj_set_style_local_pad_all(chart, LV_CHART_PART_BG, LV_STATE_DEFAULT, 0);
		lv_obj_set_style_local_bg_opa(chart, LV_CHART_PART_SERIES_BG, LV_STATE_DEFAULT, LV_OPA_TRANSP);
		lv_obj_set_style_local_line_width(chart, LV_CHART_PART_SERIES, LV_STATE_DEFAULT, 2);
		lv_obj_set_style_local_size(chart, LV_CHART_PART_SERIES, LV_STATE_DEFAULT, 0);/*radius of points*/

		lv_obj_align(chart, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 325);

		lv_chart_set_update_mode(chart, LV_CHART_UPDATE_MODE_CIRCULAR);

		lv_chart_set_type(chart, LV_CHART_TYPE_LINE);
		lv_obj_set_style_local_bg_opa(chart, LV_CHART_PART_SERIES, LV_STATE_DEFAULT, LV_OPA_TRANSP);

		lv_chart_set_point_count(chart, 225);
		lv_chart_set_div_line_count(chart, 0, 0);
		lv_chart_set_range(chart, 0, 255);

		/*Add data series*/
		series = lv_chart_add_series(chart, LV_COLOR_CYAN);

		lv_chart_init_points(chart, series, 0);

Sorry for the late replay, Ali. I’ve added this to my todo list.

1 Like

Thanks, @kisvegabor

@kisvegabor As you said here:

That logic hasn’t changed in v7. LVGL just redraws every dirty area. However, it seems in v6 the chart is still running in the background while you scroll, but in v7 it stops. So v7 might be slower here.

Anyway, how you implemented this chart? Maybe there is something to optimize there.

No need to say how good it is to optimize more. So with regarding this, I hope this new solution I found to solve my problem will not have any bad effect on your decision in optimizing :sunglasses:
Anyway, here it is:
Based on @kisvegabor 's answer in the issue I opened recently I found that it’s not a bad idea to create an lvgl task for updating GUI parameters and chart.
So I added these 2 lines:
lv_task_create(lvgl_task_refresh_params_callback, 1000, LV_TASK_PRIO_MID, NULL);
lv_task_create(lvgl_task_refresh_chart_callback, 8, LV_TASK_PRIO_HIGH, NULL);

and the result was so satisfying for me.
PS: I call lv_task_handler every 10 ms, Is it O.K to have set the period in lv_task_create less than this time?

It’s completely safe to make the period smaller; just be aware that the period is effectively rounded to the frequency at which you call lv_task_handler (meaning it will not be called any more frequently than 10ms).

1 Like

Maybe the chart lag is over as well? :slight_smile:
(Sorry, but I couldn’t immerse in it yet :frowning: )

Hmm, It’s far better, but you didn’t hear it from me.:sunglasses:

1 Like