How to draw square waveform using LVGL chart

Hello, I think you somehow need to create a point on the same X axis with a higher Y first, then the next point with higher Y, and then when it drops again, remain on the X axis and lower Y again.

But as far as I know lv_chart_set_next_value() adds the value to an array with the Y axis and automatically scales the horizontal axis. All charts seem to work with automatic scaling in horizontal/X axis.

Maybe something like this works:

lv_chart_set_next_value(chart, ser, 0);
lv_chart_set_next_value(chart, ser, 80);
lv_chart_set_next_value(chart, ser, 80);
lv_chart_set_next_value(chart, ser, 0);
lv_chart_set_next_value(chart, ser, 0);
lv_chart_set_next_value(chart, ser, 80);
lv_chart_set_next_value(chart, ser, 80);
lv_chart_set_next_value(chart, ser, 0);

But I doubt it… You might even have to draw lines yourself…

1 Like