The LEDs are rectangle-like (or circle) object. You can set their brightness with lv_led_set_bright(led, bright). The brightness should be between 0 (darkest) and 255 (lightest).

Use lv_led_on(led) and lv_led_off(led) to set the brightness to a predefined ON or OFF value. The lv_led_toggle(led) toggles between the ON and OFF state.

Style usage

The LED uses one style which can be set by lv_led_set_style(led, &style). To determine the appearance the style.body properties are used. The colors are darkened and shadow width is reduced at lower brightness and gains its original value at brightness 255 to show a lighting effect. The default style is: lv_style_pretty_color


  • Typically the default style is not suitable therefore you has to create you own style. See the Examples.
Example of Led in Littlev Graphics Library

						/*Create a style for the LED*/
static lv_style_t style_led;
lv_style_copy(&style_led, &lv_style_pretty_color);
style_led.body.radius = LV_RADIUS_CIRCLE;
style_led.body.main_color = LV_COLOR_MAKE(0xb5, 0x0f, 0x04);
style_led.body.grad_color = LV_COLOR_MAKE(0x50, 0x07, 0x02);
style_led.body.border.color = LV_COLOR_MAKE(0xfa, 0x0f, 0x00);
style_led.body.border.width = 3;
style_led.body.border.opa = LV_OPA_30;
style_led.body.shadow.color = LV_COLOR_MAKE(0xb5, 0x0f, 0x04);
style_led.body.shadow.width = 10;

/*Create a LED and switch it ON*/
lv_obj_t * led1  = lv_led_create(lv_scr_act(), NULL);
lv_obj_set_style(led1, &style_led);
lv_obj_align(led1, NULL, LV_ALIGN_IN_TOP_MID, 40, 40);

/*Copy the previous LED and set a brightness*/
lv_obj_t * led2  = lv_led_create(lv_scr_act(), led1);
lv_obj_align(led2, led1, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
lv_led_set_bright(led2, 190);

/*Copy the previous LED and switch it OFF*/
lv_obj_t * led3  = lv_led_create(lv_scr_act(), led1);
lv_obj_align(led3, led2, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);

/*Create 3 labels next to the LEDs*/
lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text(label, "LED On");
lv_obj_align(label, led1, LV_ALIGN_OUT_LEFT_MID, -40, 0);

label = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text(label, "LED half");
lv_obj_align(label, led2, LV_ALIGN_OUT_LEFT_MID, -40, 0);

label = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text(label, "LED Off");
lv_obj_align(label, led3, LV_ALIGN_OUT_LEFT_MID, -40, 0);

lv_obj_t *


(lv_obj_t * par, lv_obj_t * copy);

Create a led objects

par pointer to an object, it will be the parent of the new led

copy pointer to a led object, if not NULL then the new object will be copied from it

return pointer to the created led



(lv_obj_t * led, uint8_t bright);

Set the brightness of a LED object

led pointer to a LED object

bright 0 (max. dark) ... 255 (max. light)



(lv_obj_t * led);

Light on a LED

led pointer to a LED object



(lv_obj_t * led);

Light off a LED

led pointer to a LED object



(lv_obj_t * led);

Toggle the state of a LED

led pointer to a LED object



(lv_obj_t *led, lv_style_t *style);

Set the style of a led

led pointer to a led object

style pointer to a style



(lv_obj_t * led);

Get the brightness of a LEd object

led pointer to LED object

return bright 0 (max. dark) ... 255 (max. light)



(lv_obj_t *led);

Get the style of an led object

led pointer to an led object

return pointer to the led's style

LittlevGL - Open-source Embedded GUI Library

LittlevGL is a free and open-source graphics library providing everything you need to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint.

If you like LittlevGL, please
support its deveopment!

The founder of Littlev Graphics Library (LittlevGL) and related software modules is:
Gábor Kiss-Vámosi
All Rights Reserved ©  2018 Hungary