From cbfbcb47f964a8652ea667e01f6a978b3479fee6 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 23 Feb 2021 15:03:06 +0100 Subject: [PATCH] feat(color): use colors from material design Use function instead of color macros --- .../get_started/lv_example_get_started_2.c | 12 +- examples/scroll/lv_example_scroll.h | 2 - examples/styles/lv_example_style_1.c | 4 +- examples/styles/lv_example_style_10.c | 4 +- examples/styles/lv_example_style_11.c | 2 +- examples/styles/lv_example_style_2.c | 4 +- examples/styles/lv_example_style_3.c | 4 +- examples/styles/lv_example_style_4.c | 4 +- examples/styles/lv_example_style_5.c | 4 +- examples/styles/lv_example_style_7.c | 6 +- examples/styles/lv_example_style_8.c | 2 +- examples/styles/lv_example_style_9.c | 6 +- examples/widgets/bar/lv_example_bar_2.c | 4 +- examples/widgets/bar/lv_example_bar_3.c | 6 +- examples/widgets/bar/lv_example_bar_6.c | 4 +- examples/widgets/btn/lv_example_btn_2.c | 10 +- .../btnmatrix/lv_example_btnmatrix_2.c | 14 +- .../btnmatrix/lv_example_btnmatrix_3.c | 2 +- examples/widgets/canvas/lv_example_canvas_1.c | 12 +- examples/widgets/canvas/lv_example_canvas_2.c | 2 +- examples/widgets/chart/lv_example_chart_1.c | 4 +- examples/widgets/chart/lv_example_chart_2.c | 4 +- examples/widgets/chart/lv_example_chart_3.c | 4 +- examples/widgets/chart/lv_example_chart_4.c | 8 +- examples/widgets/img/lv_example_img_2.c | 8 +- examples/widgets/img/lv_example_img_4.c | 4 +- examples/widgets/imgbtn/lv_example_imgbtn_1.c | 4 +- examples/widgets/label/lv_example_label_2.c | 2 +- examples/widgets/led/lv_example_led_1.c | 2 +- examples/widgets/line/lv_example_line_1.c | 2 +- examples/widgets/meter/lv_example_meter_1.c | 10 +- examples/widgets/meter/lv_example_meter_2.c | 8 +- examples/widgets/meter/lv_example_meter_3.c | 6 +- examples/widgets/meter/lv_example_meter_4.c | 8 +- examples/widgets/obj/lv_example_obj_1.c | 2 +- examples/widgets/slider/lv_example_slider_3.c | 2 +- examples/widgets/table/lv_example_table_1.c | 4 +- src/extra/themes/default/lv_theme_default.c | 26 +- src/extra/widgets/calendar/lv_calendar.c | 2 +- src/extra/widgets/led/lv_led.c | 20 +- src/extra/widgets/msgbox/lv_msgbox.c | 2 +- src/lv_core/lv_indev_scroll.c | 4 +- src/lv_core/lv_obj_scroll.c | 37 +-- src/lv_core/lv_obj_scroll.h | 10 - src/lv_core/lv_refr.c | 6 +- src/lv_draw/lv_draw_arc.c | 2 +- src/lv_draw/lv_draw_blend.c | 4 +- src/lv_draw/lv_draw_img.c | 4 +- src/lv_draw/lv_draw_label.c | 6 +- src/lv_draw/lv_draw_line.c | 2 +- src/lv_draw/lv_draw_rect.c | 10 +- src/lv_draw/lv_img_buf.c | 2 +- src/lv_gpu/lv_gpu_nxp_pxp.c | 2 +- src/lv_hal/lv_hal_disp.c | 2 +- src/lv_misc/lv_color.c | 4 +- src/lv_misc/lv_color.h | 300 ++++++++++++++++-- src/lv_misc/lv_style.c | 2 +- src/lv_misc/lv_style.h | 2 +- src/lv_widgets/lv_canvas.c | 4 +- tests/lv_test_core/lv_test_style.c | 54 ++-- 60 files changed, 475 insertions(+), 222 deletions(-) diff --git a/examples/get_started/lv_example_get_started_2.c b/examples/get_started/lv_example_get_started_2.c index cab244907..b222004ed 100644 --- a/examples/get_started/lv_example_get_started_2.c +++ b/examples/get_started/lv_example_get_started_2.c @@ -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); diff --git a/examples/scroll/lv_example_scroll.h b/examples/scroll/lv_example_scroll.h index 740e47b7e..71fb86778 100644 --- a/examples/scroll/lv_example_scroll.h +++ b/examples/scroll/lv_example_scroll.h @@ -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 diff --git a/examples/styles/lv_example_style_1.c b/examples/styles/lv_example_style_1.c index f14218d35..2e978d65c 100644 --- a/examples/styles/lv_example_style_1.c +++ b/examples/styles/lv_example_style_1.c @@ -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*/ diff --git a/examples/styles/lv_example_style_10.c b/examples/styles/lv_example_style_10.c index b3072cce2..417d632a6 100644 --- a/examples/styles/lv_example_style_10.c +++ b/examples/styles/lv_example_style_10.c @@ -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*/ diff --git a/examples/styles/lv_example_style_11.c b/examples/styles/lv_example_style_11.c index 5fe759134..6a95e9634 100644 --- a/examples/styles/lv_example_style_11.c +++ b/examples/styles/lv_example_style_11.c @@ -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); diff --git a/examples/styles/lv_example_style_2.c b/examples/styles/lv_example_style_2.c index 5eb374316..4e0d102f1 100644 --- a/examples/styles/lv_example_style_2.c +++ b/examples/styles/lv_example_style_2.c @@ -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); diff --git a/examples/styles/lv_example_style_3.c b/examples/styles/lv_example_style_3.c index 1e966d61a..f95bf4d4c 100644 --- a/examples/styles/lv_example_style_3.c +++ b/examples/styles/lv_example_style_3.c @@ -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*/ diff --git a/examples/styles/lv_example_style_4.c b/examples/styles/lv_example_style_4.c index ee1afaa77..c0b298c41 100644 --- a/examples/styles/lv_example_style_4.c +++ b/examples/styles/lv_example_style_4.c @@ -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); diff --git a/examples/styles/lv_example_style_5.c b/examples/styles/lv_example_style_5.c index e6a8e6344..2102b7aea 100644 --- a/examples/styles/lv_example_style_5.c +++ b/examples/styles/lv_example_style_5.c @@ -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); diff --git a/examples/styles/lv_example_style_7.c b/examples/styles/lv_example_style_7.c index 54b124cca..e8cd5b906 100644 --- a/examples/styles/lv_example_style_7.c +++ b/examples/styles/lv_example_style_7.c @@ -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); diff --git a/examples/styles/lv_example_style_8.c b/examples/styles/lv_example_style_8.c index c9b5b87d4..f0c0ccfa3 100644 --- a/examples/styles/lv_example_style_8.c +++ b/examples/styles/lv_example_style_8.c @@ -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); diff --git a/examples/styles/lv_example_style_9.c b/examples/styles/lv_example_style_9.c index e0b4b0d83..535ca2f9b 100644 --- a/examples/styles/lv_example_style_9.c +++ b/examples/styles/lv_example_style_9.c @@ -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); diff --git a/examples/widgets/bar/lv_example_bar_2.c b/examples/widgets/bar/lv_example_bar_2.c index d9dc910b2..7d842e5cc 100644 --- a/examples/widgets/bar/lv_example_bar_2.c +++ b/examples/widgets/bar/lv_example_bar_2.c @@ -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); diff --git a/examples/widgets/bar/lv_example_bar_3.c b/examples/widgets/bar/lv_example_bar_3.c index c28415485..1640ee13c 100644 --- a/examples/widgets/bar/lv_example_bar_3.c +++ b/examples/widgets/bar/lv_example_bar_3.c @@ -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); diff --git a/examples/widgets/bar/lv_example_bar_6.c b/examples/widgets/bar/lv_example_bar_6.c index e2aa70175..17715e2a7 100644 --- a/examples/widgets/bar/lv_example_bar_6.c +++ b/examples/widgets/bar/lv_example_bar_6.c @@ -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; diff --git a/examples/widgets/btn/lv_example_btn_2.c b/examples/widgets/btn/lv_example_btn_2.c index c66f603e2..c345ec595 100644 --- a/examples/widgets/btn/lv_example_btn_2.c +++ b/examples/widgets/btn/lv_example_btn_2.c @@ -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); diff --git a/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c b/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c index 0221ffbbc..f2cdc9f2c 100644 --- a/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c +++ b/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c @@ -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); diff --git a/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c b/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c index 871e36735..edbfc39f9 100644 --- a/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c +++ b/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c @@ -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); diff --git a/examples/widgets/canvas/lv_example_canvas_1.c b/examples/widgets/canvas/lv_example_canvas_1.c index e3c451a3a..ce01b8f65 100644 --- a/examples/widgets/canvas/lv_example_canvas_1.c +++ b/examples/widgets/canvas/lv_example_canvas_1.c @@ -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); } diff --git a/examples/widgets/canvas/lv_example_canvas_2.c b/examples/widgets/canvas/lv_example_canvas_2.c index 19c0141b3..49e4f3330 100644 --- a/examples/widgets/canvas/lv_example_canvas_2.c +++ b/examples/widgets/canvas/lv_example_canvas_2.c @@ -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; diff --git a/examples/widgets/chart/lv_example_chart_1.c b/examples/widgets/chart/lv_example_chart_1.c index 8838b616f..d69351da2 100644 --- a/examples/widgets/chart/lv_example_chart_1.c +++ b/examples/widgets/chart/lv_example_chart_1.c @@ -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); diff --git a/examples/widgets/chart/lv_example_chart_2.c b/examples/widgets/chart/lv_example_chart_2.c index 4351477e7..2d05ec555 100644 --- a/examples/widgets/chart/lv_example_chart_2.c +++ b/examples/widgets/chart/lv_example_chart_2.c @@ -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++) { diff --git a/examples/widgets/chart/lv_example_chart_3.c b/examples/widgets/chart/lv_example_chart_3.c index c7b5de872..e076d311e 100644 --- a/examples/widgets/chart/lv_example_chart_3.c +++ b/examples/widgets/chart/lv_example_chart_3.c @@ -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); diff --git a/examples/widgets/chart/lv_example_chart_4.c b/examples/widgets/chart/lv_example_chart_4.c index 59bca7f01..f9bfe5938 100644 --- a/examples/widgets/chart/lv_example_chart_4.c +++ b/examples/widgets/chart/lv_example_chart_4.c @@ -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)); diff --git a/examples/widgets/img/lv_example_img_2.c b/examples/widgets/img/lv_example_img_2.c index d8863b35c..8b56a2821 100644 --- a/examples/widgets/img/lv_example_img_2.c +++ b/examples/widgets/img/lv_example_img_2.c @@ -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); diff --git a/examples/widgets/img/lv_example_img_4.c b/examples/widgets/img/lv_example_img_4.c index 8f4faa221..945ab2fdd 100644 --- a/examples/widgets/img/lv_example_img_4.c +++ b/examples/widgets/img/lv_example_img_4.c @@ -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); diff --git a/examples/widgets/imgbtn/lv_example_imgbtn_1.c b/examples/widgets/imgbtn/lv_example_imgbtn_1.c index 29a3fb904..0771f5ede 100644 --- a/examples/widgets/imgbtn/lv_example_imgbtn_1.c +++ b/examples/widgets/imgbtn/lv_example_imgbtn_1.c @@ -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*/ diff --git a/examples/widgets/label/lv_example_label_2.c b/examples/widgets/label/lv_example_label_2.c index 95b15a50c..d539d765f 100644 --- a/examples/widgets/label/lv_example_label_2.c +++ b/examples/widgets/label/lv_example_label_2.c @@ -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); diff --git a/examples/widgets/led/lv_example_led_1.c b/examples/widgets/led/lv_example_led_1.c index b6de77206..2feece3c5 100644 --- a/examples/widgets/led/lv_example_led_1.c +++ b/examples/widgets/led/lv_example_led_1.c @@ -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()); diff --git a/examples/widgets/line/lv_example_line_1.c b/examples/widgets/line/lv_example_line_1.c index 64c6f3afa..a03910d6b 100644 --- a/examples/widgets/line/lv_example_line_1.c +++ b/examples/widgets/line/lv_example_line_1.c @@ -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*/ diff --git a/examples/widgets/meter/lv_example_meter_1.c b/examples/widgets/meter/lv_example_meter_1.c index 68d754569..6dfedb5c2 100644 --- a/examples/widgets/meter/lv_example_meter_1.c +++ b/examples/widgets/meter/lv_example_meter_1.c @@ -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; diff --git a/examples/widgets/meter/lv_example_meter_2.c b/examples/widgets/meter/lv_example_meter_2.c index c6fde2ea0..d1a0ce592 100644 --- a/examples/widgets/meter/lv_example_meter_2.c +++ b/examples/widgets/meter/lv_example_meter_2.c @@ -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; diff --git a/examples/widgets/meter/lv_example_meter_3.c b/examples/widgets/meter/lv_example_meter_3.c index cce562500..3a889b3a6 100644 --- a/examples/widgets/meter/lv_example_meter_3.c +++ b/examples/widgets/meter/lv_example_meter_3.c @@ -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) diff --git a/examples/widgets/meter/lv_example_meter_4.c b/examples/widgets/meter/lv_example_meter_4.c index c1c84f986..6f9a67765 100644 --- a/examples/widgets/meter/lv_example_meter_4.c +++ b/examples/widgets/meter/lv_example_meter_4.c @@ -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); } diff --git a/examples/widgets/obj/lv_example_obj_1.c b/examples/widgets/obj/lv_example_obj_1.c index 4f2d75fff..a10797d90 100644 --- a/examples/widgets/obj/lv_example_obj_1.c +++ b/examples/widgets/obj/lv_example_obj_1.c @@ -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); diff --git a/examples/widgets/slider/lv_example_slider_3.c b/examples/widgets/slider/lv_example_slider_3.c index a42b23881..009c6f1cd 100644 --- a/examples/widgets/slider/lv_example_slider_3.c +++ b/examples/widgets/slider/lv_example_slider_3.c @@ -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); diff --git a/examples/widgets/table/lv_example_table_1.c b/examples/widgets/table/lv_example_table_1.c index b0321d5a7..c189eabed 100644 --- a/examples/widgets/table/lv_example_table_1.c +++ b/examples/widgets/table/lv_example_table_1.c @@ -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; } } diff --git a/src/extra/themes/default/lv_theme_default.c b/src/extra/themes/default/lv_theme_default.c index 274379f51..d30203209 100644 --- a/src/extra/themes/default/lv_theme_default.c +++ b/src/extra/themes/default/lv_theme_default.c @@ -25,7 +25,7 @@ /*SCREEN*/ //#define COLOR_SCR (IS_LIGHT ? lv_color_hex(0xf5f8fa) : lv_color_hex(0x444b5a)) -#define COLOR_SCR (IS_LIGHT ? lv_color_hex(0xf3f6f7) : lv_color_hex(0x444b5a)) +#define COLOR_SCR (IS_LIGHT ? lv_color_blue_grey_lighten_5() : lv_color_hex(0x444b5a)) #define COLOR_SCR_TEXT (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xe7e9ec)) /*BUTTON*/ @@ -312,14 +312,14 @@ static void style_init(void) style_init_reset(&styles->bg_color_primary); lv_style_set_bg_color(&styles->bg_color_primary, theme.color_primary); - lv_style_set_text_color(&styles->bg_color_primary, LV_COLOR_WHITE); - lv_style_set_content_color(&styles->bg_color_primary, LV_COLOR_WHITE); + lv_style_set_text_color(&styles->bg_color_primary, lv_color_white()); + lv_style_set_content_color(&styles->bg_color_primary, lv_color_white()); lv_style_set_bg_opa(&styles->bg_color_primary, LV_OPA_COVER); style_init_reset(&styles->bg_color_secondary); lv_style_set_bg_color(&styles->bg_color_secondary, theme.color_secondary); - lv_style_set_text_color(&styles->bg_color_secondary, LV_COLOR_WHITE); - lv_style_set_content_color(&styles->bg_color_secondary, LV_COLOR_WHITE); + lv_style_set_text_color(&styles->bg_color_secondary, lv_color_white()); + lv_style_set_content_color(&styles->bg_color_secondary, lv_color_white()); lv_style_set_bg_opa(&styles->bg_color_secondary, LV_OPA_COVER); style_init_reset(&styles->bg_color_gray); @@ -329,7 +329,7 @@ static void style_init(void) lv_style_set_content_color(&styles->bg_color_gray, CARD_TEXT_COLOR); style_init_reset(&styles->bg_color_panel); - lv_style_set_bg_color(&styles->bg_color_panel, LV_COLOR_WHITE); + lv_style_set_bg_color(&styles->bg_color_panel, lv_color_white()); lv_style_set_bg_opa(&styles->bg_color_panel, LV_OPA_COVER); lv_style_set_text_color(&styles->bg_color_panel, CARD_TEXT_COLOR); lv_style_set_content_color(&styles->bg_color_panel, CARD_TEXT_COLOR); @@ -347,7 +347,7 @@ static void style_init(void) #endif style_init_reset(&styles->knob); - lv_style_set_bg_color(&styles->knob, IS_LIGHT ? theme.color_primary : LV_COLOR_WHITE); + lv_style_set_bg_color(&styles->knob, IS_LIGHT ? theme.color_primary : lv_color_white()); lv_style_set_bg_opa(&styles->knob, LV_OPA_COVER); lv_style_set_pad_all(&styles->knob, LV_DPX(5)); lv_style_set_radius(&styles->knob, LV_RADIUS_CIRCLE); @@ -375,13 +375,13 @@ static void style_init(void) lv_style_set_pad_all(&styles->cb_marker, LV_DPX(3)); lv_style_set_border_width(&styles->cb_marker, BORDER_WIDTH); lv_style_set_border_color(&styles->cb_marker, theme.color_primary); - lv_style_set_bg_color(&styles->cb_marker, LV_COLOR_WHITE); + lv_style_set_bg_color(&styles->cb_marker, lv_color_white()); lv_style_set_bg_opa(&styles->cb_marker, LV_OPA_COVER); lv_style_set_radius(&styles->cb_marker, RADIUS_DEFAULT / 2); style_init_reset(&styles->cb_marker_checked); lv_style_set_content_text(&styles->cb_marker_checked, LV_SYMBOL_OK); - lv_style_set_content_color(&styles->cb_marker_checked, LV_COLOR_WHITE); + lv_style_set_content_color(&styles->cb_marker_checked, lv_color_white()); lv_style_set_content_font(&styles->cb_marker_checked, theme.font_small); style_init_reset(&styles->cb_bg_outline_pad); @@ -478,11 +478,11 @@ static void style_init(void) #if LV_USE_LED lv_style_init(&styles->led); lv_style_set_bg_opa(&styles->led, LV_OPA_COVER); - lv_style_set_bg_color(&styles->led, LV_COLOR_WHITE); - lv_style_set_bg_grad_color(&styles->led, LV_COLOR_GRAY); + lv_style_set_bg_color(&styles->led, lv_color_white()); + lv_style_set_bg_grad_color(&styles->led, lv_color_grey()); lv_style_set_radius(&styles->led, LV_RADIUS_CIRCLE); lv_style_set_shadow_width(&styles->led, LV_DPX(15)); - lv_style_set_shadow_color(&styles->led, LV_COLOR_WHITE); + lv_style_set_shadow_color(&styles->led, lv_color_white()); lv_style_set_shadow_spread(&styles->led, LV_DPX(5)); #endif } @@ -880,7 +880,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) static lv_color_t gray_filter(lv_color_t color, lv_opa_t opa) { - return lv_color_mix(LV_COLOR_SILVER, color, opa); + return lv_color_mix(lv_color_grey_lighten_2(), color, opa); } static void style_init_reset(lv_style_t * style) { diff --git a/src/extra/widgets/calendar/lv_calendar.c b/src/extra/widgets/calendar/lv_calendar.c index f654ec916..aa311b40f 100644 --- a/src/extra/widgets/calendar/lv_calendar.c +++ b/src/extra/widgets/calendar/lv_calendar.c @@ -267,7 +267,7 @@ static void draw_event_cb(lv_obj_t * obj, lv_event_t e) else if(lv_btnmatrix_has_btn_ctrl(obj, hook_dsc->id, LV_BTNMATRIX_CTRL_DISABLED)) { hook_dsc->rect_dsc->bg_opa = LV_OPA_TRANSP; hook_dsc->rect_dsc->border_opa = LV_OPA_TRANSP; - hook_dsc->label_dsc->color = LV_COLOR_GRAY; + hook_dsc->label_dsc->color = lv_color_grey(); } if(lv_btnmatrix_has_btn_ctrl(obj, hook_dsc->id, LV_CALENDAR_CTRL_HIGHLIGHT)) { diff --git a/src/extra/widgets/led/lv_led.c b/src/extra/widgets/led/lv_led.c index b65344e7e..ef58f10c4 100644 --- a/src/extra/widgets/led/lv_led.c +++ b/src/extra/widgets/led/lv_led.c @@ -175,18 +175,18 @@ static lv_draw_res_t lv_led_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &rect_dsc); /*Use the original colors brightness to modify color->led*/ - rect_dsc.bg_color = lv_color_mix(led->color, LV_COLOR_BLACK, lv_color_brightness(rect_dsc.bg_color)); - rect_dsc.bg_grad_color = lv_color_mix(led->color, LV_COLOR_BLACK, lv_color_brightness(rect_dsc.bg_grad_color)); - rect_dsc.shadow_color = lv_color_mix(led->color, LV_COLOR_BLACK, lv_color_brightness(rect_dsc.shadow_color)); - rect_dsc.border_color = lv_color_mix(led->color, LV_COLOR_BLACK, lv_color_brightness(rect_dsc.border_color)); - rect_dsc.outline_color = lv_color_mix(led->color, LV_COLOR_BLACK, lv_color_brightness(rect_dsc.outline_color)); + rect_dsc.bg_color = lv_color_mix(led->color, lv_color_black(), lv_color_brightness(rect_dsc.bg_color)); + rect_dsc.bg_grad_color = lv_color_mix(led->color, lv_color_black(), lv_color_brightness(rect_dsc.bg_grad_color)); + rect_dsc.shadow_color = lv_color_mix(led->color, lv_color_black(), lv_color_brightness(rect_dsc.shadow_color)); + rect_dsc.border_color = lv_color_mix(led->color, lv_color_black(), lv_color_brightness(rect_dsc.border_color)); + rect_dsc.outline_color = lv_color_mix(led->color, lv_color_black(), lv_color_brightness(rect_dsc.outline_color)); /*Mix. the color with black proportionally with brightness*/ - rect_dsc.bg_color = lv_color_mix(rect_dsc.bg_color, LV_COLOR_BLACK, led->bright); - rect_dsc.bg_grad_color = lv_color_mix(rect_dsc.bg_grad_color, LV_COLOR_BLACK, led->bright); - rect_dsc.border_color = lv_color_mix(rect_dsc.border_color, LV_COLOR_BLACK, led->bright); - rect_dsc.shadow_color = lv_color_mix(rect_dsc.shadow_color, LV_COLOR_BLACK, led->bright); - rect_dsc.outline_color = lv_color_mix(rect_dsc.outline_color, LV_COLOR_BLACK, led->bright); + rect_dsc.bg_color = lv_color_mix(rect_dsc.bg_color, lv_color_black(), led->bright); + rect_dsc.bg_grad_color = lv_color_mix(rect_dsc.bg_grad_color, lv_color_black(), led->bright); + rect_dsc.border_color = lv_color_mix(rect_dsc.border_color, lv_color_black(), led->bright); + rect_dsc.shadow_color = lv_color_mix(rect_dsc.shadow_color, lv_color_black(), led->bright); + rect_dsc.outline_color = lv_color_mix(rect_dsc.outline_color, lv_color_black(), led->bright); /*Set the current shadow width according to brightness proportionally between LV_LED_BRIGHT_OFF * and LV_LED_BRIGHT_ON*/ diff --git a/src/extra/widgets/msgbox/lv_msgbox.c b/src/extra/widgets/msgbox/lv_msgbox.c index 93f062c0e..968f32d25 100644 --- a/src/extra/widgets/msgbox/lv_msgbox.c +++ b/src/extra/widgets/msgbox/lv_msgbox.c @@ -49,7 +49,7 @@ lv_obj_t * lv_msgbox_create(const char * title, const char * txt, const char * b lv_obj_set_size(parent, LV_SIZE_PCT(100), LV_SIZE_PCT(100)); lv_obj_remove_style(parent, LV_PART_ANY, LV_STATE_ANY, NULL); - lv_obj_set_style_bg_color(parent, LV_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + lv_obj_set_style_bg_color(parent, LV_PART_MAIN, LV_STATE_DEFAULT, lv_color_grey()); lv_obj_set_style_bg_opa(parent, LV_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); lv_obj_t * mbox = lv_obj_create_from_class(&lv_msgbox_class, parent, NULL); diff --git a/src/lv_core/lv_indev_scroll.c b/src/lv_core/lv_indev_scroll.c index 95cae80ad..51bb1fcd1 100644 --- a/src/lv_core/lv_indev_scroll.c +++ b/src/lv_core/lv_indev_scroll.c @@ -123,7 +123,7 @@ void _lv_indev_scroll_throw_handler(lv_indev_proc_t * proc) proc->types.pointer.scroll_throw_vect.y = elastic_diff(scroll_obj, proc->types.pointer.scroll_throw_vect.y, st, sb); - _lv_obj_scroll_by_raw(scroll_obj, 0, proc->types.pointer.scroll_throw_vect.y); + lv_obj_scroll_by(scroll_obj, 0, proc->types.pointer.scroll_throw_vect.y, LV_ANIM_OFF); } /*With snapping find the nearest snap point and scroll there*/ else { @@ -146,7 +146,7 @@ void _lv_indev_scroll_throw_handler(lv_indev_proc_t * proc) proc->types.pointer.scroll_throw_vect.x = elastic_diff(scroll_obj, proc->types.pointer.scroll_throw_vect.x, sl ,sr); - _lv_obj_scroll_by_raw(scroll_obj, proc->types.pointer.scroll_throw_vect.x, 0); + lv_obj_scroll_by(scroll_obj, proc->types.pointer.scroll_throw_vect.x, 0, LV_ANIM_OFF); } /*With snapping find the nearest snap point and scroll there*/ else { diff --git a/src/lv_core/lv_obj_scroll.c b/src/lv_core/lv_obj_scroll.c index 792d07056..0eed38e68 100644 --- a/src/lv_core/lv_obj_scroll.c +++ b/src/lv_core/lv_obj_scroll.c @@ -32,6 +32,7 @@ void lv_obj_move_children_by(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_dif /********************** * STATIC PROTOTYPES **********************/ +static void scroll_by_raw(lv_obj_t * obj, lv_coord_t x, lv_coord_t y); static void scroll_x_anim(void * obj, int32_t v); static void scroll_y_anim(void * obj, int32_t v); static void scroll_anim_ready_cb(lv_anim_t * a); @@ -234,21 +235,6 @@ void lv_obj_get_scroll_end(struct _lv_obj_t * obj, lv_point_t * end) * Other functions *====================*/ -void _lv_obj_scroll_by_raw(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) -{ - if(x == 0 && y == 0) return; - - lv_obj_allocate_spec_attr(obj); - - obj->spec_attr->scroll.x += x; - obj->spec_attr->scroll.y += y; - - lv_obj_move_children_by(obj, x, y); - lv_res_t res = lv_signal_send(obj, LV_SIGNAL_SCROLL, NULL); - if(res != LV_RES_OK) return; - lv_obj_invalidate(obj); -} - void lv_obj_scroll_by(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim_en) { if(x == 0 && y == 0) return; @@ -304,7 +290,7 @@ void lv_obj_scroll_by(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable /*Remove pending animations*/ lv_anim_del(obj, scroll_y_anim); lv_anim_del(obj, scroll_x_anim); - _lv_obj_scroll_by_raw(obj, x, y); + scroll_by_raw(obj, x, y); } } @@ -557,15 +543,30 @@ void lv_obj_scrollbar_invalidate(lv_obj_t * obj) * STATIC FUNCTIONS **********************/ +static void scroll_by_raw(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) +{ + if(x == 0 && y == 0) return; + + lv_obj_allocate_spec_attr(obj); + + obj->spec_attr->scroll.x += x; + obj->spec_attr->scroll.y += y; + + lv_obj_move_children_by(obj, x, y); + lv_res_t res = lv_signal_send(obj, LV_SIGNAL_SCROLL, NULL); + if(res != LV_RES_OK) return; + lv_obj_invalidate(obj); +} + static void scroll_x_anim(void * obj, int32_t v) { - _lv_obj_scroll_by_raw(obj, v + lv_obj_get_scroll_x(obj), 0); + scroll_by_raw(obj, v + lv_obj_get_scroll_x(obj), 0); } static void scroll_y_anim(void * obj, int32_t v) { printf("scrl_anim %d\n", v); - _lv_obj_scroll_by_raw(obj, 0, v + lv_obj_get_scroll_y(obj)); + scroll_by_raw(obj, 0, v + lv_obj_get_scroll_y(obj)); } static void scroll_anim_ready_cb(lv_anim_t * a) diff --git a/src/lv_core/lv_obj_scroll.h b/src/lv_core/lv_obj_scroll.h index d53b2d892..3f2c1cf06 100644 --- a/src/lv_core/lv_obj_scroll.h +++ b/src/lv_core/lv_obj_scroll.h @@ -182,16 +182,6 @@ void lv_obj_get_scroll_end(struct _lv_obj_t * obj, lv_point_t * end); * Other functions *====================*/ -/** - * The most basic function to scroll by a given amount of pixels. - * Used internally. - * @param obj pointer to an object to scroll - * @param x pixels to scroll horizontally - * @param y pixels to scroll vertically - * @note > 0 value means scroll right/bottom (show the more content on the right/bottom) - */ -void _lv_obj_scroll_by_raw(struct _lv_obj_t * obj, lv_coord_t x, lv_coord_t y); - /** * * Scroll by a given amount of pixels diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index c95cce229..0be005627 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -229,8 +229,8 @@ void _lv_disp_refr_task(lv_timer_t * tmr) if(perf_label == NULL) { perf_label = lv_label_create(lv_layer_sys(), NULL); lv_obj_set_style_bg_opa(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_obj_set_style_bg_color(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); - lv_obj_set_style_text_color(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_bg_color(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, lv_color_black()); + lv_obj_set_style_text_color(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, lv_color_white()); lv_obj_set_style_pad_top(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3); lv_obj_set_style_pad_bottom(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3); lv_obj_set_style_pad_left(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3); @@ -646,7 +646,7 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p) lv_event_send(obj, LV_EVENT_DRAW_MAIN_END, &obj_ext_mask); #if MASK_AREA_DEBUG - static lv_color_t debug_color = LV_COLOR_RED; + static lv_color_t debug_color = lv_color_red(); lv_draw_rect_dsc_t draw_dsc; lv_draw_rect_dsc_init(&draw_dsc); draw_dsc.bg_color.full = debug_color.full; diff --git a/src/lv_draw/lv_draw_arc.c b/src/lv_draw/lv_draw_arc.c index 3e8c74e04..941168e97 100644 --- a/src/lv_draw/lv_draw_arc.c +++ b/src/lv_draw/lv_draw_arc.c @@ -64,7 +64,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_arc_dsc_init(lv_draw_arc_dsc_t * dsc) lv_memset_00(dsc, sizeof(lv_draw_arc_dsc_t)); dsc->width = 1; dsc->opa = LV_OPA_COVER; - dsc->color = LV_COLOR_BLACK; + dsc->color = lv_color_black(); } /** diff --git a/src/lv_draw/lv_draw_blend.c b/src/lv_draw/lv_draw_blend.c index e2dccc15a..40a349263 100644 --- a/src/lv_draw/lv_draw_blend.c +++ b/src/lv_draw/lv_draw_blend.c @@ -361,7 +361,7 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co /* Fall down to SW render in case of error */ } #endif - lv_color_t last_dest_color = LV_COLOR_BLACK; + lv_color_t last_dest_color = lv_color_black(); lv_color_t last_res_color = lv_color_mix(color, last_dest_color, opa); uint16_t color_premult[3]; @@ -540,7 +540,7 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co /*Simple fill (maybe with opacity), no masking*/ if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) { - lv_color_t last_dest_color = LV_COLOR_BLACK; + lv_color_t last_dest_color = lv_color_black(); lv_color_t last_res_color = lv_color_mix(color, last_dest_color, opa); for(y = draw_area->y1; y <= draw_area->y2; y++) { for(x = draw_area->x1; x <= draw_area->x2; x++) { diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index 1c205efca..31057ca29 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -57,7 +57,7 @@ static void draw_cleanup(lv_img_cache_entry_t * cache); void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc) { lv_memset_00(dsc, sizeof(lv_draw_img_dsc_t)); - dsc->recolor = LV_COLOR_BLACK; + dsc->recolor = lv_color_black(); dsc->opa = LV_OPA_COVER; dsc->zoom = LV_IMG_ZOOM_NONE; dsc->antialias = LV_COLOR_DEPTH > 8 ? 1 : 0; @@ -632,7 +632,7 @@ static void show_error(const lv_area_t * coords, const lv_area_t * clip_area, co { lv_draw_rect_dsc_t rect_dsc; lv_draw_rect_dsc_init(&rect_dsc); - rect_dsc.bg_color = LV_COLOR_WHITE; + rect_dsc.bg_color = lv_color_white(); lv_draw_rect(coords, clip_area, &rect_dsc); lv_draw_label_dsc_t label_dsc; diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index cb0c18173..ed1db18d5 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -95,12 +95,12 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc) { lv_memset_00(dsc, sizeof(lv_draw_label_dsc_t)); dsc->opa = LV_OPA_COVER; - dsc->color = LV_COLOR_BLACK; + dsc->color = lv_color_black(); dsc->font = LV_THEME_FONT_NORMAL; dsc->sel_start = LV_DRAW_LABEL_NO_TXT_SEL; dsc->sel_end = LV_DRAW_LABEL_NO_TXT_SEL; - dsc->sel_color = LV_COLOR_BLACK; - dsc->sel_bg_color = LV_COLOR_BLUE; + dsc->sel_color = lv_color_black(); + dsc->sel_bg_color = lv_color_blue(); dsc->bidi_dir = LV_BIDI_DIR_LTR; } diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index e85e514da..291fff416 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -53,7 +53,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc) lv_memset_00(dsc, sizeof(lv_draw_line_dsc_t)); dsc->width = 1; dsc->opa = LV_OPA_COVER; - dsc->color = LV_COLOR_BLACK; + dsc->color = lv_color_black(); } /** diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 3d2a05cc9..7088dfa81 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -73,11 +73,11 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(const lv_draw_rect_dsc_t LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc) { lv_memset_00(dsc, sizeof(lv_draw_rect_dsc_t)); - dsc->bg_color = LV_COLOR_WHITE; - dsc->bg_grad_color = LV_COLOR_BLACK; - dsc->border_color = LV_COLOR_BLACK; - dsc->content_color = LV_COLOR_BLACK; - dsc->shadow_color = LV_COLOR_BLACK; + dsc->bg_color = lv_color_white(); + dsc->bg_grad_color = lv_color_black(); + dsc->border_color = lv_color_black(); + dsc->content_color = lv_color_black(); + dsc->shadow_color = lv_color_black(); dsc->bg_grad_color_stop = 0xFF; dsc->bg_opa = LV_OPA_COVER; dsc->bg_img_opa = LV_OPA_COVER; diff --git a/src/lv_draw/lv_img_buf.c b/src/lv_draw/lv_img_buf.c index 90ceb6c66..0161bd266 100644 --- a/src/lv_draw/lv_img_buf.c +++ b/src/lv_draw/lv_img_buf.c @@ -50,7 +50,7 @@ */ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_color_t color) { - lv_color_t p_color = LV_COLOR_BLACK; + lv_color_t p_color = lv_color_black(); uint8_t * buf_u8 = (uint8_t *)dsc->data; if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED || diff --git a/src/lv_gpu/lv_gpu_nxp_pxp.c b/src/lv_gpu/lv_gpu_nxp_pxp.c index b49c35994..98da2cd54 100644 --- a/src/lv_gpu/lv_gpu_nxp_pxp.c +++ b/src/lv_gpu/lv_gpu_nxp_pxp.c @@ -377,7 +377,7 @@ static void lv_gpu_nxp_pxp_blit_recolor(lv_color_t * dest, lv_coord_t dest_width if(colorKeyEnabled) { /* should never get here, recolor & color keying not supported. Draw black box instead. */ const lv_area_t fill_area = {.x1 = 0, .y1 = 0, .x2 = copy_width - 1, .y2 = copy_height - 1}; - lv_gpu_nxp_pxp_fill(dest, dest_width, &fill_area, LV_COLOR_BLACK, LV_OPA_MAX); + lv_gpu_nxp_pxp_fill(dest, dest_width, &fill_area, lv_color_black(), LV_OPA_MAX); LV_LOG_WARN("Recoloring and color keying is not supported. Black rectangle rendered."); return ; } diff --git a/src/lv_hal/lv_hal_disp.c b/src/lv_hal/lv_hal_disp.c index 14b25b880..6cd8335ba 100644 --- a/src/lv_hal/lv_hal_disp.c +++ b/src/lv_hal/lv_hal_disp.c @@ -126,7 +126,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) disp->inv_p = 0; disp->last_activity_time = 0; - disp->bg_color = LV_COLOR_WHITE; + disp->bg_color = lv_color_white(); disp->bg_img = NULL; #if LV_COLOR_SCREEN_TRANSP disp->bg_opa = LV_OPA_TRANSP; diff --git a/src/lv_misc/lv_color.c b/src/lv_misc/lv_color.c index 0354df63e..47032bffb 100644 --- a/src/lv_misc/lv_color.c +++ b/src/lv_misc/lv_color.c @@ -124,12 +124,12 @@ LV_ATTRIBUTE_FAST_MEM void lv_color_fill(lv_color_t * buf, lv_color_t color, uin lv_color_t lv_color_lighten(lv_color_t c, lv_opa_t lvl) { - return lv_color_mix(LV_COLOR_WHITE, c, lvl); + return lv_color_mix(lv_color_white(), c, lvl); } lv_color_t lv_color_darken(lv_color_t c, lv_opa_t lvl) { - return lv_color_mix(LV_COLOR_BLACK, c, lvl); + return lv_color_mix(lv_color_black(), c, lvl); } lv_color_t lv_color_change_lightness(lv_color_t c, lv_opa_t lvl) diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index 919d2f5bf..d2190188a 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -35,24 +35,6 @@ extern "C" { /********************* * DEFINES *********************/ -#define LV_COLOR_WHITE LV_COLOR_MAKE(0xFF, 0xFF, 0xFF) -#define LV_COLOR_SILVER LV_COLOR_MAKE(0xC0, 0xC0, 0xC0) -#define LV_COLOR_GRAY LV_COLOR_MAKE(0x80, 0x80, 0x80) -#define LV_COLOR_BLACK LV_COLOR_MAKE(0x00, 0x00, 0x00) -#define LV_COLOR_RED LV_COLOR_MAKE(0xFF, 0x00, 0x00) -#define LV_COLOR_MAROON LV_COLOR_MAKE(0x80, 0x00, 0x00) -#define LV_COLOR_YELLOW LV_COLOR_MAKE(0xFF, 0xFF, 0x00) -#define LV_COLOR_OLIVE LV_COLOR_MAKE(0x80, 0x80, 0x00) -#define LV_COLOR_LIME LV_COLOR_MAKE(0x00, 0xFF, 0x00) -#define LV_COLOR_GREEN LV_COLOR_MAKE(0x00, 0x80, 0x00) -#define LV_COLOR_CYAN LV_COLOR_MAKE(0x00, 0xFF, 0xFF) -#define LV_COLOR_AQUA LV_COLOR_CYAN -#define LV_COLOR_TEAL LV_COLOR_MAKE(0x00, 0x80, 0x80) -#define LV_COLOR_BLUE LV_COLOR_MAKE(0x00, 0x00, 0xFF) -#define LV_COLOR_NAVY LV_COLOR_MAKE(0x00, 0x00, 0x80) -#define LV_COLOR_MAGENTA LV_COLOR_MAKE(0xFF, 0x00, 0xFF) -#define LV_COLOR_PURPLE LV_COLOR_MAKE(0x80, 0x00, 0x80) -#define LV_COLOR_ORANGE LV_COLOR_MAKE(0xFF, 0xA5, 0x00) /** * Opacity percentages. @@ -638,6 +620,288 @@ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8); */ lv_color_hsv_t lv_color_to_hsv(lv_color_t color); + +/********************** + * PREDEFINED COLORS + **********************/ +/* Source: https://vuetifyjs.com/en/styles/colors/#material-colors */ + +static inline lv_color_t lv_color_red(void) { return lv_color_hex(0xF44336); } +static inline lv_color_t lv_color_red_lighten_5(void) { return lv_color_hex(0xFFEBEE); } +static inline lv_color_t lv_color_red_lighten_4(void) { return lv_color_hex(0xFFCDD2); } +static inline lv_color_t lv_color_red_lighten_3(void) { return lv_color_hex(0xEF9A9A); } +static inline lv_color_t lv_color_red_lighten_2(void) { return lv_color_hex(0xE57373); } +static inline lv_color_t lv_color_red_lighten_1(void) { return lv_color_hex(0xEF5350); } +static inline lv_color_t lv_color_red_darken_1(void) { return lv_color_hex(0xE53935); } +static inline lv_color_t lv_color_red_darken_2(void) { return lv_color_hex(0xD32F2F); } +static inline lv_color_t lv_color_red_darken_3(void) { return lv_color_hex(0xC62828); } +static inline lv_color_t lv_color_red_darken_4(void) { return lv_color_hex(0xB71C1C); } +static inline lv_color_t lv_color_red_accent_1(void) { return lv_color_hex(0xFF8A80); } +static inline lv_color_t lv_color_red_accent_2(void) { return lv_color_hex(0xFF5252); } +static inline lv_color_t lv_color_red_accent_3(void) { return lv_color_hex(0xFF1744); } +static inline lv_color_t lv_color_red_accent_4(void) { return lv_color_hex(0xD50000); } + +static inline lv_color_t lv_color_pink(void) { return lv_color_hex(0xE91E63); } +static inline lv_color_t lv_color_pink_lighten_5(void) { return lv_color_hex(0xFCE4EC); } +static inline lv_color_t lv_color_pink_lighten_4(void) { return lv_color_hex(0xF8BBD0); } +static inline lv_color_t lv_color_pink_lighten_3(void) { return lv_color_hex(0xF48FB1); } +static inline lv_color_t lv_color_pink_lighten_2(void) { return lv_color_hex(0xF06292); } +static inline lv_color_t lv_color_pink_lighten_1(void) { return lv_color_hex(0xEC407A); } +static inline lv_color_t lv_color_pink_darken_1(void) { return lv_color_hex(0xD81B60); } +static inline lv_color_t lv_color_pink_darken_2(void) { return lv_color_hex(0xC2185B); } +static inline lv_color_t lv_color_pink_darken_3(void) { return lv_color_hex(0xAD1457); } +static inline lv_color_t lv_color_pink_darken_4(void) { return lv_color_hex(0x880E4F); } +static inline lv_color_t lv_color_pink_accent_1(void) { return lv_color_hex(0xFF80AB); } +static inline lv_color_t lv_color_pink_accent_2(void) { return lv_color_hex(0xFF4081); } +static inline lv_color_t lv_color_pink_accent_3(void) { return lv_color_hex(0xF50057); } +static inline lv_color_t lv_color_pink_accent_4(void) { return lv_color_hex(0xC51162); } + +static inline lv_color_t lv_color_purple(void) { return lv_color_hex(0x9C27B0); } +static inline lv_color_t lv_color_purple_lighten_5(void) { return lv_color_hex(0xF3E5F5); } +static inline lv_color_t lv_color_purple_lighten_4(void) { return lv_color_hex(0xE1BEE7); } +static inline lv_color_t lv_color_purple_lighten_3(void) { return lv_color_hex(0xCE93D8); } +static inline lv_color_t lv_color_purple_lighten_2(void) { return lv_color_hex(0xBA68C8); } +static inline lv_color_t lv_color_purple_lighten_1(void) { return lv_color_hex(0xAB47BC); } +static inline lv_color_t lv_color_purple_darken_1(void) { return lv_color_hex(0x8E24AA); } +static inline lv_color_t lv_color_purple_darken_2(void) { return lv_color_hex(0x7B1FA2); } +static inline lv_color_t lv_color_purple_darken_3(void) { return lv_color_hex(0x6A1B9A); } +static inline lv_color_t lv_color_purple_darken_4(void) { return lv_color_hex(0x4A148C); } +static inline lv_color_t lv_color_purple_accent_1(void) { return lv_color_hex(0xEA80FC); } +static inline lv_color_t lv_color_purple_accent_2(void) { return lv_color_hex(0xE040FB); } +static inline lv_color_t lv_color_purple_accent_3(void) { return lv_color_hex(0xD500F9); } +static inline lv_color_t lv_color_purple_accent_4(void) { return lv_color_hex(0xAA00FF); } + +static inline lv_color_t lv_color_deep_purple(void) { return lv_color_hex(0x673AB7); } +static inline lv_color_t lv_color_deep_purple_lighten_5(void) { return lv_color_hex(0xEDE7F6); } +static inline lv_color_t lv_color_deep_purple_lighten_4(void) { return lv_color_hex(0xD1C4E9); } +static inline lv_color_t lv_color_deep_purple_lighten_3(void) { return lv_color_hex(0xB39DDB); } +static inline lv_color_t lv_color_deep_purple_lighten_2(void) { return lv_color_hex(0x9575CD); } +static inline lv_color_t lv_color_deep_purple_lighten_1(void) { return lv_color_hex(0x7E57C2); } +static inline lv_color_t lv_color_deep_purple_darken_1(void) { return lv_color_hex(0x5E35B1); } +static inline lv_color_t lv_color_deep_purple_darken_2(void) { return lv_color_hex(0x512DA8); } +static inline lv_color_t lv_color_deep_purple_darken_3(void) { return lv_color_hex(0x4527A0); } +static inline lv_color_t lv_color_deep_purple_darken_4(void) { return lv_color_hex(0x311B92); } +static inline lv_color_t lv_color_deep_purple_accent_1(void) { return lv_color_hex(0xB388FF); } +static inline lv_color_t lv_color_deep_purple_accent_2(void) { return lv_color_hex(0x7C4DFF); } +static inline lv_color_t lv_color_deep_purple_accent_3(void) { return lv_color_hex(0x651FFF); } +static inline lv_color_t lv_color_deep_purple_accent_4(void) { return lv_color_hex(0x6200EA); } + +static inline lv_color_t lv_color_indigo(void) { return lv_color_hex(0x3F51B5); } +static inline lv_color_t lv_color_indigo_lighten_5(void) { return lv_color_hex(0xE8EAF6); } +static inline lv_color_t lv_color_indigo_lighten_4(void) { return lv_color_hex(0xC5CAE9); } +static inline lv_color_t lv_color_indigo_lighten_3(void) { return lv_color_hex(0x9FA8DA); } +static inline lv_color_t lv_color_indigo_lighten_2(void) { return lv_color_hex(0x7986CB); } +static inline lv_color_t lv_color_indigo_lighten_1(void) { return lv_color_hex(0x5C6BC0); } +static inline lv_color_t lv_color_indigo_darken_1(void) { return lv_color_hex(0x3949AB); } +static inline lv_color_t lv_color_indigo_darken_2(void) { return lv_color_hex(0x303F9F); } +static inline lv_color_t lv_color_indigo_darken_3(void) { return lv_color_hex(0x283593); } +static inline lv_color_t lv_color_indigo_darken_4(void) { return lv_color_hex(0x1A237E); } +static inline lv_color_t lv_color_indigo_accent_1(void) { return lv_color_hex(0x8C9EFF); } +static inline lv_color_t lv_color_indigo_accent_2(void) { return lv_color_hex(0x536DFE); } +static inline lv_color_t lv_color_indigo_accent_3(void) { return lv_color_hex(0x3D5AFE); } +static inline lv_color_t lv_color_indigo_accent_4(void) { return lv_color_hex(0x304FFE); } + +static inline lv_color_t lv_color_blue(void) { return lv_color_hex(0x2196F3); } +static inline lv_color_t lv_color_blue_lighten_5(void) { return lv_color_hex(0xE3F2FD); } +static inline lv_color_t lv_color_blue_lighten_4(void) { return lv_color_hex(0xBBDEFB); } +static inline lv_color_t lv_color_blue_lighten_3(void) { return lv_color_hex(0x90CAF9); } +static inline lv_color_t lv_color_blue_lighten_2(void) { return lv_color_hex(0x64B5F6); } +static inline lv_color_t lv_color_blue_lighten_1(void) { return lv_color_hex(0x42A5F5); } +static inline lv_color_t lv_color_blue_darken_1(void) { return lv_color_hex(0x1E88E5); } +static inline lv_color_t lv_color_blue_darken_2(void) { return lv_color_hex(0x1976D2); } +static inline lv_color_t lv_color_blue_darken_3(void) { return lv_color_hex(0x1565C0); } +static inline lv_color_t lv_color_blue_darken_4(void) { return lv_color_hex(0x0D47A1); } +static inline lv_color_t lv_color_blue_accent_1(void) { return lv_color_hex(0x82B1FF); } +static inline lv_color_t lv_color_blue_accent_2(void) { return lv_color_hex(0x448AFF); } +static inline lv_color_t lv_color_blue_accent_3(void) { return lv_color_hex(0x2979FF); } +static inline lv_color_t lv_color_blue_accent_4(void) { return lv_color_hex(0x2962FF); } + +static inline lv_color_t lv_color_light_blue(void) { return lv_color_hex(0x03A9F4); } +static inline lv_color_t lv_color_light_blue_lighten_5(void) { return lv_color_hex(0xE1F5FE); } +static inline lv_color_t lv_color_light_blue_lighten_4(void) { return lv_color_hex(0xB3E5FC); } +static inline lv_color_t lv_color_light_blue_lighten_3(void) { return lv_color_hex(0x81D4FA); } +static inline lv_color_t lv_color_light_blue_lighten_2(void) { return lv_color_hex(0x4FC3F7); } +static inline lv_color_t lv_color_light_blue_lighten_1(void) { return lv_color_hex(0x29B6F6); } +static inline lv_color_t lv_color_light_blue_darken_1(void) { return lv_color_hex(0x039BE5); } +static inline lv_color_t lv_color_light_blue_darken_2(void) { return lv_color_hex(0x0288D1); } +static inline lv_color_t lv_color_light_blue_darken_3(void) { return lv_color_hex(0x0277BD); } +static inline lv_color_t lv_color_light_blue_darken_4(void) { return lv_color_hex(0x01579B); } +static inline lv_color_t lv_color_light_blue_accent_1(void) { return lv_color_hex(0x80D8FF); } +static inline lv_color_t lv_color_light_blue_accent_2(void) { return lv_color_hex(0x40C4FF); } +static inline lv_color_t lv_color_light_blue_accent_3(void) { return lv_color_hex(0x00B0FF); } +static inline lv_color_t lv_color_light_blue_accent_4(void) { return lv_color_hex(0x0091EA); } + +static inline lv_color_t lv_color_cyan(void) { return lv_color_hex(0x00BCD4); } +static inline lv_color_t lv_color_cyan_lighten_5(void) { return lv_color_hex(0xE0F7FA); } +static inline lv_color_t lv_color_cyan_lighten_4(void) { return lv_color_hex(0xB2EBF2); } +static inline lv_color_t lv_color_cyan_lighten_3(void) { return lv_color_hex(0x80DEEA); } +static inline lv_color_t lv_color_cyan_lighten_2(void) { return lv_color_hex(0x4DD0E1); } +static inline lv_color_t lv_color_cyan_lighten_1(void) { return lv_color_hex(0x26C6DA); } +static inline lv_color_t lv_color_cyan_darken_1(void) { return lv_color_hex(0x00ACC1); } +static inline lv_color_t lv_color_cyan_darken_2(void) { return lv_color_hex(0x0097A7); } +static inline lv_color_t lv_color_cyan_darken_3(void) { return lv_color_hex(0x00838F); } +static inline lv_color_t lv_color_cyan_darken_4(void) { return lv_color_hex(0x006064); } +static inline lv_color_t lv_color_cyan_accent_1(void) { return lv_color_hex(0x84FFFF); } +static inline lv_color_t lv_color_cyan_accent_2(void) { return lv_color_hex(0x18FFFF); } +static inline lv_color_t lv_color_cyan_accent_3(void) { return lv_color_hex(0x00E5FF); } +static inline lv_color_t lv_color_cyan_accent_4(void) { return lv_color_hex(0x00B8D4); } + +static inline lv_color_t lv_color_teal(void) { return lv_color_hex(0x009688); } +static inline lv_color_t lv_color_teal_lighten_5(void) { return lv_color_hex(0xE0F2F1); } +static inline lv_color_t lv_color_teal_lighten_4(void) { return lv_color_hex(0xB2DFDB); } +static inline lv_color_t lv_color_teal_lighten_3(void) { return lv_color_hex(0x80CBC4); } +static inline lv_color_t lv_color_teal_lighten_2(void) { return lv_color_hex(0x4DB6AC); } +static inline lv_color_t lv_color_teal_lighten_1(void) { return lv_color_hex(0x26A69A); } +static inline lv_color_t lv_color_teal_darken_1(void) { return lv_color_hex(0x00897B); } +static inline lv_color_t lv_color_teal_darken_2(void) { return lv_color_hex(0x00796B); } +static inline lv_color_t lv_color_teal_darken_3(void) { return lv_color_hex(0x00695C); } +static inline lv_color_t lv_color_teal_darken_4(void) { return lv_color_hex(0x004D40); } +static inline lv_color_t lv_color_teal_accent_1(void) { return lv_color_hex(0xA7FFEB); } +static inline lv_color_t lv_color_teal_accent_2(void) { return lv_color_hex(0x64FFDA); } +static inline lv_color_t lv_color_teal_accent_3(void) { return lv_color_hex(0x1DE9B6); } +static inline lv_color_t lv_color_teal_accent_4(void) { return lv_color_hex(0x00BFA5); } + +static inline lv_color_t lv_color_green(void) { return lv_color_hex(0x4CAF50); } +static inline lv_color_t lv_color_green_lighten_5(void) { return lv_color_hex(0xE8F5E9); } +static inline lv_color_t lv_color_green_lighten_4(void) { return lv_color_hex(0xC8E6C9); } +static inline lv_color_t lv_color_green_lighten_3(void) { return lv_color_hex(0xA5D6A7); } +static inline lv_color_t lv_color_green_lighten_2(void) { return lv_color_hex(0x81C784); } +static inline lv_color_t lv_color_green_lighten_1(void) { return lv_color_hex(0x66BB6A); } +static inline lv_color_t lv_color_green_darken_1(void) { return lv_color_hex(0x43A047); } +static inline lv_color_t lv_color_green_darken_2(void) { return lv_color_hex(0x388E3C); } +static inline lv_color_t lv_color_green_darken_3(void) { return lv_color_hex(0x2E7D32); } +static inline lv_color_t lv_color_green_darken_4(void) { return lv_color_hex(0x1B5E20); } +static inline lv_color_t lv_color_green_accent_1(void) { return lv_color_hex(0xB9F6CA); } +static inline lv_color_t lv_color_green_accent_2(void) { return lv_color_hex(0x69F0AE); } +static inline lv_color_t lv_color_green_accent_3(void) { return lv_color_hex(0x00E676); } +static inline lv_color_t lv_color_green_accent_4(void) { return lv_color_hex(0x00C853); } + +static inline lv_color_t lv_color_light_green(void) { return lv_color_hex(0x8BC34A); } +static inline lv_color_t lv_color_light_green_lighten_5(void) { return lv_color_hex(0xF1F8E9); } +static inline lv_color_t lv_color_light_green_lighten_4(void) { return lv_color_hex(0xDCEDC8); } +static inline lv_color_t lv_color_light_green_lighten_3(void) { return lv_color_hex(0xC5E1A5); } +static inline lv_color_t lv_color_light_green_lighten_2(void) { return lv_color_hex(0xAED581); } +static inline lv_color_t lv_color_light_green_lighten_1(void) { return lv_color_hex(0x9CCC65); } +static inline lv_color_t lv_color_light_green_darken_1(void) { return lv_color_hex(0x7CB342); } +static inline lv_color_t lv_color_light_green_darken_2(void) { return lv_color_hex(0x689F38); } +static inline lv_color_t lv_color_light_green_darken_3(void) { return lv_color_hex(0x558B2F); } +static inline lv_color_t lv_color_light_green_darken_4(void) { return lv_color_hex(0x33691E); } +static inline lv_color_t lv_color_light_green_accent_1(void) { return lv_color_hex(0xCCFF90); } +static inline lv_color_t lv_color_light_green_accent_2(void) { return lv_color_hex(0xB2FF59); } +static inline lv_color_t lv_color_light_green_accent_3(void) { return lv_color_hex(0x76FF03); } +static inline lv_color_t lv_color_light_green_accent_4(void) { return lv_color_hex(0x64DD17); } + +static inline lv_color_t lv_color_lime(void) { return lv_color_hex(0xCDDC39); } +static inline lv_color_t lv_color_lime_lighten_5(void) { return lv_color_hex(0xF9FBE7); } +static inline lv_color_t lv_color_lime_lighten_4(void) { return lv_color_hex(0xF0F4C3); } +static inline lv_color_t lv_color_lime_lighten_3(void) { return lv_color_hex(0xE6EE9C); } +static inline lv_color_t lv_color_lime_lighten_2(void) { return lv_color_hex(0xDCE775); } +static inline lv_color_t lv_color_lime_lighten_1(void) { return lv_color_hex(0xD4E157); } +static inline lv_color_t lv_color_lime_darken_1(void) { return lv_color_hex(0xC0CA33); } +static inline lv_color_t lv_color_lime_darken_2(void) { return lv_color_hex(0xAFB42B); } +static inline lv_color_t lv_color_lime_darken_3(void) { return lv_color_hex(0x9E9D24); } +static inline lv_color_t lv_color_lime_darken_4(void) { return lv_color_hex(0x827717); } +static inline lv_color_t lv_color_lime_accent_1(void) { return lv_color_hex(0xF4FF81); } +static inline lv_color_t lv_color_lime_accent_2(void) { return lv_color_hex(0xEEFF41); } +static inline lv_color_t lv_color_lime_accent_3(void) { return lv_color_hex(0xC6FF00); } +static inline lv_color_t lv_color_lime_accent_4(void) { return lv_color_hex(0xAEEA00); } + +static inline lv_color_t lv_color_yellow(void) { return lv_color_hex(0xFFEB3B); } +static inline lv_color_t lv_color_yellow_lighten_5(void) { return lv_color_hex(0xFFFDE7); } +static inline lv_color_t lv_color_yellow_lighten_4(void) { return lv_color_hex(0xFFF9C4); } +static inline lv_color_t lv_color_yellow_lighten_3(void) { return lv_color_hex(0xFFF59D); } +static inline lv_color_t lv_color_yellow_lighten_2(void) { return lv_color_hex(0xFFF176); } +static inline lv_color_t lv_color_yellow_lighten_1(void) { return lv_color_hex(0xFFEE58); } +static inline lv_color_t lv_color_yellow_darken_1(void) { return lv_color_hex(0xFDD835); } +static inline lv_color_t lv_color_yellow_darken_2(void) { return lv_color_hex(0xFBC02D); } +static inline lv_color_t lv_color_yellow_darken_3(void) { return lv_color_hex(0xF9A825); } +static inline lv_color_t lv_color_yellow_darken_4(void) { return lv_color_hex(0xF57F17); } +static inline lv_color_t lv_color_yellow_accent_1(void) { return lv_color_hex(0xFFFF8D); } +static inline lv_color_t lv_color_yellow_accent_2(void) { return lv_color_hex(0xFFFF00); } +static inline lv_color_t lv_color_yellow_accent_3(void) { return lv_color_hex(0xFFEA00); } +static inline lv_color_t lv_color_yellow_accent_4(void) { return lv_color_hex(0xFFD600); } + +static inline lv_color_t lv_color_amber(void) { return lv_color_hex(0xFFC107); } +static inline lv_color_t lv_color_amber_lighten_5(void) { return lv_color_hex(0xFFF8E1); } +static inline lv_color_t lv_color_amber_lighten_4(void) { return lv_color_hex(0xFFECB3); } +static inline lv_color_t lv_color_amber_lighten_3(void) { return lv_color_hex(0xFFE082); } +static inline lv_color_t lv_color_amber_lighten_2(void) { return lv_color_hex(0xFFD54F); } +static inline lv_color_t lv_color_amber_lighten_1(void) { return lv_color_hex(0xFFCA28); } +static inline lv_color_t lv_color_amber_darken_1(void) { return lv_color_hex(0xFFB300); } +static inline lv_color_t lv_color_amber_darken_2(void) { return lv_color_hex(0xFFA000); } +static inline lv_color_t lv_color_amber_darken_3(void) { return lv_color_hex(0xFF8F00); } +static inline lv_color_t lv_color_amber_darken_4(void) { return lv_color_hex(0xFF6F00); } +static inline lv_color_t lv_color_amber_accent_1(void) { return lv_color_hex(0xFFE57F); } +static inline lv_color_t lv_color_amber_accent_2(void) { return lv_color_hex(0xFFD740); } +static inline lv_color_t lv_color_amber_accent_3(void) { return lv_color_hex(0xFFC400); } +static inline lv_color_t lv_color_amber_accent_4(void) { return lv_color_hex(0xFFAB00); } + +static inline lv_color_t lv_color_orange(void) { return lv_color_hex(0xFF9800); } +static inline lv_color_t lv_color_orange_lighten_5(void) { return lv_color_hex(0xFFF3E0); } +static inline lv_color_t lv_color_orange_lighten_4(void) { return lv_color_hex(0xFFE0B2); } +static inline lv_color_t lv_color_orange_lighten_3(void) { return lv_color_hex(0xFFCC80); } +static inline lv_color_t lv_color_orange_lighten_2(void) { return lv_color_hex(0xFFB74D); } +static inline lv_color_t lv_color_orange_lighten_1(void) { return lv_color_hex(0xFFA726); } +static inline lv_color_t lv_color_orange_darken_1(void) { return lv_color_hex(0xFB8C00); } +static inline lv_color_t lv_color_orange_darken_2(void) { return lv_color_hex(0xF57C00); } +static inline lv_color_t lv_color_orange_darken_3(void) { return lv_color_hex(0xEF6C00); } +static inline lv_color_t lv_color_orange_darken_4(void) { return lv_color_hex(0xE65100); } +static inline lv_color_t lv_color_orange_accent_1(void) { return lv_color_hex(0xFFD180); } +static inline lv_color_t lv_color_orange_accent_2(void) { return lv_color_hex(0xFFAB40); } +static inline lv_color_t lv_color_orange_accent_3(void) { return lv_color_hex(0xFF9100); } +static inline lv_color_t lv_color_orange_accent_4(void) { return lv_color_hex(0xFF6D00); } + +static inline lv_color_t lv_color_deep_orange(void) { return lv_color_hex(0xFF5722); } +static inline lv_color_t lv_color_deep_orange_lighten_5(void) { return lv_color_hex(0xFBE9E7); } +static inline lv_color_t lv_color_deep_orange_lighten_4(void) { return lv_color_hex(0xFFCCBC); } +static inline lv_color_t lv_color_deep_orange_lighten_3(void) { return lv_color_hex(0xFFAB91); } +static inline lv_color_t lv_color_deep_orange_lighten_2(void) { return lv_color_hex(0xFF8A65); } +static inline lv_color_t lv_color_deep_orange_lighten_1(void) { return lv_color_hex(0xFF7043); } +static inline lv_color_t lv_color_deep_orange_darken_1(void) { return lv_color_hex(0xF4511E); } +static inline lv_color_t lv_color_deep_orange_darken_2(void) { return lv_color_hex(0xE64A19); } +static inline lv_color_t lv_color_deep_orange_darken_3(void) { return lv_color_hex(0xD84315); } +static inline lv_color_t lv_color_deep_orange_darken_4(void) { return lv_color_hex(0xBF360C); } +static inline lv_color_t lv_color_deep_orange_accent_1(void) { return lv_color_hex(0xFF9E80); } +static inline lv_color_t lv_color_deep_orange_accent_2(void) { return lv_color_hex(0xFF6E40); } +static inline lv_color_t lv_color_deep_orange_accent_3(void) { return lv_color_hex(0xFF3D00); } +static inline lv_color_t lv_color_deep_orange_accent_4(void) { return lv_color_hex(0xDD2C00); } + +static inline lv_color_t lv_color_brown(void) { return lv_color_hex(0x795548); } +static inline lv_color_t lv_color_brown_lighten_5(void) { return lv_color_hex(0xEFEBE9); } +static inline lv_color_t lv_color_brown_lighten_4(void) { return lv_color_hex(0xD7CCC8); } +static inline lv_color_t lv_color_brown_lighten_3(void) { return lv_color_hex(0xBCAAA4); } +static inline lv_color_t lv_color_brown_lighten_2(void) { return lv_color_hex(0xA1887F); } +static inline lv_color_t lv_color_brown_lighten_1(void) { return lv_color_hex(0x8D6E63); } +static inline lv_color_t lv_color_brown_darken_1(void) { return lv_color_hex(0x6D4C41); } +static inline lv_color_t lv_color_brown_darken_2(void) { return lv_color_hex(0x5D4037); } +static inline lv_color_t lv_color_brown_darken_3(void) { return lv_color_hex(0x4E342E); } +static inline lv_color_t lv_color_brown_darken_4(void) { return lv_color_hex(0x3E2723); } + +static inline lv_color_t lv_color_blue_grey(void) { return lv_color_hex(0x607D8B); } +static inline lv_color_t lv_color_blue_grey_lighten_5(void) { return lv_color_hex(0xECEFF1); } +static inline lv_color_t lv_color_blue_grey_lighten_4(void) { return lv_color_hex(0xCFD8DC); } +static inline lv_color_t lv_color_blue_grey_lighten_3(void) { return lv_color_hex(0xB0BEC5); } +static inline lv_color_t lv_color_blue_grey_lighten_2(void) { return lv_color_hex(0x90A4AE); } +static inline lv_color_t lv_color_blue_grey_lighten_1(void) { return lv_color_hex(0x78909C); } +static inline lv_color_t lv_color_blue_grey_darken_1(void) { return lv_color_hex(0x546E7A); } +static inline lv_color_t lv_color_blue_grey_darken_2(void) { return lv_color_hex(0x455A64); } +static inline lv_color_t lv_color_blue_grey_darken_3(void) { return lv_color_hex(0x37474F); } +static inline lv_color_t lv_color_blue_grey_darken_4(void) { return lv_color_hex(0x263238); } + +static inline lv_color_t lv_color_grey(void) { return lv_color_hex(0x9E9E9E); } +static inline lv_color_t lv_color_grey_lighten_5(void) { return lv_color_hex(0xFAFAFA); } +static inline lv_color_t lv_color_grey_lighten_4(void) { return lv_color_hex(0xF5F5F5); } +static inline lv_color_t lv_color_grey_lighten_3(void) { return lv_color_hex(0xEEEEEE); } +static inline lv_color_t lv_color_grey_lighten_2(void) { return lv_color_hex(0xE0E0E0); } +static inline lv_color_t lv_color_grey_lighten_1(void) { return lv_color_hex(0xBDBDBD); } +static inline lv_color_t lv_color_grey_darken_1(void) { return lv_color_hex(0x757575); } +static inline lv_color_t lv_color_grey_darken_2(void) { return lv_color_hex(0x616161); } +static inline lv_color_t lv_color_grey_darken_3(void) { return lv_color_hex(0x424242); } +static inline lv_color_t lv_color_grey_darken_4(void) { return lv_color_hex(0x212121); } + +static inline lv_color_t lv_color_white(void) { return lv_color_hex(0xFFFFFF); } +static inline lv_color_t lv_color_black(void) { return lv_color_hex(0x000000); } + /********************** * MACROS **********************/ diff --git a/src/lv_misc/lv_style.c b/src/lv_misc/lv_style.c index e420efb03..32c4d929f 100644 --- a/src/lv_misc/lv_style.c +++ b/src/lv_misc/lv_style.c @@ -224,7 +224,7 @@ lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop) value.num = LV_IMG_ZOOM_NONE; break; case LV_STYLE_BG_COLOR: - value.color = LV_COLOR_WHITE; + value.color = lv_color_white(); break; case LV_STYLE_OPA: case LV_STYLE_BORDER_OPA: diff --git a/src/lv_misc/lv_style.h b/src/lv_misc/lv_style.h index 3ea7bfb12..d65cbc29f 100644 --- a/src/lv_misc/lv_style.h +++ b/src/lv_misc/lv_style.h @@ -295,7 +295,7 @@ void lv_style_reset(lv_style_t * style); * ... * MY_PROP = lv_style_register_prop; * ... - * lv_style_set_my_prop(&style1, LV_COLOR_RED); + * lv_style_set_my_prop(&style1, lv_color_red()); */ lv_style_prop_t lv_style_register_prop(void); diff --git a/src/lv_widgets/lv_canvas.c b/src/lv_widgets/lv_canvas.c index 92a415efe..9b10efde0 100644 --- a/src/lv_widgets/lv_canvas.c +++ b/src/lv_widgets/lv_canvas.c @@ -371,7 +371,7 @@ void lv_canvas_blur_hor(lv_obj_t * obj, const lv_area_t * area, uint16_t r) x_safe = x + 1 + r_front; x_safe = x_safe > canvas->dsc.header.w - 1 ? canvas->dsc.header.w - 1 : x_safe; - c = lv_img_buf_get_px_color(&line_img, x_safe, 0, LV_COLOR_RED); + c = lv_img_buf_get_px_color(&line_img, x_safe, 0, lv_color_white()); if(has_alpha) opa = lv_img_buf_get_px_alpha(&line_img, x_safe, 0); rsum += c.ch.red; @@ -1018,7 +1018,7 @@ static void set_px_true_color_alpha(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_ d.header.w = buf_w; d.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA; - lv_color_t bg_color = lv_img_buf_get_px_color(&d, x, y, LV_COLOR_BLACK); + lv_color_t bg_color = lv_img_buf_get_px_color(&d, x, y, lv_color_black()); lv_opa_t bg_opa = lv_img_buf_get_px_alpha(&d, x, y); lv_opa_t res_opa; diff --git a/tests/lv_test_core/lv_test_style.c b/tests/lv_test_core/lv_test_style.c index ae6456d34..1a9109a45 100644 --- a/tests/lv_test_core/lv_test_style.c +++ b/tests/lv_test_core/lv_test_style.c @@ -128,7 +128,7 @@ typedef int _keep_pedantic_happy; // _lv_style_set_int(&style, LV_STYLE_TEXT_LINE_SPACE, 5); // _lv_style_set_opa(&style, LV_STYLE_BG_OPA, LV_OPA_50); // _lv_style_set_ptr(&style, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL); -// _lv_style_set_color(&style, LV_STYLE_BG_COLOR, LV_COLOR_RED); +// _lv_style_set_color(&style, LV_STYLE_BG_COLOR, lv_color_red()); // // found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); // lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'int' property"); @@ -144,7 +144,7 @@ typedef int _keep_pedantic_happy; // // found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); // lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'color' property"); -// lv_test_assert_color_eq(LV_COLOR_RED, color, "Get the value of a 'color' property"); +// lv_test_assert_color_eq(lv_color_red(), color, "Get the value of a 'color' property"); // // lv_test_print("Reset the style"); // lv_style_reset(&style); @@ -192,7 +192,7 @@ typedef int _keep_pedantic_happy; // _lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE, 5); // _lv_style_set_opa(&style_first, LV_STYLE_BG_OPA, LV_OPA_50); // _lv_style_set_ptr(&style_first, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL); -// _lv_style_set_color(&style_first, LV_STYLE_BG_COLOR, LV_COLOR_RED); +// _lv_style_set_color(&style_first, LV_STYLE_BG_COLOR, lv_color_red()); // // found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); // lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property"); @@ -208,14 +208,14 @@ typedef int _keep_pedantic_happy; // // found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); // lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'color' property"); -// lv_test_assert_color_eq(LV_COLOR_RED, color, "Get the value of a 'color' property"); +// lv_test_assert_color_eq(lv_color_red(), color, "Get the value of a 'color' property"); // // lv_test_print("Overwrite the properties from the second style"); // // _lv_style_set_int(&style_second, LV_STYLE_TEXT_LINE_SPACE, 10); // _lv_style_set_opa(&style_second, LV_STYLE_BG_OPA, LV_OPA_60); // _lv_style_set_ptr(&style_second, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 1); -// _lv_style_set_color(&style_second, LV_STYLE_BG_COLOR, LV_COLOR_BLUE); +// _lv_style_set_color(&style_second, LV_STYLE_BG_COLOR, lv_color_blue()); // // found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value); // lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'int' property"); @@ -231,7 +231,7 @@ typedef int _keep_pedantic_happy; // // found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color); // lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'color' property"); -// lv_test_assert_color_eq(LV_COLOR_BLUE, color, "Get the value of an overwritten 'color' property"); +// lv_test_assert_color_eq(lv_color_blue(), color, "Get the value of an overwritten 'color' property"); // // lv_test_print("Overwrite the properties with the local style"); // _lv_style_list_set_local_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, 20); @@ -375,9 +375,9 @@ typedef int _keep_pedantic_happy; // // lv_test_print("Test state precedence in 2 styles"); // _lv_style_set_color(&style_first, LV_STYLE_BG_COLOR, LV_COLOR_YELLOW); -// _lv_style_set_color(&style_first, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED) << LV_STYLE_STATE_POS, LV_COLOR_RED); +// _lv_style_set_color(&style_first, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED) << LV_STYLE_STATE_POS, lv_color_red()); // _lv_style_set_color(&style_second, LV_STYLE_BG_COLOR | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, LV_COLOR_LIME); -// _lv_style_set_color(&style_second, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_COLOR_BLUE); +// _lv_style_set_color(&style_second, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, lv_color_blue()); // // lv_color_t color; // @@ -387,7 +387,7 @@ typedef int _keep_pedantic_happy; // // found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED) << LV_STYLE_STATE_POS, &color); // lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in hovered state"); -// lv_test_assert_color_eq(LV_COLOR_RED, color, "Get the value of a 'color' in hovered state"); +// lv_test_assert_color_eq(lv_color_red(), color, "Get the value of a 'color' in hovered state"); // // found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, &color); // lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in checked state"); @@ -395,7 +395,7 @@ typedef int _keep_pedantic_happy; // // found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, &color); // lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in hover pressed state"); -// lv_test_assert_color_eq(LV_COLOR_BLUE, color, "Get the value of a 'color' in hover pressed state"); +// lv_test_assert_color_eq(lv_color_blue(), color, "Get the value of a 'color' in hover pressed state"); // // found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, &color); // lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in edit (unspecified) state"); @@ -436,16 +436,16 @@ typedef int _keep_pedantic_happy; // lv_test_print("Set style properties"); // lv_mem_monitor(&mon_start); // for(i = 0; i < 100; i++) { -// _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, lv_color_red()); // -// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_RED); -// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, LV_COLOR_BLUE); -// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_BLUE); +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, lv_color_red()); +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, lv_color_blue()); +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, lv_color_blue()); // _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED | LV_STATE_FOCUSED) << LV_STYLE_STATE_POS, LV_COLOR_GREEN); // -// _lv_style_set_color(&style3, LV_STYLE_BG_COLOR, LV_COLOR_RED); +// _lv_style_set_color(&style3, LV_STYLE_BG_COLOR, lv_color_red()); // -// _lv_style_set_color(&style3, LV_STYLE_IMAGE_RECOLOR, LV_COLOR_RED); +// _lv_style_set_color(&style3, LV_STYLE_IMAGE_RECOLOR, lv_color_red()); // // lv_style_reset(&style1); // lv_style_reset(&style2); @@ -485,9 +485,9 @@ typedef int _keep_pedantic_happy; // lv_test_print("Add styles"); // lv_mem_monitor(&mon_start); // for(i = 0; i < 100; i++) { -// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_RED); -// _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, LV_COLOR_RED); -// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, lv_color_red()); +// _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, lv_color_red()); +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, lv_color_red()); // // _lv_style_list_add_style(&style_list, &style1); // _lv_style_list_remove_style(&style_list, &style1); @@ -512,11 +512,11 @@ typedef int _keep_pedantic_happy; // lv_test_print("Add styles and use local style"); // lv_mem_monitor(&mon_start); // for(i = 0; i < 100; i++) { -// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_RED); -// _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, LV_COLOR_RED); -// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, lv_color_red()); +// _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, lv_color_red()); +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, lv_color_red()); // -// if(i % 2 == 0) _lv_style_list_set_local_color(&style_list, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// if(i % 2 == 0) _lv_style_list_set_local_color(&style_list, LV_STYLE_LINE_COLOR, lv_color_red()); // // _lv_style_list_add_style(&style_list, &style1); // _lv_style_list_remove_style(&style_list, &style1); @@ -527,7 +527,7 @@ typedef int _keep_pedantic_happy; // _lv_style_list_remove_style(&style_list, &style2); // _lv_style_list_add_style(&style_list, &style1); // -// if(i % 2 != 0) _lv_style_list_set_local_color(&style_list, LV_STYLE_LINE_COLOR, LV_COLOR_RED); +// if(i % 2 != 0) _lv_style_list_set_local_color(&style_list, LV_STYLE_LINE_COLOR, lv_color_red()); // // _lv_style_list_reset(&style_list); // lv_style_reset(&style1); @@ -549,9 +549,9 @@ typedef int _keep_pedantic_happy; // _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE); // } // -// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_RED); -// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, LV_COLOR_BLUE); -// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_BLUE); +// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, lv_color_red()); +// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, lv_color_blue()); +// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, lv_color_blue()); // _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED | LV_STATE_FOCUSED) << LV_STYLE_STATE_POS, LV_COLOR_GREEN); // // _lv_style_list_add_style(&style_list, &style1);