Description
What MCU/Processor/Board and compiler are you using?
ESP32
What LVGL version are you using?
LVGL @ master (as of 8-26-2021)
lvgl_esp32_drivers
What do you want to achieve?
Changing arc color, arc thickness, arc ending (flat)
What have you tried so far?
Using lv_style_t, I have tried using lv_style_set_line_color, lv_style_set_arc_color, and a few others.
I’ve been able to change background arc color when using lv_obj_add_style(obj, &style, LV_ARC_DRAW_PART_BACKGROUND), but using LV_ARC_DRAW_PART_FOREGROUND does not change foreground color.
In addition to the coloring issue I’ve been facing, I havent found a clean method of changing things like the arc thickness.
fwiw the arcs are then animated used lv_anim_timeline, if it makes an impact (I dont think it should)
Code to reproduce
‘’’
{
static lv_style_t main_style;
lv_style_init(&main_style);
lv_style_set_bg_opa(&main_style, LV_OPA_COVER);
lv_style_set_bg_color(&main_style, lv_color_black());
lv_style_init(&arc_style_bg);
lv_style_set_arc_color(&arc_style_bg, lv_color_make(103, 103, 103));
lv_style_init(&arc_style_normal);
lv_style_set_line_color(&arc_style_normal, lv_color_make(243, 243, 243));
// have tried lv_style_set_arc_color here as well to no avail
lv_style_init(&arc_style_blue);
lv_style_set_line_color(&arc_style_blue, lv_color_make(44, 171, 224));
lv_obj_t* main_screen = lv_scr_act();
lv_obj_add_style(main_screen, &main_style, 0);
lv_obj_t* arc1 = lv_spawn_arc(main_screen, 0, 270, 0, 360, 0, -40, 80, 80, LV_ARC_MODE_NORMAL);
// arc fg color should be set here, but remains the normal blue color
lv_obj_add_style(arc1, &arc_style_normal, LV_ARC_DRAW_PART_FOREGROUND);
}
lv_obj_t* lv_spawn_arc(lv_obj_t *parent, uint8_t start_value, uint16_t rot, uint16_t angle_start, uint16_t angle_end, uint16_t x, uint16_t y, uint16_t width, uint16_t height, lv_arc_mode_t mode)
{
lv_obj_t * arc = lv_arc_create(parent);
lv_obj_set_size(arc, width, height);
lv_arc_set_value(arc, start_value);
lv_arc_set_rotation(arc, rot);
lv_arc_set_bg_angles(arc, angle_start, angle_end);
lv_arc_set_mode(arc, mode);
// Arc bg color is set here, and sets color properly
lv_obj_add_style(arc, &arc_style_bg, LV_ARC_DRAW_PART_BACKGROUND);
// lv_obj_remove_style(arc, NULL, LV_PART_KNOB); /*Be sure the knob is not displayed*/
lv_obj_clear_flag(arc, LV_OBJ_FLAG_CLICKABLE); /*To not allow adjusting by click*/
lv_obj_align(arc, LV_ALIGN_CENTER, x, y);
return arc;
}
‘’’