Hello,
i am using the latest version of lvgl on an ESP32 with Arduino IDE.
I am trying to produce a chart. As far as i understood, there is no way to give individual x-points while drawing data with the built in functionality. This is why i try to draw line-objects.
The number of “points” and with that the number of lines to draw can change according to a list, which is created somewhere else dynamically.
So far i managed to draw objects dynamically with allocating a vector of objects - this works fine. Trying to apply this to the lines object fails at the point, where
lv_line_set_points(section_lines[i], **points**, 2);
has to be used. If i set a 2D array of lv_point_t, the code compiles, but in the moment of drawing, to be more specific, in the moment of scrolling into the chart, the ESP freezes with the last trace msg:
Trace: lv_draw_get_buf: allocate (C:\Users\Eichler\Documents\Arduino\libraries\LittlevGL\src\src\lv_draw\lv_draw.c #57)
with drawing 2 lines, each one has 2 points. The code looks as follows, excluding some part which is in between to calculate x and y positions (which is working correctly):
lv_point_t time_sections[programs[prog_i].seasons[season_i].profiles[0].size()][2];
std::vector<lv_obj_t *> section_lines(programs[prog_i].seasons[season_i].profiles[0].size());
//const lv_point_t points[] = {{70, 150}, {190, 40}};
for (int i = 0; i<programs[prog_i].seasons[season_i].profiles[0].size(); i++)
{
[......]
time_sections[i][0] = {(int)xpoint(x1), (int)ppoint(y1)};
time_sections[i][1] = {(int)xpoint(x2), (int)ppoint(y2)};
section_lines[i] = lv_line_create(page, NULL);
lv_line_set_style(section_lines[i], LV_LINE_STYLE_MAIN, &style_line);
lv_line_set_points(section_lines[i], time_sections[i], 2);
lv_obj_set_pos(section_lines[i], 10, 220);
}
if i set a pair of constant dummy points (commented in the example code), it works as expected.
I am not able to create a vector / an array, which is written dynamically and can serve the set_points function to draw multiple lines automatically. Can you help me with that? Thank you very much!