Drawing simple objects in LVGL seems hard, I was trying to do that a few weeks ago, figured I was going to have to write code for things like rectangle, circle etc. Here’s one test I did.
lv_obj_t *
drawRectangle( int x, int y, int width, int height, lv_color_t color ) {
lv_obj_t * obj1 = lv_obj_create(lv_scr_act(), NULL);
lv_style_t *style1 = (lv_style_t *)malloc( sizeof( lv_style_t ));
lv_style_copy(style1, &lv_style_plain_color); /*Copy a built-in style to initialize the new style*/
style1->body.empty = 1;
style1->body.border.color = color;
style1->body.border.width = 1;
style1->body.border.part = LV_BORDER_FULL;
lv_obj_set_style(obj1, style1);
lv_obj_set_pos(obj1, x, y);
lv_obj_set_size(obj1, width, height);
return obj1;
}
void opcontrol() {
lv_obj_t *obj = drawRectangle( 20, 20, 100, 100, LV_COLOR_YELLOW);
while (true) {
pros::delay(20);
}
}
obj1 = lv_obj_create(lv_scr_act(), NULL);
I have a BTNM object on the outer layer that I can’t “use lv_scr_act()”
I want to transplant your visual test page on VCS to PROS.