diff --git a/lv_examples/1_1_hello_world/lv_ex_hello_world.c b/lv_examples/1_1_hello_world/lv_ex_hello_world.c index c9a65c6e96..c7968a3d5b 100644 --- a/lv_examples/1_1_hello_world/lv_ex_hello_world.c +++ b/lv_examples/1_1_hello_world/lv_ex_hello_world.c @@ -1,5 +1,5 @@ /** - * @file lv_hello_world.c + * @file lv_ex_hello_world.c * */ @@ -14,7 +14,7 @@ /********************* * INCLUDES *********************/ -#include "lv_hello_world.h" +#include "lv_ex_hello_world.h" #if USE_LV_EXAMPLE != 0 #include "lvgl/lvgl.h" @@ -46,7 +46,7 @@ /** * Create a simple 'Hello world!' label */ -void lv_hello_world_init(void) +void lv_ex_hello_world(void) { /*Create a Label on the current screen*/ lv_obj_t * label1 = lv_label_create(lv_scr_act(), NULL); diff --git a/lv_examples/1_1_hello_world/lv_ex_hello_world.h b/lv_examples/1_1_hello_world/lv_ex_hello_world.h index a14b3f0438..a84708f179 100644 --- a/lv_examples/1_1_hello_world/lv_ex_hello_world.h +++ b/lv_examples/1_1_hello_world/lv_ex_hello_world.h @@ -1,10 +1,10 @@ /** - * @file lv_hello_world.h + * @file lv_ex_hello_world.h * */ -#ifndef LV_HELLO_WORLD_H -#define LV_HELLO_WORLD_H +#ifndef LV_EX_HELLO_WORLD_H +#define LV_EX_HELLO_WORLD_H #ifdef __cplusplus extern "C" { @@ -27,7 +27,7 @@ extern "C" { /********************** * GLOBAL PROTOTYPES **********************/ -void lv_hello_world_init(void); +void lv_ex_hello_world(void); /********************** * MACROS diff --git a/lv_examples/1_1_hello_world/lv_ex_hello_world.png b/lv_examples/1_1_hello_world/lv_ex_hello_world.png new file mode 100644 index 0000000000..547f045edf Binary files /dev/null and b/lv_examples/1_1_hello_world/lv_ex_hello_world.png differ diff --git a/lv_examples/1_2_objects/lv_ex_objects.h b/lv_examples/1_2_objects/lv_ex_objects.h index 5f6d7dc00f..7bcba5ac08 100644 --- a/lv_examples/1_2_objects/lv_ex_objects.h +++ b/lv_examples/1_2_objects/lv_ex_objects.h @@ -1,10 +1,10 @@ /** - * @file lv_hello_world.h + * @file lv_ex_objects.h * */ -#ifndef LV_OBJ_USAGE_H -#define LV_OBJ_USAGE_H +#ifndef LV_EX_OBJECTS_H +#define LV_EX_OBJECTS_H #ifdef __cplusplus extern "C" { @@ -27,7 +27,7 @@ extern "C" { /********************** * GLOBAL PROTOTYPES **********************/ -void lv_obj_usage_init(void); +void lv_ex_objects(void); /********************** * MACROS diff --git a/lv_examples/1_2_objects/lv_ex_objects.png b/lv_examples/1_2_objects/lv_ex_objects.png new file mode 100644 index 0000000000..f18386c16c Binary files /dev/null and b/lv_examples/1_2_objects/lv_ex_objects.png differ diff --git a/lv_examples/1_3_styles/lv_ex_styles.c b/lv_examples/1_3_styles/lv_ex_styles.c index 4c7ffe3227..b0b6ccc574 100644 --- a/lv_examples/1_3_styles/lv_ex_styles.c +++ b/lv_examples/1_3_styles/lv_ex_styles.c @@ -1,5 +1,5 @@ /** - * @file style_usage.c + * @file lv_ex_styles.h * */ @@ -27,7 +27,7 @@ /********************* * INCLUDES *********************/ -#include "style_usage.h" +#include "lv_ex_styles.h" #if USE_LV_EXAMPLE != 0 @@ -60,66 +60,65 @@ /** * Create a simple 'Hello world!' label */ -void style_usage_init(void) +void lv_ex_styles(void) { - /************************************ - * BUTTON + LABEL WITH DEFAULT STYLE - ************************************/ + /**************************************** + * BASE OBJECT + LABEL WITH DEFAULT STYLE + ****************************************/ - lv_obj_t * btn1; - btn1 = lv_btn_create(lv_scr_act(), NULL); /*Create a simple button*/ - lv_obj_set_pos(btn1, 10, 10); - lv_obj_t * label = lv_label_create(btn1, NULL); /*Add a lebel tothe button*/ + lv_obj_t * obj1; + obj1 = lv_obj_create(lv_scr_act(), NULL); /*Create a simple objects*/ + lv_obj_set_pos(obj1, 10, 10); + lv_obj_t * label = lv_label_create(obj1, NULL); + + /*Add a label to the object*/ lv_label_set_text(label, "Default"); + lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0); - /************************ - * BUTTON WITH NEW STYLE - ************************/ + /**************************************** + * BASE OBJECT WITH PRETTY COLOR STYLE + ****************************************/ - /* Create a new style - * Don't forget a style can describe any object type - * like buttons and labels */ - static lv_style_t style_btn2; /*Styles can't be local variables*/ - lv_style_get(LV_STYLE_PRETTY_COLOR, &style_btn2); /*Copy a built-in style as a starting point*/ - style_btn2.swidth = 10; /*10 px shadow*/ - style_btn2.bwidth = 5; /*5 px border width*/ - style_btn2.mcolor = COLOR_ORANGE; /*Orange main color*/ - style_btn2.gcolor = COLOR_RED; /*Red gradient color*/ - style_btn2.letter_space = 10; /*10 px letter space*/ - style_btn2.txt_align = LV_TXT_ALIGN_MID; /*Text align: middle*/ + lv_obj_t * obj2; + obj2 = lv_obj_create(lv_scr_act(), NULL); + lv_obj_align(obj2, obj1, LV_ALIGN_OUT_RIGHT_MID, 20, 0); /*Align next to the previous object*/ + lv_obj_set_style(obj2, lv_style_get(LV_STYLE_PRETTY_COLOR, NULL)); /*Set built in style*/ + label = lv_label_create(obj2, NULL); - /*Create a button and apply the new style*/ - lv_obj_t * btn2; - btn2 = lv_btn_create(lv_scr_act(), NULL); - lv_obj_align(btn2, btn1, LV_ALIGN_OUT_RIGHT_MID, 20, 0); - lv_obj_set_style(btn2, &style_btn2); + /* Add a label to the object. + * Labels by default inherit the parent's style */ + lv_label_set_text(label, "Pretty\ncolor"); + lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0); - /* Add a label to the button. - * Label by default inherits the parent's style */ - label = lv_label_create(btn2, NULL); + /***************************** + * BASE OBJECT WITH NEW STYLE + *****************************/ + + /* Create a new style */ + static lv_style_t style_new; /*Styles can't be local variables*/ + lv_style_get(LV_STYLE_PRETTY_COLOR, &style_new); /*Copy a built-in style as a starting point*/ + style_new.radius = LV_RADIUS_CIRCLE; /*Fully round corners*/ + style_new.swidth = 8; /*8 px shadow*/ + style_new.bwidth = 2; /*2 px border width*/ + style_new.mcolor = COLOR_WHITE; /*White main color*/ + style_new.gcolor = color_mix(COLOR_BLUE, COLOR_WHITE, OPA_40); /*light blue gradient color*/ + style_new.scolor = COLOR_MAKE(0xa0, 0xa0, 0xa0); /*Light gray shadow color*/ + style_new.ccolor = color_mix(COLOR_BLUE, COLOR_WHITE, OPA_90); /*Blue content color (text color)*/ + style_new.letter_space = 10; /*10 px letter space*/ + style_new.txt_align = LV_TXT_ALIGN_MID; /*Middel text align*/ + + /*Create a base object and apply the new style*/ + lv_obj_t * obj3; + obj3 = lv_obj_create(lv_scr_act(), NULL); + lv_obj_align(obj3, obj2, LV_ALIGN_OUT_RIGHT_MID, 20, 0); + lv_obj_set_style(obj3, &style_new); + + /* Add a label to the object. + * Labels by default inherit the parent's style */ + label = lv_label_create(obj3, NULL); lv_label_set_text(label, "New\nstyle"); - - /************************ - * LABEL WITH NEW STYLE - ************************/ - - /*Create new style for the label*/ - static lv_style_t style_label; - lv_style_get(LV_STYLE_PRETTY_COLOR, &style_label); /*Use a built-in style*/ - style_label.ccolor = color_mix(COLOR_BLUE, COLOR_WHITE, OPA_70);/*Light blue content color (text color) */ - style_label.letter_space = 4; /*4 px letter space*/ - style_label.txt_align = LV_TXT_ALIGN_MID; /*Text align: middle*/ - - /*Copy 'btn2'. It will use the same style as 'btn2'*/ - lv_obj_t * btn3; - btn3 = lv_btn_create(lv_scr_act(), btn2); - lv_obj_align(btn3, btn2, LV_ALIGN_OUT_RIGHT_MID, 20, 0); - - /*Create a label and apply the new style */ - label = lv_label_create(btn3, NULL); - lv_label_set_text(label, "Label\nstyle"); - lv_obj_set_style(label, &style_label); + lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0); /************************ @@ -131,7 +130,7 @@ void style_usage_init(void) lv_style_get(LV_STYLE_PRETTY_COLOR, &style_led); style_led.swidth = 15; style_led.radius = LV_RADIUS_CIRCLE; - style_led.bwidth = 5; + style_led.bwidth = 3; style_led.bopa = OPA_30; style_led.mcolor = COLOR_MAKE(0xb5, 0x0f, 0x04); style_led.gcolor = COLOR_MAKE(0x50, 0x07, 0x02); @@ -141,17 +140,17 @@ void style_usage_init(void) /*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_us(led1, btn1, LV_ALIGN_OUT_BOTTOM_MID, 0, 40); + lv_obj_align_us(led1, obj1, LV_ALIGN_OUT_BOTTOM_MID, 0, 40); lv_led_on(led1); /*Copy the previous LED and set a brightness*/ lv_obj_t * led2 = lv_led_create(lv_scr_act(), led1); - lv_obj_align_us(led2, btn2, LV_ALIGN_OUT_BOTTOM_MID, 0, 40); + lv_obj_align_us(led2, obj2, 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_us(led3, btn3, LV_ALIGN_OUT_BOTTOM_MID, 0, 40); + lv_obj_align_us(led3, obj3, LV_ALIGN_OUT_BOTTOM_MID, 0, 40); lv_led_off(led3); } diff --git a/lv_examples/1_3_styles/lv_ex_styles.png b/lv_examples/1_3_styles/lv_ex_styles.png new file mode 100644 index 0000000000..5cf3af4f85 Binary files /dev/null and b/lv_examples/1_3_styles/lv_ex_styles.png differ diff --git a/lv_examples/1_5_animations/lv_ex_animations.c b/lv_examples/1_5_animations/lv_ex_animations.c index 41c8edcb0d..8b13789179 100644 --- a/lv_examples/1_5_animations/lv_ex_animations.c +++ b/lv_examples/1_5_animations/lv_ex_animations.c @@ -1,28 +1 @@ -/* - * - static lv_style_t s1; - lv_style_get(LV_STYLE_BTN_REL, &s1); - static lv_style_t s2; - lv_style_get(LV_STYLE_BTN_REL, &s2); - s2.radius = 30; - s2.mcolor = COLOR_RED; - s2.bwidth = 8; - s2.opa = 50; - s2.hpad = 80; - //s2.font = font_get(FONT_DEJAVU_60); - - - lv_style_anim_t a; - a.act_time = -1000; - a.time = 1000; - a.playback = 1; - a.playback_pause = 300; - a.repeat = 1; - a.repeat_pause = 300; - a.end_cb = NULL; - a.style_anim = lv_style_get(LV_STYLE_BTN_REL, NULL); - a.style_start = &s1; - a.style_end = &s2; - lv_style_anim_create(&a); - */ diff --git a/lv_examples/2_2_encoder_ctrl/lv_ex_encoder_ctrl.h b/lv_examples/2_2_encoder_ctrl/lv_ex_encoder_ctrl.h index 8cd3651b02..622658775d 100644 --- a/lv_examples/2_2_encoder_ctrl/lv_ex_encoder_ctrl.h +++ b/lv_examples/2_2_encoder_ctrl/lv_ex_encoder_ctrl.h @@ -1,10 +1,10 @@ /** - * @file encoder_ctrl.h + * @file lv_ex_encoder_ctrl.h * */ -#ifndef ENCODER_CTRL_H -#define ENCODER_CTRL_H +#ifndef LV_EX_ENCODER_CTRL_H +#define LV_EX_ENCODER_CTRL_H #ifdef __cplusplus extern "C" { @@ -27,7 +27,7 @@ extern "C" { /********************** * GLOBAL PROTOTYPES **********************/ -void encoder_ctrl_init(void); +void lv_ex_encoder_ctrl(void); /********************** * MACROS diff --git a/lv_examples/2_2_encoder_ctrl/lv_ex_encoder_ctrl.png b/lv_examples/2_2_encoder_ctrl/lv_ex_encoder_ctrl.png new file mode 100644 index 0000000000..c540c88f18 Binary files /dev/null and b/lv_examples/2_2_encoder_ctrl/lv_ex_encoder_ctrl.png differ