A39模拟器
This commit is contained in:
13
MXC-A39/lvgl/examples/widgets/led/index.rst
Normal file
13
MXC-A39/lvgl/examples/widgets/led/index.rst
Normal file
@ -0,0 +1,13 @@
|
||||
C
|
||||
^
|
||||
|
||||
LED with custom style
|
||||
"""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/led/lv_example_led_1
|
||||
:language: c
|
||||
|
||||
MicroPython
|
||||
^^^^^^^^^^^
|
||||
|
||||
No examples yet.
|
26
MXC-A39/lvgl/examples/widgets/led/lv_example_led_1.c
Normal file
26
MXC-A39/lvgl/examples/widgets/led/lv_example_led_1.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_LED && LV_BUILD_EXAMPLES
|
||||
|
||||
/**
|
||||
* Create LED's with different brightness and color
|
||||
*/
|
||||
void lv_example_led_1(void)
|
||||
{
|
||||
/*Create a LED and switch it OFF*/
|
||||
lv_obj_t * led1 = lv_led_create(lv_scr_act());
|
||||
lv_obj_align(led1, LV_ALIGN_CENTER, -80, 0);
|
||||
lv_led_off(led1);
|
||||
|
||||
/*Copy the previous LED and set a brightness*/
|
||||
lv_obj_t * led2 = lv_led_create(lv_scr_act());
|
||||
lv_obj_align(led2, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_led_set_brightness(led2, 150);
|
||||
lv_led_set_color(led2, lv_palette_main(LV_PALETTE_RED));
|
||||
|
||||
/*Copy the previous LED and switch it ON*/
|
||||
lv_obj_t * led3 = lv_led_create(lv_scr_act());
|
||||
lv_obj_align(led3, LV_ALIGN_CENTER, 80, 0);
|
||||
lv_led_on(led3);
|
||||
}
|
||||
|
||||
#endif
|
27
MXC-A39/lvgl/examples/widgets/led/lv_example_led_1.py
Normal file
27
MXC-A39/lvgl/examples/widgets/led/lv_example_led_1.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Create a style for the LED
|
||||
style_led = lv.style_t()
|
||||
lv.style_copy(style_led, lv.style_pretty_color)
|
||||
style_led.body.radius = 800 # large enough to draw a 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 = 5
|
||||
|
||||
# Create a LED and switch it OFF
|
||||
led1 = lv.led(lv.scr_act())
|
||||
led1.set_style(lv.led.STYLE.MAIN, style_led)
|
||||
led1.align(None, lv.ALIGN.CENTER, -80, 0)
|
||||
led1.off()
|
||||
|
||||
# Copy the previous LED and set a brightness
|
||||
led2 = lv.led(lv.scr_act(), led1)
|
||||
led2.align(None, lv.ALIGN.CENTER, 0, 0)
|
||||
led2.set_bright(190)
|
||||
|
||||
# Copy the previous LED and switch it ON
|
||||
led3 = lv.led(lv.scr_act(), led1)
|
||||
led3.align(None, lv.ALIGN.CENTER, 80, 0)
|
||||
led3.on()
|
Reference in New Issue
Block a user