Arc change color in another function

Description

Change arc color in another function dynamically

What MCU/Processor/Board and compiler are you using?

PC simulation

What LVGL version are you using?

last on master

What do you want to achieve?

What have you tried so far?

lv_obj_set_style_local_bg_color(arc,LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_BLACK);

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

    static lv_style_t style;
	lv_style_init(&style);
	lv_style_set_line_width(&style, LV_STATE_DEFAULT, 15);

	static lv_style_t st_color;
	lv_style_init(&st_color);
	lv_style_set_line_width(&st_color, LV_STATE_DEFAULT, 15);
//
	lv_obj_t * arc = lv_arc_create(lv_scr_act(), NULL);
	lv_arc_set_bg_angles(arc, 0, 100);
	lv_arc_set_value(arc, 50);
	lv_obj_set_size(arc, 230, 230);
	lv_obj_set_style_local_border_opa(arc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0);
	lv_obj_set_style_local_bg_opa(arc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0);
	lv_obj_add_style(arc, LV_OBJ_PART_MAIN, &style);
	lv_obj_add_style(arc, LV_ARC_PART_INDIC, &st_color);
	lv_obj_align(arc, NULL, LV_ALIGN_CENTER, 0, 0);

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Hi,

You can modify the line color in st_color and call lv_obj_report_style_mod(&st_color) to tell LVGL a style has changed or change arc’s the local style like this:

lv_obj_set_style_local_line_color(arc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT,  color);
2 Likes

I apologize for the stupid question, but I don’t see where these functions can be viewed, in the documentation i can`t see …

It’s explained here: https://docs.lvgl.io/latest/en/html/overview/style.html

Feedback is very welcome, so if you think the docs can be improved, please let us know.

1 Like