The LVGL lv_line example code ends with the line:
lv_obj_center(line1);
The result of that line of code drove me (a complete noob) nuts for about a day. When you use it with the example points defined in
static lv_point_precise_t line_points[] = { {5, 5}, {70, 70}, {120, 10}, {180, 60}, {240, 10} };
you may not immediately notice a problem. But if you look carefully at the point results and the resulting figure on your CYD, you’ll see that the points on the line are not where you expected them.
I modified the lv_line example to display three “+” symbols at different locations across the screen.
With the lv_obj_center line not commented out, I got the following display on my CYD:
https://drive.google.com/file/d/1jv2usbqxbLvoF3CoQJVG_t0P2jCIjAnm/view?usp=sharing
With lv_obj_center commented out, I get the desired result:
https://drive.google.com/file/d/1jwZ-LHwL5e8alYYPr5EWd5t3P4cTdcee/view?usp=sharing
Here’s the code, with the lv_obj_center line not commented out:
void lv_draw_cross(void)
{
/*Create arrays for the points of the line*/
static lv_point_precise_t line1_points[] = { {20, 10}, {40, 10} };
static lv_point_precise_t line2_points[] = { {30, 0}, {30, 20} };
static lv_point_precise_t line3_points[] = { {140, 100}, {160, 100} };
static lv_point_precise_t line4_points[] = { {150, 90}, {150, 110} };
static lv_point_precise_t line5_points[] = { {280, 200}, {300, 200} };
static lv_point_precise_t line6_points[] = { {290, 190}, {290, 210} };
/*Create style*/
static lv_style_t style_line;
lv_style_init(&style_line);
lv_style_set_line_width(&style_line, 2);
lv_style_set_line_color(&style_line, lv_palette_main(LV_PALETTE_BLUE));
lv_style_set_line_rounded(&style_line, true);
/* Create and display the six lines comprising the three + symbols */
lv_obj_t * line1;
line1 = lv_line_create(lv_screen_active());
lv_line_set_points(line1, line1_points, 2); /*Set the points*/
lv_obj_add_style(line1, &style_line, 0);
lv_obj_center(line1);
lv_obj_t * line2;
line2 = lv_line_create(lv_screen_active());
lv_line_set_points(line2, line2_points, 2); /*Set the points*/
lv_obj_add_style(line2, &style_line, 0);
lv_obj_center(line2);
lv_obj_t * line3;
line3 = lv_line_create(lv_screen_active());
lv_line_set_points(line3, line3_points, 2); /*Set the points*/
lv_obj_add_style(line3, &style_line, 0);
lv_obj_center(line3);
lv_obj_t * line4;
line4 = lv_line_create(lv_screen_active());
lv_line_set_points(line4, line4_points, 2); /*Set the points*/
lv_obj_add_style(line4, &style_line, 0);
lv_obj_center(line4);
lv_obj_t * line5;
line5 = lv_line_create(lv_screen_active());
lv_line_set_points(line5, line5_points, 2); /*Set the points*/
lv_obj_add_style(line5, &style_line, 0);
lv_obj_center(line5);
lv_obj_t * line6;
line6 = lv_line_create(lv_screen_active());
lv_line_set_points(line6, line6_points, 2); /*Set the points*/
lv_obj_add_style(line6, &style_line, 0);
lv_obj_center(line6);
}
Consequently, I would argue that when the lv_obj_center line is used, the resulting display is not What You Code Is What You Get.
I sure wish this forum had a preview feature, so I didn’t have to post a bunch of mis-formatted posts to see what I need to edit. Also, it seems buggy, because it moved my code and /code tags a couple of times.