lv_example: add screenshots

This commit is contained in:
Gabor
2017-08-17 10:41:48 +02:00
parent b8080ef1db
commit 7fdd633561
10 changed files with 71 additions and 99 deletions
@@ -1,5 +1,5 @@
/** /**
* @file lv_hello_world.c * @file lv_ex_hello_world.c
* *
*/ */
@@ -14,7 +14,7 @@
/********************* /*********************
* INCLUDES * INCLUDES
*********************/ *********************/
#include "lv_hello_world.h" #include "lv_ex_hello_world.h"
#if USE_LV_EXAMPLE != 0 #if USE_LV_EXAMPLE != 0
#include "lvgl/lvgl.h" #include "lvgl/lvgl.h"
@@ -46,7 +46,7 @@
/** /**
* Create a simple 'Hello world!' label * 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*/ /*Create a Label on the current screen*/
lv_obj_t * label1 = lv_label_create(lv_scr_act(), NULL); lv_obj_t * label1 = lv_label_create(lv_scr_act(), NULL);
@@ -1,10 +1,10 @@
/** /**
* @file lv_hello_world.h * @file lv_ex_hello_world.h
* *
*/ */
#ifndef LV_HELLO_WORLD_H #ifndef LV_EX_HELLO_WORLD_H
#define LV_HELLO_WORLD_H #define LV_EX_HELLO_WORLD_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -27,7 +27,7 @@ extern "C" {
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES
**********************/ **********************/
void lv_hello_world_init(void); void lv_ex_hello_world(void);
/********************** /**********************
* MACROS * MACROS
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

+4 -4
View File
@@ -1,10 +1,10 @@
/** /**
* @file lv_hello_world.h * @file lv_ex_objects.h
* *
*/ */
#ifndef LV_OBJ_USAGE_H #ifndef LV_EX_OBJECTS_H
#define LV_OBJ_USAGE_H #define LV_EX_OBJECTS_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -27,7 +27,7 @@ extern "C" {
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES
**********************/ **********************/
void lv_obj_usage_init(void); void lv_ex_objects(void);
/********************** /**********************
* MACROS * MACROS
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

+56 -57
View File
@@ -1,5 +1,5 @@
/** /**
* @file style_usage.c * @file lv_ex_styles.h
* *
*/ */
@@ -27,7 +27,7 @@
/********************* /*********************
* INCLUDES * INCLUDES
*********************/ *********************/
#include "style_usage.h" #include "lv_ex_styles.h"
#if USE_LV_EXAMPLE != 0 #if USE_LV_EXAMPLE != 0
@@ -60,66 +60,65 @@
/** /**
* Create a simple 'Hello world!' label * 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; lv_obj_t * obj1;
btn1 = lv_btn_create(lv_scr_act(), NULL); /*Create a simple button*/ obj1 = lv_obj_create(lv_scr_act(), NULL); /*Create a simple objects*/
lv_obj_set_pos(btn1, 10, 10); lv_obj_set_pos(obj1, 10, 10);
lv_obj_t * label = lv_label_create(btn1, NULL); /*Add a lebel tothe button*/ lv_obj_t * label = lv_label_create(obj1, NULL);
/*Add a label to the object*/
lv_label_set_text(label, "Default"); 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 lv_obj_t * obj2;
* Don't forget a style can describe any object type obj2 = lv_obj_create(lv_scr_act(), NULL);
* like buttons and labels */ lv_obj_align(obj2, obj1, LV_ALIGN_OUT_RIGHT_MID, 20, 0); /*Align next to the previous object*/
static lv_style_t style_btn2; /*Styles can't be local variables*/ lv_obj_set_style(obj2, lv_style_get(LV_STYLE_PRETTY_COLOR, NULL)); /*Set built in style*/
lv_style_get(LV_STYLE_PRETTY_COLOR, &style_btn2); /*Copy a built-in style as a starting point*/ label = lv_label_create(obj2, NULL);
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*/
/*Create a button and apply the new style*/ /* Add a label to the object.
lv_obj_t * btn2; * Labels by default inherit the parent's style */
btn2 = lv_btn_create(lv_scr_act(), NULL); lv_label_set_text(label, "Pretty\ncolor");
lv_obj_align(btn2, btn1, LV_ALIGN_OUT_RIGHT_MID, 20, 0); lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style(btn2, &style_btn2);
/* Add a label to the button. /*****************************
* Label by default inherits the parent's style */ * BASE OBJECT WITH NEW STYLE
label = lv_label_create(btn2, NULL); *****************************/
/* 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"); lv_label_set_text(label, "New\nstyle");
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
/************************
* 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);
/************************ /************************
@@ -131,7 +130,7 @@ void style_usage_init(void)
lv_style_get(LV_STYLE_PRETTY_COLOR, &style_led); lv_style_get(LV_STYLE_PRETTY_COLOR, &style_led);
style_led.swidth = 15; style_led.swidth = 15;
style_led.radius = LV_RADIUS_CIRCLE; style_led.radius = LV_RADIUS_CIRCLE;
style_led.bwidth = 5; style_led.bwidth = 3;
style_led.bopa = OPA_30; style_led.bopa = OPA_30;
style_led.mcolor = COLOR_MAKE(0xb5, 0x0f, 0x04); style_led.mcolor = COLOR_MAKE(0xb5, 0x0f, 0x04);
style_led.gcolor = COLOR_MAKE(0x50, 0x07, 0x02); style_led.gcolor = COLOR_MAKE(0x50, 0x07, 0x02);
@@ -141,17 +140,17 @@ void style_usage_init(void)
/*Create a LED and switch it ON*/ /*Create a LED and switch it ON*/
lv_obj_t * led1 = lv_led_create(lv_scr_act(), NULL); lv_obj_t * led1 = lv_led_create(lv_scr_act(), NULL);
lv_obj_set_style(led1, &style_led); 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); lv_led_on(led1);
/*Copy the previous LED and set a brightness*/ /*Copy the previous LED and set a brightness*/
lv_obj_t * led2 = lv_led_create(lv_scr_act(), led1); 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); lv_led_set_bright(led2, 190);
/*Copy the previous LED and switch it OFF*/ /*Copy the previous LED and switch it OFF*/
lv_obj_t * led3 = lv_led_create(lv_scr_act(), led1); 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); lv_led_off(led3);
} }
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

@@ -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);
*/
@@ -1,10 +1,10 @@
/** /**
* @file encoder_ctrl.h * @file lv_ex_encoder_ctrl.h
* *
*/ */
#ifndef ENCODER_CTRL_H #ifndef LV_EX_ENCODER_CTRL_H
#define ENCODER_CTRL_H #define LV_EX_ENCODER_CTRL_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -27,7 +27,7 @@ extern "C" {
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES
**********************/ **********************/
void encoder_ctrl_init(void); void lv_ex_encoder_ctrl(void);
/********************** /**********************
* MACROS * MACROS
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB