How to change the border color of LED object in LVGL v8


Good Day! I’ve been trying the LVGL v8 and it has been great so far.
My problem is that I can’t change the border color of a LED object by using the lv_obj_set_style_border_color() . It’s been working on LVGL v7, but it seems that the styling has changed a little bit on v8.

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


What LVGL version are you using?


What do you want to achieve?

I want to change the border color of LED objects

What have you tried so far?

I managed to make it work somehow by modifying the lv_led.c and adding a new function which accepts a color parameter and assigns it to rect_dsc.border_color found on lv_led_event() . However, I still prefer the approach which does not modify any original source code of LVGL v8.

Code to reproduce

Here are my added codes on lv_led.c which made the changing of border color works:

void lv_led_set_border_color(lv_obj_t * obj, lv_color_t color)
lv_led_t * led = (lv_led_t *)obj;
led->border_color = color;

Here are my codes when I’m trying to change the border color by using the generic lv_obj_set_style functions which doesn’t work:

led_obj = lv_led_create(led_widget_obj); 
lv_obj_set_style_border_width(led_obj, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_border_color(led_obj, lv_color_white(), LV_PART_MAIN | LV_STATE_DEFAULT);

Is there any way to change the border color by using the lv_obj_set_style_border_color() ? You’re suggestions would be much appreciated. Thanks!

See this comment: Set border color of LED object - #4 by kisvegabor

Tried the latest fix and verified that it’s working! Thank you very much @embeddedt @kisvegabor