feat(color): use colors from material design

Use function instead of color macros
This commit is contained in:
Gabor Kiss-Vamosi
2021-02-23 15:03:06 +01:00
parent 8740046efc
commit cbfbcb47f9
60 changed files with 475 additions and 222 deletions

View File

@@ -14,22 +14,22 @@ void lv_example_get_started_2(void)
lv_style_init(&style_btn);
lv_style_set_radius(&style_btn, 10);
lv_style_set_bg_opa(&style_btn, LV_OPA_COVER);
lv_style_set_bg_color(&style_btn, LV_COLOR_SILVER);
lv_style_set_bg_grad_color(&style_btn, LV_COLOR_GRAY);
lv_style_set_bg_color(&style_btn, lv_color_grey_lighten_3());
lv_style_set_bg_grad_color(&style_btn, lv_color_grey());
lv_style_set_bg_grad_dir(&style_btn, LV_GRAD_DIR_VER);
/*Add a border*/
lv_style_set_border_color(&style_btn, LV_COLOR_WHITE);
lv_style_set_border_color(&style_btn, lv_color_white());
lv_style_set_border_opa(&style_btn, LV_OPA_70);
lv_style_set_border_width(&style_btn, 2);
/*Set the text style*/
lv_style_set_text_color(&style_btn, LV_COLOR_WHITE);
lv_style_set_text_color(&style_btn, lv_color_white());
/*Create a red style. Change only some colors.*/
lv_style_init(&style_btn_red);
lv_style_set_bg_color(&style_btn_red, LV_COLOR_RED);
lv_style_set_bg_grad_color(&style_btn_red, LV_COLOR_MAROON);
lv_style_set_bg_color(&style_btn_red, lv_color_red());
lv_style_set_bg_grad_color(&style_btn_red, lv_color_red_darken_3());
/*Create a style for the pressed state. Add color filter to make every color darker*/
lv_style_init(&style_btn_pressed);

View File

@@ -27,8 +27,6 @@ extern "C" {
**********************/
void lv_example_scroll_1(void);
void lv_example_scroll_2(void);
void lv_example_scroll_3(void);
void lv_example_scroll_4(void);
/**********************
* MACROS

View File

@@ -12,8 +12,8 @@ void lv_example_style_1(void)
/*Make a gradient*/
lv_style_set_bg_opa(&style, LV_OPA_COVER);
lv_style_set_bg_color(&style, LV_COLOR_SILVER);
lv_style_set_bg_grad_color(&style, LV_COLOR_BLUE);
lv_style_set_bg_color(&style, lv_color_grey_lighten_3());
lv_style_set_bg_grad_color(&style, lv_color_blue());
lv_style_set_bg_grad_dir(&style, LV_GRAD_DIR_VER);
/*Shift the gradient to the bottom*/

View File

@@ -12,10 +12,10 @@ typedef int _keep_pedantic_happy;
// /*Set a background color and a radius*/
// lv_style_set_radius(&style, LV_STATE_DEFAULT, 5);
// lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER);
// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_SILVER);
// lv_style_set_bg_color(&style, LV_STATE_DEFAULT, lv_color_grey_lighten_3());
//
// /*Set different background color in pressed state*/
// lv_style_set_bg_color(&style, LV_STATE_PRESSED, LV_COLOR_GRAY);
// lv_style_set_bg_color(&style, LV_STATE_PRESSED, lv_color_grey());
//
// /*Set different transition time in default and pressed state
// *fast press, slower revert to default*/

View File

@@ -9,7 +9,7 @@ void lv_example_style_11(void)
static lv_style_t style;
lv_style_init(&style);
lv_style_set_arc_color(&style, LV_COLOR_RED);
lv_style_set_arc_color(&style, lv_color_red());
lv_style_set_arc_width(&style, 4);

View File

@@ -12,10 +12,10 @@ void lv_example_style_2(void)
/*Set a background color and a radius*/
lv_style_set_radius(&style, 10);
lv_style_set_bg_opa(&style, LV_OPA_COVER);
lv_style_set_bg_color(&style, LV_COLOR_SILVER);
lv_style_set_bg_color(&style, lv_color_grey_lighten_3());
/*Add border to the bottom+right*/
lv_style_set_border_color(&style, LV_COLOR_BLUE);
lv_style_set_border_color(&style, lv_color_blue());
lv_style_set_border_width(&style, 5);
lv_style_set_border_opa(&style, LV_OPA_50);
lv_style_set_border_side(&style, LV_BORDER_SIDE_BOTTOM | LV_BORDER_SIDE_RIGHT);

View File

@@ -12,11 +12,11 @@ void lv_example_style_3(void)
/*Set a background color and a radius*/
lv_style_set_radius(&style, 5);
lv_style_set_bg_opa(&style, LV_OPA_COVER);
lv_style_set_bg_color(&style, LV_COLOR_SILVER);
lv_style_set_bg_color(&style, lv_color_grey_lighten_3());
/*Add outline*/
lv_style_set_outline_width(&style, 2);
lv_style_set_outline_color(&style, LV_COLOR_BLUE);
lv_style_set_outline_color(&style, lv_color_blue());
lv_style_set_outline_pad(&style, 8);
/*Create an object with the new style*/

View File

@@ -12,11 +12,11 @@ void lv_example_style_4(void)
/*Set a background color and a radius*/
lv_style_set_radius(&style, 5);
lv_style_set_bg_opa(&style, LV_OPA_COVER);
lv_style_set_bg_color(&style, LV_COLOR_SILVER);
lv_style_set_bg_color(&style, lv_color_grey_lighten_3());
/*Add a shadow*/
lv_style_set_shadow_width(&style, 8);
lv_style_set_shadow_color(&style, LV_COLOR_BLUE);
lv_style_set_shadow_color(&style, lv_color_blue());
lv_style_set_shadow_ofs_x(&style, 10);
lv_style_set_shadow_ofs_y(&style, 20);

View File

@@ -12,10 +12,10 @@ void lv_example_style_6(void)
/*Set a background color and a radius*/
lv_style_set_radius(&style, 5);
lv_style_set_bg_opa(&style, LV_OPA_COVER);
lv_style_set_bg_color(&style, LV_COLOR_SILVER);
lv_style_set_bg_color(&style, lv_color_grey_lighten_3());
/*Add a value text properties*/
lv_style_set_content_color(&style, LV_COLOR_BLUE);
lv_style_set_content_color(&style, lv_color_blue());
lv_style_set_content_align(&style, LV_ALIGN_IN_BOTTOM_RIGHT);
lv_style_set_content_ofs_x(&style, -5);
lv_style_set_content_ofs_y(&style, -5);

View File

@@ -11,12 +11,12 @@ void lv_example_style_7(void)
lv_style_set_radius(&style, 5);
lv_style_set_bg_opa(&style, LV_OPA_COVER);
lv_style_set_bg_color(&style, LV_COLOR_SILVER);
lv_style_set_bg_color(&style, lv_color_grey_lighten_3());
lv_style_set_border_width(&style, 2);
lv_style_set_border_color(&style, LV_COLOR_BLUE);
lv_style_set_border_color(&style, lv_color_blue());
lv_style_set_pad_all(&style, 10);
lv_style_set_text_color(&style, LV_COLOR_BLUE);
lv_style_set_text_color(&style, lv_color_blue());
lv_style_set_text_letter_space(&style, 5);
lv_style_set_text_line_space(&style, 20);
lv_style_set_text_decor(&style, LV_TEXT_DECOR_UNDERLINE);

View File

@@ -9,7 +9,7 @@ void lv_example_style_8(void)
static lv_style_t style;
lv_style_init(&style);
lv_style_set_line_color(&style, LV_COLOR_GRAY);
lv_style_set_line_color(&style, lv_color_grey());
lv_style_set_line_width(&style, 6);
lv_style_set_line_rounded(&style, true);

View File

@@ -12,13 +12,13 @@ void lv_example_style_9(void)
/*Set a background color and a radius*/
lv_style_set_radius(&style, 5);
lv_style_set_bg_opa(&style, LV_OPA_COVER);
lv_style_set_bg_color(&style, LV_COLOR_SILVER);
lv_style_set_bg_color(&style, lv_color_grey_lighten_3());
lv_style_set_border_width(&style, 2);
lv_style_set_border_color(&style, LV_COLOR_BLUE);
lv_style_set_border_color(&style, lv_color_blue());
// lv_style_set_pad_all(&style, 10);
lv_style_set_img_recolor(&style, LV_COLOR_BLUE);
lv_style_set_img_recolor(&style, lv_color_blue());
lv_style_set_img_recolor_opa(&style, LV_OPA_50);
lv_style_set_transform_angle(&style, 300);

View File

@@ -10,7 +10,7 @@ void lv_example_bar_2(void)
static lv_style_t style_indic;
lv_style_init(&style_bg);
lv_style_set_border_color(&style_bg, LV_COLOR_BLUE);
lv_style_set_border_color(&style_bg, lv_color_blue());
lv_style_set_border_width(&style_bg, 2);
lv_style_set_pad_all(&style_bg, 6); /*To make the indicator smaller*/
lv_style_set_radius(&style_bg, 6);
@@ -18,7 +18,7 @@ void lv_example_bar_2(void)
lv_style_init(&style_indic);
lv_style_set_bg_opa(&style_indic, LV_OPA_COVER);
lv_style_set_bg_color(&style_indic, LV_COLOR_BLUE);
lv_style_set_bg_color(&style_indic, lv_color_blue());
lv_style_set_radius(&style_indic, 3);
lv_obj_t * bar = lv_bar_create(lv_scr_act(), NULL);

View File

@@ -19,12 +19,12 @@ void lv_example_bar_3(void)
lv_style_init(&style_indic);
lv_style_set_bg_opa(&style_indic, LV_OPA_COVER);
lv_style_set_bg_color(&style_indic, LV_COLOR_RED);
lv_style_set_bg_grad_color(&style_indic, LV_COLOR_BLUE);
lv_style_set_bg_color(&style_indic, lv_color_red());
lv_style_set_bg_grad_color(&style_indic, lv_color_blue());
lv_style_set_bg_grad_dir(&style_indic, LV_GRAD_DIR_VER);
lv_style_set_content_align(&style_indic, LV_ALIGN_OUT_LEFT_TOP);
lv_style_set_content_ofs_x(&style_indic, -3);
lv_style_set_content_color(&style_indic, LV_COLOR_GRAY);
lv_style_set_content_color(&style_indic, lv_color_grey());
lv_obj_t * bar = lv_bar_create(lv_scr_act(), NULL);
lv_obj_add_style(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, &style_indic);

View File

@@ -26,13 +26,13 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
if(lv_area_get_width(&bar->indic_area) > txt_size.x + 20) {
txt_area.x2 = bar->indic_area.x2 - 5;
txt_area.x1 = txt_area.x2 - txt_size.x + 1;
dsc.color = LV_COLOR_WHITE;
dsc.color = lv_color_white();
}
/*If the indicator is still short put the text out of it on the right */
else {
txt_area.x1 = bar->indic_area.x2 + 5;
txt_area.x2 = txt_area.x1 + txt_size.x - 1;
dsc.color = LV_COLOR_BLACK;
dsc.color = lv_color_black();
}
txt_area.y1 = bar->indic_area.y1 + (lv_area_get_height(&bar->indic_area) - txt_size.y) / 2;

View File

@@ -17,20 +17,20 @@ void lv_example_btn_2(void)
lv_style_set_radius(&style, 3);
lv_style_set_bg_opa(&style, LV_OPA_70);
lv_style_set_bg_color(&style, LV_COLOR_BLUE);
lv_style_set_bg_grad_color(&style, LV_COLOR_AQUA);
lv_style_set_bg_color(&style, lv_color_blue());
lv_style_set_bg_grad_color(&style, lv_color_blue_darken_4());
lv_style_set_bg_grad_dir(&style, LV_GRAD_DIR_VER);
lv_style_set_border_opa(&style, LV_OPA_40);
lv_style_set_border_width(&style, 2);
lv_style_set_border_color(&style, LV_COLOR_GRAY);
lv_style_set_border_color(&style, lv_color_grey());
lv_style_set_shadow_width(&style, 8);
lv_style_set_shadow_color(&style, LV_COLOR_GRAY);
lv_style_set_shadow_color(&style, lv_color_grey());
lv_style_set_shadow_ofs_x(&style, 8);
lv_style_set_shadow_ofs_y(&style, 8);
lv_style_set_text_color(&style, LV_COLOR_WHITE);
lv_style_set_text_color(&style, lv_color_white());
/*Init the pressed style*/
lv_style_set_shadow_ofs_x(&style_pr, 4);

View File

@@ -10,21 +10,21 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
/*Change the draw descriptor the 2nd button */
if(dsc->id == 1) {
dsc->rect_dsc->radius = 0;
if(lv_btnmatrix_get_pressed_btn(obj) == dsc->id) dsc->rect_dsc->bg_color = LV_COLOR_NAVY;
else dsc->rect_dsc->bg_color = LV_COLOR_BLUE;
if(lv_btnmatrix_get_pressed_btn(obj) == dsc->id) dsc->rect_dsc->bg_color = lv_color_blue_darken_3();
else dsc->rect_dsc->bg_color = lv_color_blue();
dsc->rect_dsc->shadow_width = 6;
dsc->rect_dsc->shadow_ofs_x = 3;
dsc->rect_dsc->shadow_ofs_y = 3;
dsc->label_dsc->color = LV_COLOR_WHITE;
dsc->label_dsc->color = lv_color_white();
}
/*Change the draw descriptor the 3rd button */
else if(dsc->id == 2) {
dsc->rect_dsc->radius = LV_RADIUS_CIRCLE;
if(lv_btnmatrix_get_pressed_btn(obj) == dsc->id) dsc->rect_dsc->bg_color = LV_COLOR_MAROON;
else dsc->rect_dsc->bg_color = LV_COLOR_RED;
if(lv_btnmatrix_get_pressed_btn(obj) == dsc->id) dsc->rect_dsc->bg_color = lv_color_red_darken_3();
else dsc->rect_dsc->bg_color = lv_color_red();
dsc->label_dsc->color = LV_COLOR_WHITE;
dsc->label_dsc->color = lv_color_white();
}
else if(dsc->id == 3) {
dsc->label_dsc->opa = LV_OPA_TRANSP; /*Hide the text if any*/
@@ -49,7 +49,7 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
lv_draw_img_dsc_t img_draw_dsc;
lv_draw_img_dsc_init(&img_draw_dsc);
img_draw_dsc.recolor = LV_COLOR_BLACK;
img_draw_dsc.recolor = lv_color_black();
if(lv_btnmatrix_get_pressed_btn(obj) == dsc->id) img_draw_dsc.recolor_opa = LV_OPA_30;
lv_draw_img(&a, dsc->clip_area, &img_star, &img_draw_dsc);

View File

@@ -41,7 +41,7 @@ void lv_example_btnmatrix_3(void)
lv_style_set_radius(&style_btn, 0);
lv_style_set_border_width(&style_btn, 1);
lv_style_set_border_opa(&style_btn, LV_OPA_50);
lv_style_set_border_color(&style_btn, LV_COLOR_GRAY);
lv_style_set_border_color(&style_btn, lv_color_grey());
lv_style_set_border_side(&style_btn, LV_BORDER_SIDE_INTERNAL);
lv_style_set_radius(&style_btn, 0);

View File

@@ -12,25 +12,25 @@ void lv_example_canvas_1(void)
rect_dsc.radius = 10;
rect_dsc.bg_opa = LV_OPA_COVER;
rect_dsc.bg_grad_dir = LV_GRAD_DIR_HOR;
rect_dsc.bg_color = LV_COLOR_RED;
rect_dsc.bg_grad_color = LV_COLOR_BLUE;
rect_dsc.bg_color = lv_color_red();
rect_dsc.bg_grad_color = lv_color_blue();
rect_dsc.border_width = 2;
rect_dsc.border_opa = LV_OPA_90;
rect_dsc.border_color = LV_COLOR_WHITE;
rect_dsc.border_color = lv_color_white();
rect_dsc.shadow_width = 5;
rect_dsc.shadow_ofs_x = 5;
rect_dsc.shadow_ofs_y = 5;
lv_draw_label_dsc_t label_dsc;
lv_draw_label_dsc_init(&label_dsc);
label_dsc.color = LV_COLOR_YELLOW;
label_dsc.color = lv_color_yellow();
static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
lv_obj_t * canvas = lv_canvas_create(lv_scr_act(), NULL);
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_TRUE_COLOR);
lv_obj_align(canvas, NULL, LV_ALIGN_CENTER, 0, 0);
lv_canvas_fill_bg(canvas, LV_COLOR_SILVER, LV_OPA_COVER);
lv_canvas_fill_bg(canvas, lv_color_grey_lighten_3(), LV_OPA_COVER);
lv_canvas_draw_rect(canvas, 70, 60, 100, 70, &rect_dsc);
@@ -46,7 +46,7 @@ void lv_example_canvas_1(void)
img.header.w = CANVAS_WIDTH;
img.header.h = CANVAS_HEIGHT;
lv_canvas_fill_bg(canvas, LV_COLOR_SILVER, LV_OPA_COVER);
lv_canvas_fill_bg(canvas, lv_color_grey_lighten_3(), LV_OPA_COVER);
lv_canvas_transform(canvas, &img, 30, LV_IMG_ZOOM_NONE, 0, 0, CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2, true);
}

View File

@@ -19,7 +19,7 @@ void lv_example_canvas_2(void)
lv_obj_t * canvas = lv_canvas_create(lv_scr_act(), NULL);
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_INDEXED_1BIT);
lv_canvas_set_palette(canvas, 0, LV_COLOR_CHROMA_KEY);
lv_canvas_set_palette(canvas, 1, LV_COLOR_RED);
lv_canvas_set_palette(canvas, 1, lv_color_red());
/*Create colors with the indices of the palette*/
lv_color_t c0;

View File

@@ -11,8 +11,8 @@ void lv_example_chart_1(void)
lv_chart_set_type(chart, LV_CHART_TYPE_LINE); /*Show lines and points too*/
/*Add two data series*/
lv_chart_series_t * ser1 = lv_chart_add_series(chart, LV_COLOR_RED, LV_CHART_AXIS_PRIMARY_Y);
lv_chart_series_t * ser2 = lv_chart_add_series(chart, LV_COLOR_GREEN, LV_CHART_AXIS_SECONDARY_Y);
lv_chart_series_t * ser1 = lv_chart_add_series(chart, lv_color_red(), LV_CHART_AXIS_PRIMARY_Y);
lv_chart_series_t * ser2 = lv_chart_add_series(chart, lv_color_green(), LV_CHART_AXIS_SECONDARY_Y);
/*Set the next points on 'ser1'*/
lv_chart_set_next_value(chart, ser1, 10);

View File

@@ -68,8 +68,8 @@ void lv_example_chart_2(void)
lv_obj_add_event_cb(chart1, event_cb, NULL);
/*Add two data series*/
ser1 = lv_chart_add_series(chart1, LV_COLOR_RED, LV_CHART_AXIS_PRIMARY_Y);
ser2 = lv_chart_add_series(chart1, LV_COLOR_BLUE, LV_CHART_AXIS_SECONDARY_Y);
ser1 = lv_chart_add_series(chart1, lv_color_red(), LV_CHART_AXIS_PRIMARY_Y);
ser2 = lv_chart_add_series(chart1, lv_color_blue(), LV_CHART_AXIS_SECONDARY_Y);
uint32_t i;
for(i = 0; i < 10; i++) {

View File

@@ -38,8 +38,8 @@ void lv_example_chart_3(void)
lv_chart_set_zoom_x(chart, 800);
/*Add two data series*/
lv_chart_series_t * ser1 = lv_chart_add_series(chart, LV_COLOR_RED, LV_CHART_AXIS_PRIMARY_Y);
lv_chart_series_t * ser2 = lv_chart_add_series(chart, LV_COLOR_GREEN, LV_CHART_AXIS_SECONDARY_Y);
lv_chart_series_t * ser1 = lv_chart_add_series(chart, lv_color_green_lighten_2(), LV_CHART_AXIS_PRIMARY_Y);
lv_chart_series_t * ser2 = lv_chart_add_series(chart, lv_color_green_darken_2(), LV_CHART_AXIS_SECONDARY_Y);
/*Set the next points on 'ser1'*/
lv_chart_set_next_value(chart, ser1, 31);

View File

@@ -30,11 +30,11 @@ static void event_cb(lv_obj_t * chart, lv_event_t e)
lv_draw_rect_dsc_t draw_rect_dsc;
lv_draw_rect_dsc_init(&draw_rect_dsc);
draw_rect_dsc.bg_color = LV_COLOR_BLACK;
draw_rect_dsc.bg_color = lv_color_black();
draw_rect_dsc.bg_opa = LV_OPA_50;
draw_rect_dsc.radius = 3;
draw_rect_dsc.content_text = buf;
draw_rect_dsc.content_color = LV_COLOR_WHITE;
draw_rect_dsc.content_color = lv_color_white();
lv_area_t a;
a.x1 = chart->coords.x1 + p.x - 20;
@@ -68,8 +68,8 @@ void lv_example_chart_4(void)
lv_chart_set_zoom_x(chart, 800);
/*Add two data series*/
lv_chart_series_t * ser1 = lv_chart_add_series(chart, LV_COLOR_RED, LV_CHART_AXIS_PRIMARY_Y);
lv_chart_series_t * ser2 = lv_chart_add_series(chart, LV_COLOR_GREEN, LV_CHART_AXIS_PRIMARY_Y);
lv_chart_series_t * ser1 = lv_chart_add_series(chart, lv_color_red(), LV_CHART_AXIS_PRIMARY_Y);
lv_chart_series_t * ser2 = lv_chart_add_series(chart, lv_color_green(), LV_CHART_AXIS_PRIMARY_Y);
uint32_t i;
for(i = 0; i < 10; i++) {
lv_chart_set_next_value(chart, ser1, lv_rand(60,90));

View File

@@ -14,10 +14,10 @@ static lv_obj_t * img1;
void lv_example_img_2(void)
{
/*Create 4 sliders to adjust RGB color and re-color intensity*/
red_slider = create_slider(LV_COLOR_RED);
green_slider = create_slider(LV_COLOR_LIME);
blue_slider = create_slider(LV_COLOR_BLUE);
intense_slider = create_slider(LV_COLOR_GRAY);
red_slider = create_slider(lv_color_red());
green_slider = create_slider(lv_color_green());
blue_slider = create_slider(lv_color_blue());
intense_slider = create_slider(lv_color_grey());
lv_slider_set_value(red_slider, LV_OPA_20, LV_ANIM_OFF);
lv_slider_set_value(green_slider, LV_OPA_90, LV_ANIM_OFF);

View File

@@ -15,10 +15,10 @@ void lv_example_img_4(void)
static lv_style_t style;
lv_style_init(&style);
lv_style_set_bg_color(&style, LV_COLOR_YELLOW);
lv_style_set_bg_color(&style, lv_color_yellow());
lv_style_set_bg_opa(&style, LV_OPA_COVER);
lv_style_set_img_recolor_opa(&style, LV_OPA_COVER);
lv_style_set_img_recolor(&style, LV_COLOR_BLACK);
lv_style_set_img_recolor(&style, lv_color_black());
lv_obj_t * img = lv_img_create(lv_scr_act(), NULL);
lv_obj_add_style(img, LV_PART_MAIN, LV_STATE_DEFAULT, &style);

View File

@@ -14,14 +14,14 @@ void lv_example_imgbtn_1(void)
static lv_style_t style_def;
lv_style_init(&style_def);
lv_style_set_text_color(&style_def, LV_COLOR_WHITE);
lv_style_set_text_color(&style_def, lv_color_white());
lv_style_set_transition(&style_def, &tr);
/*Darken the button when pressed and make it wider*/
static lv_style_t style_pr;
lv_style_init(&style_pr);
lv_style_set_img_recolor_opa(&style_pr, LV_OPA_30);
lv_style_set_img_recolor(&style_pr, LV_COLOR_BLACK);
lv_style_set_img_recolor(&style_pr, lv_color_black());
lv_style_set_transform_width(&style_pr, 20);
/*Create an image button*/

View File

@@ -10,7 +10,7 @@ void lv_example_label_2(void)
static lv_style_t style_shadow;
lv_style_init(&style_shadow);
lv_style_set_text_opa(&style_shadow, LV_OPA_30);
lv_style_set_text_color(&style_shadow, LV_COLOR_BLACK);
lv_style_set_text_color(&style_shadow, lv_color_black());
/*Create a label for the shadow first (it's in the background) */
lv_obj_t * shadow_label = lv_label_create(lv_scr_act(), NULL);

View File

@@ -15,7 +15,7 @@ void lv_example_led_1(void)
lv_obj_t * led2 = lv_led_create(lv_scr_act());
lv_obj_align(led2, NULL, LV_ALIGN_CENTER, 0, 0);
lv_led_set_brightness(led2, 150);
lv_led_set_color(led2, LV_COLOR_RED);
lv_led_set_color(led2, lv_color_red());
/*Copy the previous LED and switch it ON*/
lv_obj_t * led3 = lv_led_create(lv_scr_act());

View File

@@ -10,7 +10,7 @@ void lv_example_line_1(void)
static lv_style_t style_line;
lv_style_init(&style_line);
lv_style_set_line_width(&style_line, 8);
lv_style_set_line_color(&style_line, LV_COLOR_BLUE);
lv_style_set_line_color(&style_line, lv_color_blue());
lv_style_set_line_rounded(&style_line, true);
/*Create a line and apply the new style*/

View File

@@ -18,23 +18,23 @@ void lv_example_meter_1(void)
/*Add a scale first*/
lv_meter_scale_t * scale = lv_meter_add_scale(meter);
lv_meter_set_scale_ticks(meter, scale, 51, 2, 10, LV_COLOR_GRAY);
lv_meter_set_scale_major_ticks(meter, scale, 10, 4, 15, LV_COLOR_BLACK, 10);
lv_meter_set_scale_ticks(meter, scale, 51, 2, 10, lv_color_grey());
lv_meter_set_scale_major_ticks(meter, scale, 10, 4, 15, lv_color_black(), 10);
lv_meter_indicator_t * indic;
/*Add a red arc to the end */
indic = lv_meter_add_arc(meter, scale, 3, LV_COLOR_RED, 1);
indic = lv_meter_add_arc(meter, scale, 3, lv_color_red(), 1);
lv_meter_set_indicator_start_value(meter, indic, 80);
lv_meter_set_indicator_end_value(meter, indic, 100);
/*Make the tick lines red at the end of the scale*/
indic = lv_meter_add_scale_lines(meter, scale, LV_COLOR_RED, LV_COLOR_RED, false, 0);
indic = lv_meter_add_scale_lines(meter, scale, lv_color_red(), lv_color_red(), false, 0);
lv_meter_set_indicator_start_value(meter, indic, 80);
lv_meter_set_indicator_end_value(meter, indic, 100);
/*Add a needle line indicator*/
indic = lv_meter_add_needle_line(meter, scale, 4, LV_COLOR_GRAY, -10);
indic = lv_meter_add_needle_line(meter, scale, 4, lv_color_grey(), -10);
/*Create an animation to set the value*/
lv_anim_t a;

View File

@@ -22,14 +22,14 @@ void lv_example_meter_2(void)
/*Add a scale first*/
lv_meter_scale_t * scale = lv_meter_add_scale(meter);
lv_meter_set_scale_ticks(meter, scale, 11, 2, 10, LV_COLOR_GRAY);
lv_meter_set_scale_ticks(meter, scale, 11, 2, 10, lv_color_grey());
lv_meter_set_scale_major_ticks(meter, scale, 1, 2, 30, lv_color_hex3(0xeee), 10);
lv_meter_set_scale_range(meter, scale, 0, 100, 270, 90);
/*Add a three arc indicator */
lv_meter_indicator_t * indic1 = lv_meter_add_arc(meter, scale, 10, LV_COLOR_RED, 0);
lv_meter_indicator_t * indic2 = lv_meter_add_arc(meter, scale, 10, LV_COLOR_GREEN, -10);
lv_meter_indicator_t * indic3 = lv_meter_add_arc(meter, scale, 10, LV_COLOR_BLUE, -20);
lv_meter_indicator_t * indic1 = lv_meter_add_arc(meter, scale, 10, lv_color_red(), 0);
lv_meter_indicator_t * indic2 = lv_meter_add_arc(meter, scale, 10, lv_color_green(), -10);
lv_meter_indicator_t * indic3 = lv_meter_add_arc(meter, scale, 10, lv_color_blue(), -20);
/*Create an animation to set the value*/
lv_anim_t a;

View File

@@ -20,13 +20,13 @@ void lv_example_meter_3(void)
/*Create a scale for the minutes*/
/*61 ticks in a 360 degrees range (the last and the first line overlaps)*/
lv_meter_scale_t * scale_min = lv_meter_add_scale(meter);
lv_meter_set_scale_ticks(meter, scale_min, 61, 1, 10, LV_COLOR_GRAY);
lv_meter_set_scale_ticks(meter, scale_min, 61, 1, 10, lv_color_grey());
lv_meter_set_scale_range(meter, scale_min, 0, 60, 360, 270);
/*Create an other scale for the hours. It's only visual and contains only major ticks*/
lv_meter_scale_t * scale_hour = lv_meter_add_scale(meter);
lv_meter_set_scale_ticks(meter, scale_hour, 12, 0, 0, LV_COLOR_GRAY); /*12 ticks*/
lv_meter_set_scale_major_ticks(meter, scale_hour, 1, 2, 20, LV_COLOR_BLACK, 10); /*Every tick is major*/
lv_meter_set_scale_ticks(meter, scale_hour, 12, 0, 0, lv_color_grey()); /*12 ticks*/
lv_meter_set_scale_major_ticks(meter, scale_hour, 1, 2, 20, lv_color_black(), 10); /*Every tick is major*/
lv_meter_set_scale_range(meter, scale_hour, 1, 12, 330, 300); /*[1..12] values in an almost full circle*/
LV_IMG_DECLARE(img_hand)

View File

@@ -15,20 +15,20 @@ void lv_example_meter_4(void)
/*Add a scale first with no ticks.*/
lv_meter_scale_t * scale = lv_meter_add_scale(meter);
lv_meter_set_scale_ticks(meter, scale, 0, 0, 0, LV_COLOR_BLACK);
lv_meter_set_scale_ticks(meter, scale, 0, 0, 0, lv_color_black());
lv_meter_set_scale_range(meter, scale, 0, 100, 360, 0);
/*Add a three arc indicator */
lv_coord_t indic_w = lv_obj_get_width(meter) / 2;
lv_meter_indicator_t * indic1 = lv_meter_add_arc(meter, scale, indic_w, LV_COLOR_ORANGE, 0);
lv_meter_indicator_t * indic1 = lv_meter_add_arc(meter, scale, indic_w, lv_color_orange(), 0);
lv_meter_set_indicator_start_value(meter, indic1, 0);
lv_meter_set_indicator_end_value(meter, indic1, 40);
lv_meter_indicator_t * indic2 = lv_meter_add_arc(meter, scale, indic_w, LV_COLOR_GREEN, 0);
lv_meter_indicator_t * indic2 = lv_meter_add_arc(meter, scale, indic_w, lv_color_green(), 0);
lv_meter_set_indicator_start_value(meter, indic2, 40); /*Start from the previous*/
lv_meter_set_indicator_end_value(meter, indic2, 80);
lv_meter_indicator_t * indic3 = lv_meter_add_arc(meter, scale, indic_w, LV_COLOR_BLUE, 0);
lv_meter_indicator_t * indic3 = lv_meter_add_arc(meter, scale, indic_w, lv_color_blue(), 0);
lv_meter_set_indicator_start_value(meter, indic3, 80); /*Start from the previous*/
lv_meter_set_indicator_end_value(meter, indic3, 100);
}

View File

@@ -12,7 +12,7 @@ void lv_example_obj_1(void)
lv_style_init(&style_shadow);
lv_style_set_shadow_width(&style_shadow, 10);
lv_style_set_shadow_spread(&style_shadow, 5);
lv_style_set_shadow_color(&style_shadow, LV_COLOR_BLUE);
lv_style_set_shadow_color(&style_shadow, lv_color_blue());
lv_obj_t * obj3;
obj3 = lv_obj_create(lv_scr_act(), NULL);

View File

@@ -21,7 +21,7 @@ void lv_example_slider_3(void)
/*Now use only a local style.*/
lv_obj_set_style_content_ofs_y(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, -20);
lv_obj_set_style_content_color(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, LV_COLOR_GRAY);
lv_obj_set_style_content_color(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, lv_color_grey_darken_3());
/*To update the value text*/
lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);

View File

@@ -13,7 +13,7 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
/*Make the texts in the first cell center aligned*/
if(row == 0) {
hook_dsc->label_dsc->align = LV_TEXT_ALIGN_CENTER;
hook_dsc->rect_dsc->bg_color = lv_color_mix(LV_COLOR_BLUE, hook_dsc->rect_dsc->bg_color, LV_OPA_20);
hook_dsc->rect_dsc->bg_color = lv_color_mix(lv_color_blue(), hook_dsc->rect_dsc->bg_color, LV_OPA_20);
hook_dsc->rect_dsc->bg_opa = LV_OPA_COVER;
}
/*In the first column align the texts to the right*/
@@ -23,7 +23,7 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
/*MAke every 2nd row grayish*/
if((row != 0 && row % 2) == 0) {
hook_dsc->rect_dsc->bg_color = lv_color_mix(LV_COLOR_GRAY, hook_dsc->rect_dsc->bg_color, LV_OPA_10);
hook_dsc->rect_dsc->bg_color = lv_color_mix(lv_color_grey(), hook_dsc->rect_dsc->bg_color, LV_OPA_10);
hook_dsc->rect_dsc->bg_opa = LV_OPA_COVER;
}
}