I want to plot a point on chart after a button is pressed.
the API lv_chart_set_next_value2() is used to plot the point, and lv_chart_refresh() is used to refresh the chart.
But the chart do not update immediately until next point is input and lv_chart_set_next_value2() is executed again.
What MCU/Processor/Board and compiler are you using?
VisualStudio simulator
What LVGL version are you using?
v8
What do you want to achieve?
the chart is update when a button is pressed.
What have you tried so far?
I use an additional lv_chart_set_next_value2() to trigger the chart to update.
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 plot_st_data(x, y) is called when a btn is pressed.
the following code does not update immediately
void plot_st_data(x, y) {
printf("plot st data \n");
lv_chart_set_next_value2(chart_op, ser_st, x, y);
lv_chart_refresh(chart_op);
}
the following code can refresh the chart immediately
void plot_st_data(x, y) {
printf("plot st data \n");
lv_chart_set_next_value2(chart_op, ser_st, x, y);
lv_chart_refresh(chart_op);
lv_chart_set_next_value2(chart_op, ser_st, x, y);
}
My understanding is that lv_chart_refresh just marks the chart as ‘dirty’ and it is actually rendered on the next screen update which is controlled by an update interval setting in lv_conf.h
If you want to force an immediate screen update, try also calling lv_refr_now(NULL);
Thank for your suggest, i have tried the code as following:
printf("plot st data \n");
lv_chart_set_next_value2(chart_op, ser_st, x, y);
lv_chart_refresh(chart_op);
lv_refr_now(NULL);
and
printf("plot st data \n");
lv_chart_set_next_value2(chart_op, ser_st, x, y);
lv_refr_now(NULL);
the chart can not be update immediately.
In fact,no matter how long you waiting for, the chart does not be updated until next lv_chart_set_next_value2() be execused.
I will refer the example you suggested.
Thank you!
I use v8. Because it is used to show the input data, chart updates immediately is import.
I will make a simple test to determine if it is a bug.
Thank you for your information.
After rewrite my code, the API lv_chart_set_next_value2()can run correctly now.
I find the problem that maybe caused by incorrectly variable declaration in my function i.e. plot_st_data(x, y){...}, is should be plot_st_data(uint16_t x, uint16_t y){...}
BTW,
The API function lv_chart_refresh() is not necessary since it is build in lv_chart_set_next_value2()
Anyway, It’s solved. Thanks!