Hi,
The definition of lv_canvas_draw_line is:
void lv_canvas_draw_line(lv_obj_t *canvas, const lv_point_t points[], uint32_t point_cnt, lv_draw_line_dsc_t *line_draw_dsc)
The second arg is an array of lv_point_t
, how should I pass the array in micropython?
I have tried tuple and list but both failed:
canv = lv.canvas()
p1 = lv.point_t()
p2 = lv.point_t()
p1.x = 100
p1.y = 100
p2.x = 300
p2.y = 300
canv.draw_line((p1,p2), 2, style) # failed
canv.draw_line([p1, p2], 2, style) #failed
Thanks.
Good catch. It’s a bug.
The draw_line C prototype is
void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, const lv_style_t * style);
It should change to:
void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt, const lv_style_t * style);
For C, passing const lv_point_t * points
or const lv_point_t points[]
is the same.
But the micropython bindings use that as a hint that this is an array and not a pointer.
Until this is fixed on GitHub you can try changing it locally and see if it solves your problem.
After that, canv.draw_line([p1, p2], 2, style)
should work.
Fixed (including some other similar cases) on https://github.com/lvgl/lvgl/pull/1633