From 070df61eb2be5d4478191808c90fca2abb906436 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 23 Apr 2021 12:46:14 +0200 Subject: [PATCH] refactor(color) refactor the palette API --- .../get_started/lv_example_get_started_2.c | 14 +- examples/styles/lv_example_style_1.c | 4 +- examples/styles/lv_example_style_10.c | 2 +- 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_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/btn/lv_example_btn_2.c | 12 +- .../btnmatrix/lv_example_btnmatrix_2.c | 8 +- .../btnmatrix/lv_example_btnmatrix_3.c | 2 +- examples/widgets/canvas/lv_example_canvas_1.c | 10 +- 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 | 4 +- examples/widgets/chart/lv_example_chart_5.c | 2 +- examples/widgets/chart/lv_example_chart_6.c | 6 +- examples/widgets/img/lv_example_img_2.c | 8 +- examples/widgets/img/lv_example_img_4.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 | 12 +- examples/widgets/meter/lv_example_meter_2.c | 8 +- examples/widgets/meter/lv_example_meter_3.c | 4 +- examples/widgets/meter/lv_example_meter_4.c | 6 +- examples/widgets/obj/lv_example_obj_1.c | 2 +- examples/widgets/table/lv_example_table_1.c | 4 +- examples/widgets/table/lv_example_table_2.c | 2 +- src/core/lv_theme.c | 12 +- src/core/lv_theme.h | 8 +- src/draw/lv_draw_label.c | 2 +- src/extra/themes/basic/lv_theme_basic.c | 6 +- src/extra/themes/default/lv_theme_default.c | 36 +- src/extra/themes/default/lv_theme_default.h | 2 +- src/extra/widgets/calendar/lv_calendar.c | 2 +- src/extra/widgets/msgbox/lv_msgbox.c | 2 +- src/hal/lv_hal_disp.c | 2 +- src/misc/lv_color.c | 334 +++++------------- src/misc/lv_color.h | 281 ++------------- src/misc/lv_style.h | 2 +- tests/lv_test_core/lv_test_style.c | 54 +-- 47 files changed, 271 insertions(+), 640 deletions(-) diff --git a/examples/get_started/lv_example_get_started_2.c b/examples/get_started/lv_example_get_started_2.c index 03be645a6..f23495e5e 100644 --- a/examples/get_started/lv_example_get_started_2.c +++ b/examples/get_started/lv_example_get_started_2.c @@ -14,8 +14,8 @@ 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_grey_lighten_3()); - lv_style_set_bg_grad_color(&style_btn, lv_color_grey()); + lv_style_set_bg_color(&style_btn, lv_palette_lighten(LV_PALETTE_GREY, 3)); + lv_style_set_bg_grad_color(&style_btn, lv_palette_main(LV_PALETTE_GREY)); lv_style_set_bg_grad_dir(&style_btn, LV_GRAD_DIR_VER); /*Add a border*/ @@ -28,13 +28,13 @@ void lv_example_get_started_2(void) /*Create a red style. Change only some colors.*/ lv_style_init(&style_btn_red); - lv_style_set_bg_color(&style_btn_red, lv_color_light_blue()); - lv_style_set_bg_grad_color(&style_btn_red, lv_color_light_blue_darken_3()); + lv_style_set_bg_color(&style_btn_red, lv_palette_main(LV_PALETTE_RED)); + lv_style_set_bg_grad_color(&style_btn_red, lv_palette_lighten(LV_PALETTE_RED, 2)); - /*Create a style for the pressed state. Add color filter to make every color darker*/ + /*Create a style for the pressed state.*/ lv_style_init(&style_btn_pressed); - lv_style_set_bg_color(&style_btn_red, lv_color_blue()); - lv_style_set_bg_grad_color(&style_btn_red, lv_color_blue_darken_3()); + lv_style_set_bg_color(&style_btn_pressed, lv_palette_main(LV_PALETTE_BLUE)); + lv_style_set_bg_grad_color(&style_btn_pressed, lv_palette_darken(LV_PALETTE_RED, 3)); /*Create a button and use the new styles*/ lv_obj_t * btn = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/ diff --git a/examples/styles/lv_example_style_1.c b/examples/styles/lv_example_style_1.c index eed41f227..108946b3f 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_grey_lighten_3()); - lv_style_set_bg_grad_color(&style, lv_color_blue()); + lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 3)); + lv_style_set_bg_grad_color(&style, lv_palette_main(LV_PALETTE_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 e46d35823..1e53bb2b8 100644 --- a/examples/styles/lv_example_style_10.c +++ b/examples/styles/lv_example_style_10.c @@ -15,7 +15,7 @@ typedef int _keep_pedantic_happy; // 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_grey()); +// lv_style_set_bg_color(&style, LV_STATE_PRESSED, lv_palette_main(LV_PALETTE_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 b5e7c2db2..c6267c2cf 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_palette_main(LV_PALETTE_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 e5a46c1f3..3ef34b389 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_grey_lighten_3()); + lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 3)); /*Add border to the bottom+right*/ - lv_style_set_border_color(&style, lv_color_blue()); + lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_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 ae7b6d125..4df900a67 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_grey_lighten_3()); + lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 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_palette_main(LV_PALETTE_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 4a587229b..1a8d5451b 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_grey_lighten_3()); + lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 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_palette_main(LV_PALETTE_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_7.c b/examples/styles/lv_example_style_7.c index c1d4260c1..97d551a47 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_grey_lighten_3()); + lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 3)); lv_style_set_border_width(&style, 2); - lv_style_set_border_color(&style, lv_color_blue()); + lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_BLUE)); lv_style_set_pad_all(&style, 10); - lv_style_set_text_color(&style, lv_color_blue()); + lv_style_set_text_color(&style, lv_palette_main(LV_PALETTE_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 bb4d2b385..5eefef9b3 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_grey()); + lv_style_set_line_color(&style, lv_palette_main(LV_PALETTE_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 8c1599528..40c1181c8 100644 --- a/examples/styles/lv_example_style_9.c +++ b/examples/styles/lv_example_style_9.c @@ -12,11 +12,11 @@ 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_grey_lighten_3()); + lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 3)); lv_style_set_border_width(&style, 2); - lv_style_set_border_color(&style, lv_color_blue()); + lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_BLUE)); - lv_style_set_img_recolor(&style, lv_color_blue()); + lv_style_set_img_recolor(&style, lv_palette_main(LV_PALETTE_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 4e8390169..2688cc2d9 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_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_BLUE)); lv_style_set_radius(&style_indic, 3); lv_obj_t * bar = lv_bar_create(lv_scr_act()); diff --git a/examples/widgets/bar/lv_example_bar_3.c b/examples/widgets/bar/lv_example_bar_3.c index 9484dc7a4..79cdd4cf8 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_palette_main(LV_PALETTE_RED)); + lv_style_set_bg_grad_color(&style_indic, lv_palette_main(LV_PALETTE_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_grey()); +// lv_style_set_content_color(&style_indic, lv_palette_main(LV_PALETTE_GREY)); lv_obj_t * bar = lv_bar_create(lv_scr_act()); lv_obj_add_style(bar, &style_indic, LV_PART_INDICATOR); diff --git a/examples/widgets/btn/lv_example_btn_2.c b/examples/widgets/btn/lv_example_btn_2.c index 179857efd..d232a8f40 100644 --- a/examples/widgets/btn/lv_example_btn_2.c +++ b/examples/widgets/btn/lv_example_btn_2.c @@ -14,7 +14,7 @@ void lv_example_btn_2(void) static lv_style_t style; lv_style_init(&style); lv_style_set_outline_opa(&style, LV_OPA_COVER); - lv_style_set_outline_color(&style, lv_color_blue()); + lv_style_set_outline_color(&style, lv_palette_main(LV_PALETTE_BLUE)); static lv_style_t style_pr; lv_style_init(&style_pr); @@ -27,16 +27,16 @@ void lv_example_btn_2(void) // lv_style_set_radius(&style, 3); // // lv_style_set_bg_opa(&style, LV_OPA_100); -// lv_style_set_bg_color(&style, lv_color_blue()); +// lv_style_set_bg_color(&style, lv_palette_main(LV_PALETTE_BLUE)); // lv_style_set_bg_grad_color(&style, lv_color_blue_darken_2()); // 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_grey()); +// lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_GREY)); // // lv_style_set_shadow_width(&style, 8); -// lv_style_set_shadow_color(&style, lv_color_grey()); +// lv_style_set_shadow_color(&style, lv_palette_main(LV_PALETTE_GREY)); // lv_style_set_shadow_ofs_y(&style, 8); // // lv_style_set_text_color(&style, lv_color_white()); @@ -46,8 +46,8 @@ void lv_example_btn_2(void) /*Init the pressed style*/ lv_style_set_shadow_ofs_y(&style_pr, 3); - lv_style_set_bg_color(&style_pr, lv_color_blue_darken_2()); - lv_style_set_bg_grad_color(&style_pr, lv_color_blue_darken_4()); + lv_style_set_bg_color(&style_pr, lv_palette_darken(LV_PALETTE_BLUE, 2)); + lv_style_set_bg_grad_color(&style_pr, lv_palette_darken(LV_PALETTE_BLUE, 4)); lv_obj_t * btn1 = lv_btn_create(lv_scr_act()); // lv_obj_remove_style(btn1, LV_PART_ANY, LV_STATE_ANY, NULL); diff --git a/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c b/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c index 9be774ce3..67cd23e44 100644 --- a/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c +++ b/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c @@ -12,8 +12,8 @@ static void event_cb(lv_event_t * e) /*Change the draw descriptor the 2nd button*/ if(dsc->id == 1) { dsc->rect_dsc->radius = 0; - if(lv_btnmatrix_get_selected_btn(obj) == dsc->id) dsc->rect_dsc->bg_color = lv_color_blue_darken_3(); - else dsc->rect_dsc->bg_color = lv_color_blue(); + if(lv_btnmatrix_get_selected_btn(obj) == dsc->id) dsc->rect_dsc->bg_color = lv_palette_darken(LV_PALETTE_GREY, 3); + else dsc->rect_dsc->bg_color = lv_palette_main(LV_PALETTE_BLUE); dsc->rect_dsc->shadow_width = 6; dsc->rect_dsc->shadow_ofs_x = 3; @@ -23,8 +23,8 @@ static void event_cb(lv_event_t * e) /*Change the draw descriptor the 3rd button*/ else if(dsc->id == 2) { dsc->rect_dsc->radius = LV_RADIUS_CIRCLE; - if(lv_btnmatrix_get_selected_btn(obj) == dsc->id) dsc->rect_dsc->bg_color = lv_color_red_darken_3(); - else dsc->rect_dsc->bg_color = lv_color_red(); + if(lv_btnmatrix_get_selected_btn(obj) == dsc->id) dsc->rect_dsc->bg_color = lv_palette_darken(LV_PALETTE_RED, 3); + else dsc->rect_dsc->bg_color = lv_palette_main(LV_PALETTE_RED); dsc->label_dsc->color = lv_color_white(); } diff --git a/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c b/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c index f35043d0e..242e98d7e 100644 --- a/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c +++ b/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c @@ -40,7 +40,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_grey()); + lv_style_set_border_color(&style_btn, lv_palette_main(LV_PALETTE_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 c60a16db7..1a421ac10 100644 --- a/examples/widgets/canvas/lv_example_canvas_1.c +++ b/examples/widgets/canvas/lv_example_canvas_1.c @@ -12,8 +12,8 @@ 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_palette_main(LV_PALETTE_RED); + rect_dsc.bg_grad_color = lv_palette_main(LV_PALETTE_BLUE); rect_dsc.border_width = 2; rect_dsc.border_opa = LV_OPA_90; rect_dsc.border_color = lv_color_white(); @@ -23,14 +23,14 @@ void lv_example_canvas_1(void) lv_draw_label_dsc_t label_dsc; lv_draw_label_dsc_init(&label_dsc); - label_dsc.color = lv_color_yellow(); + label_dsc.color = lv_palette_main(LV_PALETTE_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()); lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_TRUE_COLOR); lv_obj_center(canvas); - lv_canvas_fill_bg(canvas, lv_color_grey_lighten_3(), LV_OPA_COVER); + lv_canvas_fill_bg(canvas, lv_palette_lighten(LV_PALETTE_GREY, 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_grey_lighten_3(), LV_OPA_COVER); + lv_canvas_fill_bg(canvas, lv_palette_lighten(LV_PALETTE_GREY, 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 a25322911..e6d387879 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()); 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_palette_main(LV_PALETTE_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 96bf7d561..710698217 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_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y); + lv_chart_series_t * ser2 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_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 63a430432..4e648ff96 100644 --- a/examples/widgets/chart/lv_example_chart_2.c +++ b/examples/widgets/chart/lv_example_chart_2.c @@ -69,8 +69,8 @@ void lv_example_chart_2(void) lv_chart_set_update_mode(chart1, LV_CHART_UPDATE_MODE_CIRCULAR); /*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_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y); + ser2 = lv_chart_add_series(chart1, lv_palette_main(LV_PALETTE_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 ab41e0703..8dec5591b 100644 --- a/examples/widgets/chart/lv_example_chart_3.c +++ b/examples/widgets/chart/lv_example_chart_3.c @@ -35,8 +35,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_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); + lv_chart_series_t * ser1 = lv_chart_add_series(chart, lv_palette_lighten(LV_PALETTE_GREEN, 2), LV_CHART_AXIS_PRIMARY_Y); + lv_chart_series_t * ser2 = lv_chart_add_series(chart, lv_palette_darken(LV_PALETTE_GREEN, 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 4d86c986e..e1f9cf48b 100644 --- a/examples/widgets/chart/lv_example_chart_4.c +++ b/examples/widgets/chart/lv_example_chart_4.c @@ -71,8 +71,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_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y); + lv_chart_series_t * ser2 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_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/chart/lv_example_chart_5.c b/examples/widgets/chart/lv_example_chart_5.c index 552c12018..f384d79f0 100644 --- a/examples/widgets/chart/lv_example_chart_5.c +++ b/examples/widgets/chart/lv_example_chart_5.c @@ -76,7 +76,7 @@ void lv_example_chart_5(void) /*Do not display points on the data*/ lv_obj_set_style_size(chart, 0, LV_PART_INDICATOR); - lv_chart_series_t * ser = lv_chart_add_series(chart, lv_color_red(), LV_CHART_AXIS_PRIMARY_Y); + lv_chart_series_t * ser = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y); uint32_t pcnt = sizeof(ecg_sample) / sizeof(ecg_sample[0]); lv_chart_set_point_count(chart, pcnt); diff --git a/examples/widgets/chart/lv_example_chart_6.c b/examples/widgets/chart/lv_example_chart_6.c index dda8c6519..a4d2dd6eb 100644 --- a/examples/widgets/chart/lv_example_chart_6.c +++ b/examples/widgets/chart/lv_example_chart_6.c @@ -38,7 +38,7 @@ static void event_cb(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_blue(); + draw_rect_dsc.bg_color = lv_palette_main(LV_PALETTE_BLUE); draw_rect_dsc.radius = 3; lv_draw_rect(&a, dsc->clip_area, &draw_rect_dsc); @@ -70,9 +70,9 @@ void lv_example_chart_6(void) lv_obj_add_event_cb(chart, event_cb, LV_EVENT_ALL, NULL); lv_obj_refresh_ext_draw_size(chart); - cursor = lv_chart_add_cursor(chart, lv_color_blue(), LV_DIR_LEFT | LV_DIR_BOTTOM); + cursor = lv_chart_add_cursor(chart, lv_palette_main(LV_PALETTE_BLUE), LV_DIR_LEFT | LV_DIR_BOTTOM); - ser = lv_chart_add_series(chart, lv_color_red(), LV_CHART_AXIS_PRIMARY_Y); + ser = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y); uint32_t i; for(i = 0; i < 10; i++) { lv_chart_set_next_value(chart, ser, lv_rand(10,90)); diff --git a/examples/widgets/img/lv_example_img_2.c b/examples/widgets/img/lv_example_img_2.c index 2d62da7fc..756ef0312 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_green()); - blue_slider = create_slider(lv_color_blue()); - intense_slider = create_slider(lv_color_grey()); + red_slider = create_slider(lv_palette_main(LV_PALETTE_RED)); + green_slider = create_slider(lv_palette_main(LV_PALETTE_GREEN)); + blue_slider = create_slider(lv_palette_main(LV_PALETTE_BLUE)); + intense_slider = create_slider(lv_palette_main(LV_PALETTE_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 38f9ab05f..3abc021f2 100644 --- a/examples/widgets/img/lv_example_img_4.c +++ b/examples/widgets/img/lv_example_img_4.c @@ -15,7 +15,7 @@ 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_palette_main(LV_PALETTE_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()); diff --git a/examples/widgets/led/lv_example_led_1.c b/examples/widgets/led/lv_example_led_1.c index 183c48ce1..f06f31ef2 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, 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_palette_main(LV_PALETTE_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 07057349e..9c120a293 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_palette_main(LV_PALETTE_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 61f79b50c..1fdaea987 100644 --- a/examples/widgets/meter/lv_example_meter_1.c +++ b/examples/widgets/meter/lv_example_meter_1.c @@ -18,33 +18,33 @@ 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_grey()); + lv_meter_set_scale_ticks(meter, scale, 51, 2, 10, lv_palette_main(LV_PALETTE_GREY)); lv_meter_set_scale_major_ticks(meter, scale, 10, 4, 15, lv_color_black(), 10); lv_meter_indicator_t * indic; /*Add a blue arc to the start*/ - indic = lv_meter_add_arc(meter, scale, 3, lv_color_blue(), 0); + indic = lv_meter_add_arc(meter, scale, 3, lv_palette_main(LV_PALETTE_BLUE), 0); lv_meter_set_indicator_start_value(meter, indic, 0); lv_meter_set_indicator_end_value(meter, indic, 20); /*Make the tick lines blue at the start of the scale*/ - indic = lv_meter_add_scale_lines(meter, scale, lv_color_blue(), lv_color_blue(), false, 0); + indic = lv_meter_add_scale_lines(meter, scale, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_BLUE), false, 0); lv_meter_set_indicator_start_value(meter, indic, 0); lv_meter_set_indicator_end_value(meter, indic, 20); /*Add a red arc to the end*/ - indic = lv_meter_add_arc(meter, scale, 3, lv_color_red(), 0); + indic = lv_meter_add_arc(meter, scale, 3, lv_palette_main(LV_PALETTE_RED), 0); 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_palette_main(LV_PALETTE_RED), lv_palette_main(LV_PALETTE_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_grey(), -10); + indic = lv_meter_add_needle_line(meter, scale, 4, lv_palette_main(LV_PALETTE_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 1be0e639f..ef3c24935 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_grey()); + lv_meter_set_scale_ticks(meter, scale, 11, 2, 10, lv_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_RED), 0); + lv_meter_indicator_t * indic2 = lv_meter_add_arc(meter, scale, 10, lv_palette_main(LV_PALETTE_GREEN), -10); + lv_meter_indicator_t * indic3 = lv_meter_add_arc(meter, scale, 10, lv_palette_main(LV_PALETTE_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 10e965bc1..6ad367f5a 100644 --- a/examples/widgets/meter/lv_example_meter_3.c +++ b/examples/widgets/meter/lv_example_meter_3.c @@ -20,12 +20,12 @@ 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_grey()); + lv_meter_set_scale_ticks(meter, scale_min, 61, 1, 10, lv_palette_main(LV_PALETTE_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_grey()); /*12 ticks*/ + lv_meter_set_scale_ticks(meter, scale_hour, 12, 0, 0, lv_palette_main(LV_PALETTE_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*/ diff --git a/examples/widgets/meter/lv_example_meter_4.c b/examples/widgets/meter/lv_example_meter_4.c index 15543ced9..7580cc840 100644 --- a/examples/widgets/meter/lv_example_meter_4.c +++ b/examples/widgets/meter/lv_example_meter_4.c @@ -20,15 +20,15 @@ void lv_example_meter_4(void) /*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_palette_main(LV_PALETTE_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_yellow(), 0); + lv_meter_indicator_t * indic2 = lv_meter_add_arc(meter, scale, indic_w, lv_palette_main(LV_PALETTE_YELLOW), 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_deep_orange(), 0); + lv_meter_indicator_t * indic3 = lv_meter_add_arc(meter, scale, indic_w, lv_palette_main(LV_PALETTE_DEEP_ORANGE), 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 133718871..5cc7571da 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_palette_main(LV_PALETTE_BLUE)); lv_obj_t * obj3; obj3 = lv_obj_create(lv_scr_act()); diff --git a/examples/widgets/table/lv_example_table_1.c b/examples/widgets/table/lv_example_table_1.c index cd2b80a39..3c32ad34f 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 draw_part_event_cb(lv_event_t * e) /*Make the texts in the first cell center aligned*/ if(row == 0) { dsc->label_dsc->align = LV_TEXT_ALIGN_CENTER; - dsc->rect_dsc->bg_color = lv_color_mix(lv_color_blue(), dsc->rect_dsc->bg_color, LV_OPA_20); + dsc->rect_dsc->bg_color = lv_color_mix(lv_palette_main(LV_PALETTE_BLUE), dsc->rect_dsc->bg_color, LV_OPA_20); dsc->rect_dsc->bg_opa = LV_OPA_COVER; } /*In the first column align the texts to the right*/ @@ -23,7 +23,7 @@ static void draw_part_event_cb(lv_event_t * e) /*MAke every 2nd row grayish*/ if((row != 0 && row % 2) == 0) { - dsc->rect_dsc->bg_color = lv_color_mix(lv_color_grey(), dsc->rect_dsc->bg_color, LV_OPA_10); + dsc->rect_dsc->bg_color = lv_color_mix(lv_palette_main(LV_PALETTE_GREY), dsc->rect_dsc->bg_color, LV_OPA_10); dsc->rect_dsc->bg_opa = LV_OPA_COVER; } } diff --git a/examples/widgets/table/lv_example_table_2.c b/examples/widgets/table/lv_example_table_2.c index 39e151df9..bb44600e2 100644 --- a/examples/widgets/table/lv_example_table_2.c +++ b/examples/widgets/table/lv_example_table_2.c @@ -13,7 +13,7 @@ static void draw_event_cb(lv_event_t * e) lv_draw_rect_dsc_t rect_dsc; lv_draw_rect_dsc_init(&rect_dsc); - rect_dsc.bg_color = chk ? lv_theme_get_color_primary(obj) : lv_color_grey_lighten_2(); + rect_dsc.bg_color = chk ? lv_theme_get_color_primary(obj) : lv_palette_lighten(LV_PALETTE_GREY, 2); rect_dsc.radius = LV_RADIUS_CIRCLE; lv_area_t sw_area; diff --git a/src/core/lv_theme.c b/src/core/lv_theme.c index 4117c2425..9bd3fab6d 100644 --- a/src/core/lv_theme.c +++ b/src/core/lv_theme.c @@ -95,28 +95,28 @@ const lv_font_t * lv_theme_get_font_large(lv_obj_t * obj) return th ? th->font_large : LV_FONT_DEFAULT; } -lv_color_palette_t lv_theme_get_palette_primary(lv_obj_t * obj) +lv_palette_t lv_theme_get_palette_primary(lv_obj_t * obj) { lv_theme_t * th = lv_theme_get_from_obj(obj); - return th ? th->palette_primary : LV_COLOR_PALETTE_BLUE_GREY; + return th ? th->palette_primary : LV_PALETTE_BLUE_GREY; } -lv_color_palette_t lv_theme_get_palette_secondary(lv_obj_t * obj) +lv_palette_t lv_theme_get_palette_secondary(lv_obj_t * obj) { lv_theme_t * th = lv_theme_get_from_obj(obj); - return th ? th->palette_secondary : LV_COLOR_PALETTE_BLUE; + return th ? th->palette_secondary : LV_PALETTE_BLUE; } lv_color_t lv_theme_get_color_primary(lv_obj_t * obj) { lv_theme_t * th = lv_theme_get_from_obj(obj); - return th ? th->color_primary : lv_color_blue_grey(); + return th ? th->color_primary : lv_palette_main(LV_PALETTE_BLUE_GREY); } lv_color_t lv_theme_get_color_secondary(lv_obj_t * obj) { lv_theme_t * th = lv_theme_get_from_obj(obj); - return th ? th->color_secondary : lv_color_blue(); + return th ? th->color_secondary : lv_palette_main(LV_PALETTE_BLUE); } /********************** diff --git a/src/core/lv_theme.h b/src/core/lv_theme.h index 8c5a01838..bc23a41ca 100644 --- a/src/core/lv_theme.h +++ b/src/core/lv_theme.h @@ -33,8 +33,8 @@ typedef struct _lv_theme_t { struct _lv_theme_t * parent; /**< Apply the current theme's style on top of this theme.*/ void * user_data; struct _lv_disp_t * disp; - lv_color_palette_t palette_primary; - lv_color_palette_t palette_secondary; + lv_palette_t palette_primary; + lv_palette_t palette_secondary; lv_color_t color_primary; lv_color_t color_secondary; const lv_font_t * font_small; @@ -94,9 +94,9 @@ const lv_font_t * lv_theme_get_font_normal(lv_obj_t * obj); */ const lv_font_t * lv_theme_get_font_large(lv_obj_t * obj); -lv_color_palette_t lv_theme_get_palette_primary(lv_obj_t * obj); +lv_palette_t lv_theme_get_palette_primary(lv_obj_t * obj); -lv_color_palette_t lv_theme_get_palette_secondary(lv_obj_t * obj); +lv_palette_t lv_theme_get_palette_secondary(lv_obj_t * obj); /** * Get the primary color of the theme diff --git a/src/draw/lv_draw_label.c b/src/draw/lv_draw_label.c index 2d3930195..7b1fb8257 100644 --- a/src/draw/lv_draw_label.c +++ b/src/draw/lv_draw_label.c @@ -100,7 +100,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc) 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_bg_color = lv_palette_main(LV_PALETTE_BLUE); dsc->bidi_dir = LV_BIDI_DIR_LTR; } diff --git a/src/extra/themes/basic/lv_theme_basic.c b/src/extra/themes/basic/lv_theme_basic.c index d69a5aec4..c06eb8247 100644 --- a/src/extra/themes/basic/lv_theme_basic.c +++ b/src/extra/themes/basic/lv_theme_basic.c @@ -20,7 +20,7 @@ #define COLOR_WHITE lv_color_white() #define COLOR_LIGHT lv_color_grey_lighten_3() #define COLOR_MID lv_color_grey_lighten_1() -#define COLOR_DARK lv_color_grey() +#define COLOR_DARK lv_palette_main(LV_PALETTE_GREY) #define COLOR_DIM lv_color_grey_darken_2() #define PAD_DEF LV_DPX(5) @@ -163,8 +163,8 @@ lv_theme_t * lv_theme_basic_init(lv_disp_t * disp) } theme.disp = disp; - theme.palette_primary = LV_COLOR_PALETTE_NONE; - theme.palette_secondary = LV_COLOR_PALETTE_NONE; + theme.palette_primary = LV_PALETTE_NONE; + theme.palette_secondary = LV_PALETTE_NONE; theme.font_small = LV_FONT_DEFAULT; theme.font_normal = LV_FONT_DEFAULT; theme.font_large = LV_FONT_DEFAULT; diff --git a/src/extra/themes/default/lv_theme_default.c b/src/extra/themes/default/lv_theme_default.c index 3defd9f22..71a7639cf 100644 --- a/src/extra/themes/default/lv_theme_default.c +++ b/src/extra/themes/default/lv_theme_default.c @@ -20,14 +20,14 @@ #define RADIUS_DEFAULT (disp_size == DISP_LARGE ? LV_DPX(12) : LV_DPX(8)) /*SCREEN*/ -#define LIGHT_COLOR_SCR lv_color_grey_lighten_4() +#define LIGHT_COLOR_SCR lv_palette_lighten(LV_PALETTE_GREY, 4) #define LIGHT_COLOR_CARD lv_color_white() -#define LIGHT_COLOR_TEXT lv_color_grey_darken_4() -#define LIGHT_COLOR_GREY lv_color_grey_lighten_2() -#define DARK_COLOR_SCR lv_color_grey_darken_4() -#define DARK_COLOR_CARD lv_color_grey_darken_3() -#define DARK_COLOR_TEXT lv_color_grey_lighten_5() -#define DARK_COLOR_GREY lv_color_grey_darken_1() +#define LIGHT_COLOR_TEXT lv_palette_darken(LV_PALETTE_GREY, 4) +#define LIGHT_COLOR_GREY lv_palette_lighten(LV_PALETTE_GREY, 2) +#define DARK_COLOR_SCR lv_palette_darken(LV_PALETTE_GREY, 4) +#define DARK_COLOR_CARD lv_palette_darken(LV_PALETTE_GREY, 3) +#define DARK_COLOR_TEXT lv_palette_lighten(LV_PALETTE_GREY, 5) +#define DARK_COLOR_GREY lv_palette_darken(LV_PALETTE_GREY, 1) #define TRANSITION_TIME LV_THEME_DEFAULT_TRANSITON_TIME #define BORDER_WIDTH LV_DPX(2) @@ -191,8 +191,8 @@ static lv_color_t dark_color_filter_cb(const lv_color_filter_dsc_t * f, lv_color static lv_color_t grey_filter_cb(const lv_color_filter_dsc_t * f, lv_color_t color, lv_opa_t opa) { LV_UNUSED(f); - if(theme.flags & MODE_DARK) return lv_color_mix(lv_color_grey_darken_2(), color, opa); - else return lv_color_mix(lv_color_grey_lighten_2(), color, opa); + if(theme.flags & MODE_DARK) return lv_color_mix(lv_palette_darken(LV_PALETTE_GREY, 2), color, opa); + else return lv_color_mix(lv_palette_lighten(LV_PALETTE_GREY, 2), color, opa); } static void style_init(void) @@ -206,8 +206,8 @@ static void style_init(void) 0 }; - color_primary = lv_color_get_palette_main(theme.palette_primary); - color_secondary = lv_color_get_palette_main(theme.palette_secondary); + color_primary = lv_palette_main(theme.palette_primary); + color_secondary = lv_palette_main(theme.palette_secondary); color_scr = theme.flags & MODE_DARK ? DARK_COLOR_SCR : LIGHT_COLOR_SCR; color_text = theme.flags & MODE_DARK ? DARK_COLOR_TEXT : LIGHT_COLOR_TEXT; @@ -231,7 +231,7 @@ static void style_init(void) style_init_reset(&styles->scrollbar); lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_COVER); - lv_style_set_bg_color(&styles->scrollbar, lv_color_grey()); + lv_style_set_bg_color(&styles->scrollbar, lv_palette_main(LV_PALETTE_GREY)); lv_style_set_radius(&styles->scrollbar, LV_RADIUS_CIRCLE); lv_style_set_pad_right(&styles->scrollbar, LV_DPX(7)); lv_style_set_pad_top(&styles->scrollbar, LV_DPX(7)); @@ -260,7 +260,7 @@ static void style_init(void) lv_style_set_pad_all(&styles->card, PAD_DEF); lv_style_set_pad_row(&styles->card, PAD_SMALL); lv_style_set_pad_column(&styles->card, PAD_SMALL); - lv_style_set_line_color(&styles->card, lv_color_grey()); + lv_style_set_line_color(&styles->card, lv_palette_main(LV_PALETTE_GREY)); lv_style_set_line_width(&styles->card, LV_DPX(1)); style_init_reset(&styles->outline_primary); @@ -279,7 +279,7 @@ static void style_init(void) lv_style_set_bg_opa(&styles->btn, LV_OPA_COVER); lv_style_set_bg_color(&styles->btn, color_grey); if(!(theme.flags & MODE_DARK)) { - lv_style_set_shadow_color(&styles->btn, lv_color_grey_lighten_3()); + lv_style_set_shadow_color(&styles->btn, lv_palette_lighten(LV_PALETTE_GREY, 3)); lv_style_set_shadow_width(&styles->btn, 1); lv_style_set_shadow_ofs_y(&styles->btn, LV_DPX(4)); } @@ -448,7 +448,7 @@ static void style_init(void) lv_style_set_line_width(&styles->chart_ticks, LV_DPX(1)); lv_style_set_line_color(&styles->chart_ticks, color_text); lv_style_set_pad_all(&styles->chart_ticks, LV_DPX(2)); - lv_style_set_text_color(&styles->chart_ticks, lv_color_grey()); + lv_style_set_text_color(&styles->chart_ticks, lv_palette_main(LV_PALETTE_GREY)); #endif #if LV_USE_METER @@ -481,7 +481,7 @@ static void style_init(void) lv_style_set_anim_time(&styles->ta_cursor, 400); style_init_reset(&styles->ta_placeholder); - lv_style_set_text_color(&styles->ta_placeholder, lv_color_grey()); + lv_style_set_text_color(&styles->ta_placeholder, lv_palette_main(LV_PALETTE_GREY)); #endif #if LV_USE_CALENDAR @@ -544,7 +544,7 @@ static void style_init(void) style_init_reset(&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_grey()); + lv_style_set_bg_grad_color(&styles->led, lv_palette_main(LV_PALETTE_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()); @@ -557,7 +557,7 @@ static void style_init(void) * GLOBAL FUNCTIONS **********************/ -lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_palette_t palette_primary, lv_color_palette_t palette_secondary, bool dark, +lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_palette_t palette_primary, lv_palette_t palette_secondary, bool dark, const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_large) { diff --git a/src/extra/themes/default/lv_theme_default.h b/src/extra/themes/default/lv_theme_default.h index 0d5140b30..a536c92c2 100644 --- a/src/extra/themes/default/lv_theme_default.h +++ b/src/extra/themes/default/lv_theme_default.h @@ -36,7 +36,7 @@ extern "C" { * @param font pointer to a font to use. * @return a pointer to reference this theme later */ -lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_palette_t palette_primary, lv_color_palette_t palette_secondary, +lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_palette_t palette_primary, lv_palette_t palette_secondary, bool dark, const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_large); diff --git a/src/extra/widgets/calendar/lv_calendar.c b/src/extra/widgets/calendar/lv_calendar.c index 60de506e8..ef22a6f61 100644 --- a/src/extra/widgets/calendar/lv_calendar.c +++ b/src/extra/widgets/calendar/lv_calendar.c @@ -266,7 +266,7 @@ static void draw_part_begin_event_cb(lv_event_t * e) else if(lv_btnmatrix_has_btn_ctrl(obj, dsc->id, LV_BTNMATRIX_CTRL_DISABLED)) { dsc->rect_dsc->bg_opa = LV_OPA_TRANSP; dsc->rect_dsc->border_opa = LV_OPA_TRANSP; - dsc->label_dsc->color = lv_color_grey(); + dsc->label_dsc->color = lv_palette_main(LV_PALETTE_GREY); } if(lv_btnmatrix_has_btn_ctrl(obj, dsc->id, LV_CALENDAR_CTRL_HIGHLIGHT)) { diff --git a/src/extra/widgets/msgbox/lv_msgbox.c b/src/extra/widgets/msgbox/lv_msgbox.c index ed0d1a67b..f36944c01 100644 --- a/src/extra/widgets/msgbox/lv_msgbox.c +++ b/src/extra/widgets/msgbox/lv_msgbox.c @@ -45,7 +45,7 @@ lv_obj_t * lv_msgbox_create(const char * title, const char * txt, const char * b { lv_obj_t * parent = lv_obj_create(lv_scr_act()); lv_obj_remove_style_all(parent); - lv_obj_set_style_bg_color(parent, lv_color_grey(), 0); + lv_obj_set_style_bg_color(parent, lv_palette_main(LV_PALETTE_GREY), 0); lv_obj_set_style_bg_opa(parent, LV_OPA_50, 0); lv_obj_set_size(parent, LV_PCT(100), LV_PCT(100)); diff --git a/src/hal/lv_hal_disp.c b/src/hal/lv_hal_disp.c index 9f7fe5573..4147c46bb 100644 --- a/src/hal/lv_hal_disp.c +++ b/src/hal/lv_hal_disp.c @@ -132,7 +132,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) #if LV_USE_THEME_DEFAULT if(lv_theme_default_is_inited() == false) { - disp->theme = lv_theme_default_init(disp, LV_COLOR_PALETTE_BLUE, LV_COLOR_PALETTE_CYAN, false, LV_FONT_DEFAULT, LV_FONT_DEFAULT, LV_FONT_DEFAULT); + disp->theme = lv_theme_default_init(disp, LV_PALETTE_BLUE, LV_PALETTE_CYAN, false, LV_FONT_DEFAULT, LV_FONT_DEFAULT, LV_FONT_DEFAULT); } #endif diff --git a/src/misc/lv_color.c b/src/misc/lv_color.c index 2c59c3d46..1bc586b3e 100644 --- a/src/misc/lv_color.c +++ b/src/misc/lv_color.c @@ -271,263 +271,101 @@ lv_color_hsv_t lv_color_to_hsv(lv_color_t color) return lv_color_rgb_to_hsv(color32.ch.red, color32.ch.green, color32.ch.blue); } - lv_color_t lv_color_get_palette_main(lv_color_palette_t palette) +lv_color_t lv_palette_main(lv_palette_t p) { - switch(palette) { - case LV_COLOR_PALETTE_RED: return lv_color_red(); - case LV_COLOR_PALETTE_PINK: return lv_color_pink(); - case LV_COLOR_PALETTE_PURPLE: return lv_color_purple(); - case LV_COLOR_PALETTE_DEEP_PURPLE: return lv_color_deep_purple(); - case LV_COLOR_PALETTE_INDIGO: return lv_color_indigo(); - case LV_COLOR_PALETTE_BLUE: return lv_color_blue(); - case LV_COLOR_PALETTE_LIGHT_BLUE: return lv_color_light_blue(); - case LV_COLOR_PALETTE_CYAN: return lv_color_cyan(); - case LV_COLOR_PALETTE_TEAL: return lv_color_teal(); - case LV_COLOR_PALETTE_GREEN: return lv_color_green(); - case LV_COLOR_PALETTE_LIGHT_GREEN: return lv_color_light_green(); - case LV_COLOR_PALETTE_LIME: return lv_color_lime(); - case LV_COLOR_PALETTE_YELLOW: return lv_color_yellow(); - case LV_COLOR_PALETTE_AMBER: return lv_color_amber(); - case LV_COLOR_PALETTE_ORANGE: return lv_color_orange(); - case LV_COLOR_PALETTE_DEEP_ORANGE: return lv_color_deep_orange(); - case LV_COLOR_PALETTE_BROWN: return lv_color_brown(); - case LV_COLOR_PALETTE_BLUE_GREY: return lv_color_blue_grey(); - case LV_COLOR_PALETTE_GREY: return lv_color_grey(); - default: return lv_color_black(); + static const lv_color_t colors[] = { + LV_COLOR_MAKE(0xF4, 0x43, 0x36), LV_COLOR_MAKE(0xE9, 0x1E, 0x63), LV_COLOR_MAKE(0x9C, 0x27, 0xB0), LV_COLOR_MAKE(0x67, 0x3A, 0xB7), + LV_COLOR_MAKE(0x3F, 0x51, 0xB5), LV_COLOR_MAKE(0x21, 0x96, 0xF3), LV_COLOR_MAKE(0x03, 0xA9, 0xF4), LV_COLOR_MAKE(0x00, 0xBC, 0xD4), + LV_COLOR_MAKE(0x00, 0x96, 0x88), LV_COLOR_MAKE(0x4C, 0xAF, 0x50), LV_COLOR_MAKE(0x8B, 0xC3, 0x4A), LV_COLOR_MAKE(0xCD, 0xDC, 0x39), + LV_COLOR_MAKE(0xFF, 0xEB, 0x3B), LV_COLOR_MAKE(0xFF, 0xC1, 0x07), LV_COLOR_MAKE(0xFF, 0x98, 0x00), LV_COLOR_MAKE(0xFF, 0x57, 0x22), + LV_COLOR_MAKE(0x79, 0x55, 0x48), LV_COLOR_MAKE(0x60, 0x7D, 0x8B), LV_COLOR_MAKE(0x9E, 0x9E, 0x9E) + }; + + if(p >= _LV_PALETTE_LAST) { + LV_LOG_WARN("Invalid palette: %d", p); + return lv_color_black(); } + return colors[p]; + } - lv_color_t lv_color_get_palette_lighten_1(lv_color_palette_t palette) +lv_color_t lv_palette_lighten(lv_palette_t p, uint8_t lvl) { - switch(palette) { - case LV_COLOR_PALETTE_RED: return lv_color_red_lighten_1(); - case LV_COLOR_PALETTE_PINK: return lv_color_pink_lighten_1(); - case LV_COLOR_PALETTE_PURPLE: return lv_color_purple_lighten_1(); - case LV_COLOR_PALETTE_DEEP_PURPLE: return lv_color_deep_purple_lighten_1(); - case LV_COLOR_PALETTE_INDIGO: return lv_color_indigo_lighten_1(); - case LV_COLOR_PALETTE_BLUE: return lv_color_blue_lighten_1(); - case LV_COLOR_PALETTE_LIGHT_BLUE: return lv_color_light_blue_lighten_1(); - case LV_COLOR_PALETTE_CYAN: return lv_color_cyan_lighten_1(); - case LV_COLOR_PALETTE_TEAL: return lv_color_teal_lighten_1(); - case LV_COLOR_PALETTE_GREEN: return lv_color_green_lighten_1(); - case LV_COLOR_PALETTE_LIGHT_GREEN: return lv_color_light_green_lighten_1(); - case LV_COLOR_PALETTE_LIME: return lv_color_lime_lighten_1(); - case LV_COLOR_PALETTE_YELLOW: return lv_color_yellow_lighten_1(); - case LV_COLOR_PALETTE_AMBER: return lv_color_amber_lighten_1(); - case LV_COLOR_PALETTE_ORANGE: return lv_color_orange_lighten_1(); - case LV_COLOR_PALETTE_DEEP_ORANGE: return lv_color_deep_orange_lighten_1(); - case LV_COLOR_PALETTE_BROWN: return lv_color_brown_lighten_1(); - case LV_COLOR_PALETTE_BLUE_GREY: return lv_color_blue_grey_lighten_1(); - case LV_COLOR_PALETTE_GREY: return lv_color_grey_lighten_1(); - default: return lv_color_black(); - } + static const lv_color_t colors[][5] = { + {LV_COLOR_MAKE(0xEF, 0x53, 0x50), LV_COLOR_MAKE(0xE5, 0x73, 0x73), LV_COLOR_MAKE(0xEF, 0x9A, 0x9A), LV_COLOR_MAKE(0xFF, 0xCD, 0xD2), LV_COLOR_MAKE(0xFF, 0xEB, 0xEE)}, + {LV_COLOR_MAKE(0xEC, 0x40, 0x7A), LV_COLOR_MAKE(0xF0, 0x62, 0x92), LV_COLOR_MAKE(0xF4, 0x8F, 0xB1), LV_COLOR_MAKE(0xF8, 0xBB, 0xD0), LV_COLOR_MAKE(0xFC, 0xE4, 0xEC)}, + {LV_COLOR_MAKE(0xAB, 0x47, 0xBC), LV_COLOR_MAKE(0xBA, 0x68, 0xC8), LV_COLOR_MAKE(0xCE, 0x93, 0xD8), LV_COLOR_MAKE(0xE1, 0xBE, 0xE7), LV_COLOR_MAKE(0xF3, 0xE5, 0xF5)}, + {LV_COLOR_MAKE(0x7E, 0x57, 0xC2), LV_COLOR_MAKE(0x95, 0x75, 0xCD), LV_COLOR_MAKE(0xB3, 0x9D, 0xDB), LV_COLOR_MAKE(0xD1, 0xC4, 0xE9), LV_COLOR_MAKE(0xED, 0xE7, 0xF6)}, + {LV_COLOR_MAKE(0x5C, 0x6B, 0xC0), LV_COLOR_MAKE(0x79, 0x86, 0xCB), LV_COLOR_MAKE(0x9F, 0xA8, 0xDA), LV_COLOR_MAKE(0xC5, 0xCA, 0xE9), LV_COLOR_MAKE(0xE8, 0xEA, 0xF6)}, + {LV_COLOR_MAKE(0x42, 0xA5, 0xF5), LV_COLOR_MAKE(0x64, 0xB5, 0xF6), LV_COLOR_MAKE(0x90, 0xCA, 0xF9), LV_COLOR_MAKE(0xBB, 0xDE, 0xFB), LV_COLOR_MAKE(0xE3, 0xF2, 0xFD)}, + {LV_COLOR_MAKE(0x29, 0xB6, 0xF6), LV_COLOR_MAKE(0x4F, 0xC3, 0xF7), LV_COLOR_MAKE(0x81, 0xD4, 0xFA), LV_COLOR_MAKE(0xB3, 0xE5, 0xFC), LV_COLOR_MAKE(0xE1, 0xF5, 0xFE)}, + {LV_COLOR_MAKE(0x26, 0xC6, 0xDA), LV_COLOR_MAKE(0x4D, 0xD0, 0xE1), LV_COLOR_MAKE(0x80, 0xDE, 0xEA), LV_COLOR_MAKE(0xB2, 0xEB, 0xF2), LV_COLOR_MAKE(0xE0, 0xF7, 0xFA)}, + {LV_COLOR_MAKE(0x26, 0xA6, 0x9A), LV_COLOR_MAKE(0x4D, 0xB6, 0xAC), LV_COLOR_MAKE(0x80, 0xCB, 0xC4), LV_COLOR_MAKE(0xB2, 0xDF, 0xDB), LV_COLOR_MAKE(0xE0, 0xF2, 0xF1)}, + {LV_COLOR_MAKE(0x66, 0xBB, 0x6A), LV_COLOR_MAKE(0x81, 0xC7, 0x84), LV_COLOR_MAKE(0xA5, 0xD6, 0xA7), LV_COLOR_MAKE(0xC8, 0xE6, 0xC9), LV_COLOR_MAKE(0xE8, 0xF5, 0xE9)}, + {LV_COLOR_MAKE(0x9C, 0xCC, 0x65), LV_COLOR_MAKE(0xAE, 0xD5, 0x81), LV_COLOR_MAKE(0xC5, 0xE1, 0xA5), LV_COLOR_MAKE(0xDC, 0xED, 0xC8), LV_COLOR_MAKE(0xF1, 0xF8, 0xE9)}, + {LV_COLOR_MAKE(0xD4, 0xE1, 0x57), LV_COLOR_MAKE(0xDC, 0xE7, 0x75), LV_COLOR_MAKE(0xE6, 0xEE, 0x9C), LV_COLOR_MAKE(0xF0, 0xF4, 0xC3), LV_COLOR_MAKE(0xF9, 0xFB, 0xE7)}, + {LV_COLOR_MAKE(0xFF, 0xEE, 0x58), LV_COLOR_MAKE(0xFF, 0xF1, 0x76), LV_COLOR_MAKE(0xFF, 0xF5, 0x9D), LV_COLOR_MAKE(0xFF, 0xF9, 0xC4), LV_COLOR_MAKE(0xFF, 0xFD, 0xE7)}, + {LV_COLOR_MAKE(0xFF, 0xCA, 0x28), LV_COLOR_MAKE(0xFF, 0xD5, 0x4F), LV_COLOR_MAKE(0xFF, 0xE0, 0x82), LV_COLOR_MAKE(0xFF, 0xEC, 0xB3), LV_COLOR_MAKE(0xFF, 0xF8, 0xE1)}, + {LV_COLOR_MAKE(0xFF, 0xA7, 0x26), LV_COLOR_MAKE(0xFF, 0xB7, 0x4D), LV_COLOR_MAKE(0xFF, 0xCC, 0x80), LV_COLOR_MAKE(0xFF, 0xE0, 0xB2), LV_COLOR_MAKE(0xFF, 0xF3, 0xE0)}, + {LV_COLOR_MAKE(0xFF, 0x70, 0x43), LV_COLOR_MAKE(0xFF, 0x8A, 0x65), LV_COLOR_MAKE(0xFF, 0xAB, 0x91), LV_COLOR_MAKE(0xFF, 0xCC, 0xBC), LV_COLOR_MAKE(0xFB, 0xE9, 0xE7)}, + {LV_COLOR_MAKE(0x8D, 0x6E, 0x63), LV_COLOR_MAKE(0xA1, 0x88, 0x7F), LV_COLOR_MAKE(0xBC, 0xAA, 0xA4), LV_COLOR_MAKE(0xD7, 0xCC, 0xC8), LV_COLOR_MAKE(0xEF, 0xEB, 0xE9)}, + {LV_COLOR_MAKE(0x78, 0x90, 0x9C), LV_COLOR_MAKE(0x90, 0xA4, 0xAE), LV_COLOR_MAKE(0xB0, 0xBE, 0xC5), LV_COLOR_MAKE(0xCF, 0xD8, 0xDC), LV_COLOR_MAKE(0xEC, 0xEF, 0xF1)}, + {LV_COLOR_MAKE(0xBD, 0xBD, 0xBD), LV_COLOR_MAKE(0xE0, 0xE0, 0xE0), LV_COLOR_MAKE(0xEE, 0xEE, 0xEE), LV_COLOR_MAKE(0xF5, 0xF5, 0xF5), LV_COLOR_MAKE(0xFA, 0xFA, 0xFA)}, + }; + + if(p >= _LV_PALETTE_LAST) { + LV_LOG_WARN("Invalid palette: %d", p); + return lv_color_black(); + } + + if(lvl == 0 || lvl > 5) { + LV_LOG_WARN("Invalid level: %d. Most be 1..5", lvl); + return lv_color_black(); + } + + lvl--; + + return colors[p][lvl]; } - lv_color_t lv_color_get_palette_lighten_2(lv_color_palette_t palette) +lv_color_t lv_palette_darken(lv_palette_t p, uint8_t lvl) { - switch(palette) { - case LV_COLOR_PALETTE_RED: return lv_color_red_lighten_2(); - case LV_COLOR_PALETTE_PINK: return lv_color_pink_lighten_2(); - case LV_COLOR_PALETTE_PURPLE: return lv_color_purple_lighten_2(); - case LV_COLOR_PALETTE_DEEP_PURPLE: return lv_color_deep_purple_lighten_2(); - case LV_COLOR_PALETTE_INDIGO: return lv_color_indigo_lighten_2(); - case LV_COLOR_PALETTE_BLUE: return lv_color_blue_lighten_2(); - case LV_COLOR_PALETTE_LIGHT_BLUE: return lv_color_light_blue_lighten_2(); - case LV_COLOR_PALETTE_CYAN: return lv_color_cyan_lighten_2(); - case LV_COLOR_PALETTE_TEAL: return lv_color_teal_lighten_2(); - case LV_COLOR_PALETTE_GREEN: return lv_color_green_lighten_2(); - case LV_COLOR_PALETTE_LIGHT_GREEN: return lv_color_light_green_lighten_2(); - case LV_COLOR_PALETTE_LIME: return lv_color_lime_lighten_2(); - case LV_COLOR_PALETTE_YELLOW: return lv_color_yellow_lighten_2(); - case LV_COLOR_PALETTE_AMBER: return lv_color_amber_lighten_2(); - case LV_COLOR_PALETTE_ORANGE: return lv_color_orange_lighten_2(); - case LV_COLOR_PALETTE_DEEP_ORANGE: return lv_color_deep_orange_lighten_2(); - case LV_COLOR_PALETTE_BROWN: return lv_color_brown_lighten_2(); - case LV_COLOR_PALETTE_BLUE_GREY: return lv_color_blue_grey_lighten_2(); - case LV_COLOR_PALETTE_GREY: return lv_color_grey_lighten_2(); - default: return lv_color_black(); - } + static const lv_color_t colors[][4] = { + {LV_COLOR_MAKE(0xE5, 0x39, 0x35), LV_COLOR_MAKE(0xD3, 0x2F, 0x2F), LV_COLOR_MAKE(0xC6, 0x28, 0x28), LV_COLOR_MAKE(0xB7, 0x1C, 0x1C)}, + {LV_COLOR_MAKE(0xD8, 0x1B, 0x60), LV_COLOR_MAKE(0xC2, 0x18, 0x5B), LV_COLOR_MAKE(0xAD, 0x14, 0x57), LV_COLOR_MAKE(0x88, 0x0E, 0x4F)}, + {LV_COLOR_MAKE(0x8E, 0x24, 0xAA), LV_COLOR_MAKE(0x7B, 0x1F, 0xA2), LV_COLOR_MAKE(0x6A, 0x1B, 0x9A), LV_COLOR_MAKE(0x4A, 0x14, 0x8C)}, + {LV_COLOR_MAKE(0x5E, 0x35, 0xB1), LV_COLOR_MAKE(0x51, 0x2D, 0xA8), LV_COLOR_MAKE(0x45, 0x27, 0xA0), LV_COLOR_MAKE(0x31, 0x1B, 0x92)}, + {LV_COLOR_MAKE(0x39, 0x49, 0xAB), LV_COLOR_MAKE(0x30, 0x3F, 0x9F), LV_COLOR_MAKE(0x28, 0x35, 0x93), LV_COLOR_MAKE(0x1A, 0x23, 0x7E)}, + {LV_COLOR_MAKE(0x1E, 0x88, 0xE5), LV_COLOR_MAKE(0x19, 0x76, 0xD2), LV_COLOR_MAKE(0x15, 0x65, 0xC0), LV_COLOR_MAKE(0x0D, 0x47, 0xA1)}, + {LV_COLOR_MAKE(0x03, 0x9B, 0xE5), LV_COLOR_MAKE(0x02, 0x88, 0xD1), LV_COLOR_MAKE(0x02, 0x77, 0xBD), LV_COLOR_MAKE(0x01, 0x57, 0x9B)}, + {LV_COLOR_MAKE(0x00, 0xAC, 0xC1), LV_COLOR_MAKE(0x00, 0x97, 0xA7), LV_COLOR_MAKE(0x00, 0x83, 0x8F), LV_COLOR_MAKE(0x00, 0x60, 0x64)}, + {LV_COLOR_MAKE(0x00, 0x89, 0x7B), LV_COLOR_MAKE(0x00, 0x79, 0x6B), LV_COLOR_MAKE(0x00, 0x69, 0x5C), LV_COLOR_MAKE(0x00, 0x4D, 0x40)}, + {LV_COLOR_MAKE(0x43, 0xA0, 0x47), LV_COLOR_MAKE(0x38, 0x8E, 0x3C), LV_COLOR_MAKE(0x2E, 0x7D, 0x32), LV_COLOR_MAKE(0x1B, 0x5E, 0x20)}, + {LV_COLOR_MAKE(0x7C, 0xB3, 0x42), LV_COLOR_MAKE(0x68, 0x9F, 0x38), LV_COLOR_MAKE(0x55, 0x8B, 0x2F), LV_COLOR_MAKE(0x33, 0x69, 0x1E)}, + {LV_COLOR_MAKE(0xC0, 0xCA, 0x33), LV_COLOR_MAKE(0xAF, 0xB4, 0x2B), LV_COLOR_MAKE(0x9E, 0x9D, 0x24), LV_COLOR_MAKE(0x82, 0x77, 0x17)}, + {LV_COLOR_MAKE(0xFD, 0xD8, 0x35), LV_COLOR_MAKE(0xFB, 0xC0, 0x2D), LV_COLOR_MAKE(0xF9, 0xA8, 0x25), LV_COLOR_MAKE(0xF5, 0x7F, 0x17)}, + {LV_COLOR_MAKE(0xFF, 0xB3, 0x00), LV_COLOR_MAKE(0xFF, 0xA0, 0x00), LV_COLOR_MAKE(0xFF, 0x8F, 0x00), LV_COLOR_MAKE(0xFF, 0x6F, 0x00)}, + {LV_COLOR_MAKE(0xFB, 0x8C, 0x00), LV_COLOR_MAKE(0xF5, 0x7C, 0x00), LV_COLOR_MAKE(0xEF, 0x6C, 0x00), LV_COLOR_MAKE(0xE6, 0x51, 0x00)}, + {LV_COLOR_MAKE(0xF4, 0x51, 0x1E), LV_COLOR_MAKE(0xE6, 0x4A, 0x19), LV_COLOR_MAKE(0xD8, 0x43, 0x15), LV_COLOR_MAKE(0xBF, 0x36, 0x0C)}, + {LV_COLOR_MAKE(0x6D, 0x4C, 0x41), LV_COLOR_MAKE(0x5D, 0x40, 0x37), LV_COLOR_MAKE(0x4E, 0x34, 0x2E), LV_COLOR_MAKE(0x3E, 0x27, 0x23)}, + {LV_COLOR_MAKE(0x54, 0x6E, 0x7A), LV_COLOR_MAKE(0x45, 0x5A, 0x64), LV_COLOR_MAKE(0x37, 0x47, 0x4F), LV_COLOR_MAKE(0x26, 0x32, 0x38)}, + {LV_COLOR_MAKE(0x75, 0x75, 0x75), LV_COLOR_MAKE(0x61, 0x61, 0x61), LV_COLOR_MAKE(0x42, 0x42, 0x42), LV_COLOR_MAKE(0x21, 0x21, 0x21)}, + }; + + if(p >= _LV_PALETTE_LAST) { + LV_LOG_WARN("Invalid palette: %d", p); + return lv_color_black(); + } + + if(lvl == 0 || lvl > 5) { + LV_LOG_WARN("Invalid level: %d. Most be 1..4", lvl); + return lv_color_black(); + } + + lvl--; + + return colors[p][lvl]; } - lv_color_t lv_color_get_palette_lighten_3(lv_color_palette_t palette) -{ - switch(palette) { - case LV_COLOR_PALETTE_RED: return lv_color_red_lighten_3(); - case LV_COLOR_PALETTE_PINK: return lv_color_pink_lighten_3(); - case LV_COLOR_PALETTE_PURPLE: return lv_color_purple_lighten_3(); - case LV_COLOR_PALETTE_DEEP_PURPLE: return lv_color_deep_purple_lighten_3(); - case LV_COLOR_PALETTE_INDIGO: return lv_color_indigo_lighten_3(); - case LV_COLOR_PALETTE_BLUE: return lv_color_blue_lighten_3(); - case LV_COLOR_PALETTE_LIGHT_BLUE: return lv_color_light_blue_lighten_3(); - case LV_COLOR_PALETTE_CYAN: return lv_color_cyan_lighten_3(); - case LV_COLOR_PALETTE_TEAL: return lv_color_teal_lighten_3(); - case LV_COLOR_PALETTE_GREEN: return lv_color_green_lighten_3(); - case LV_COLOR_PALETTE_LIGHT_GREEN: return lv_color_light_green_lighten_3(); - case LV_COLOR_PALETTE_LIME: return lv_color_lime_lighten_3(); - case LV_COLOR_PALETTE_YELLOW: return lv_color_yellow_lighten_3(); - case LV_COLOR_PALETTE_AMBER: return lv_color_amber_lighten_3(); - case LV_COLOR_PALETTE_ORANGE: return lv_color_orange_lighten_3(); - case LV_COLOR_PALETTE_DEEP_ORANGE: return lv_color_deep_orange_lighten_3(); - case LV_COLOR_PALETTE_BROWN: return lv_color_brown_lighten_3(); - case LV_COLOR_PALETTE_BLUE_GREY: return lv_color_blue_grey_lighten_3(); - case LV_COLOR_PALETTE_GREY: return lv_color_grey_lighten_3(); - default: return lv_color_black(); - } -} - lv_color_t lv_color_get_palette_lighten_4(lv_color_palette_t palette) -{ - switch(palette) { - case LV_COLOR_PALETTE_RED: return lv_color_red_lighten_4(); - case LV_COLOR_PALETTE_PINK: return lv_color_pink_lighten_4(); - case LV_COLOR_PALETTE_PURPLE: return lv_color_purple_lighten_4(); - case LV_COLOR_PALETTE_DEEP_PURPLE: return lv_color_deep_purple_lighten_4(); - case LV_COLOR_PALETTE_INDIGO: return lv_color_indigo_lighten_4(); - case LV_COLOR_PALETTE_BLUE: return lv_color_blue_lighten_4(); - case LV_COLOR_PALETTE_LIGHT_BLUE: return lv_color_light_blue_lighten_4(); - case LV_COLOR_PALETTE_CYAN: return lv_color_cyan_lighten_4(); - case LV_COLOR_PALETTE_TEAL: return lv_color_teal_lighten_4(); - case LV_COLOR_PALETTE_GREEN: return lv_color_green_lighten_4(); - case LV_COLOR_PALETTE_LIGHT_GREEN: return lv_color_light_green_lighten_4(); - case LV_COLOR_PALETTE_LIME: return lv_color_lime_lighten_4(); - case LV_COLOR_PALETTE_YELLOW: return lv_color_yellow_lighten_4(); - case LV_COLOR_PALETTE_AMBER: return lv_color_amber_lighten_4(); - case LV_COLOR_PALETTE_ORANGE: return lv_color_orange_lighten_4(); - case LV_COLOR_PALETTE_DEEP_ORANGE: return lv_color_deep_orange_lighten_4(); - case LV_COLOR_PALETTE_BROWN: return lv_color_brown_lighten_4(); - case LV_COLOR_PALETTE_BLUE_GREY: return lv_color_blue_grey_lighten_4(); - case LV_COLOR_PALETTE_GREY: return lv_color_grey_lighten_4(); - default: return lv_color_black(); - } -} - - lv_color_t lv_color_get_palette_lighten_5(lv_color_palette_t palette) -{ - switch(palette) { - case LV_COLOR_PALETTE_RED: return lv_color_red_lighten_5(); - case LV_COLOR_PALETTE_PINK: return lv_color_pink_lighten_5(); - case LV_COLOR_PALETTE_PURPLE: return lv_color_purple_lighten_5(); - case LV_COLOR_PALETTE_DEEP_PURPLE: return lv_color_deep_purple_lighten_5(); - case LV_COLOR_PALETTE_INDIGO: return lv_color_indigo_lighten_5(); - case LV_COLOR_PALETTE_BLUE: return lv_color_blue_lighten_5(); - case LV_COLOR_PALETTE_LIGHT_BLUE: return lv_color_light_blue_lighten_5(); - case LV_COLOR_PALETTE_CYAN: return lv_color_cyan_lighten_5(); - case LV_COLOR_PALETTE_TEAL: return lv_color_teal_lighten_5(); - case LV_COLOR_PALETTE_GREEN: return lv_color_green_lighten_5(); - case LV_COLOR_PALETTE_LIGHT_GREEN: return lv_color_light_green_lighten_5(); - case LV_COLOR_PALETTE_LIME: return lv_color_lime_lighten_5(); - case LV_COLOR_PALETTE_YELLOW: return lv_color_yellow_lighten_5(); - case LV_COLOR_PALETTE_AMBER: return lv_color_amber_lighten_5(); - case LV_COLOR_PALETTE_ORANGE: return lv_color_orange_lighten_5(); - case LV_COLOR_PALETTE_DEEP_ORANGE: return lv_color_deep_orange_lighten_5(); - case LV_COLOR_PALETTE_BROWN: return lv_color_brown_lighten_5(); - case LV_COLOR_PALETTE_BLUE_GREY: return lv_color_blue_grey_lighten_5(); - case LV_COLOR_PALETTE_GREY: return lv_color_grey_lighten_5(); - default: return lv_color_black(); - } -} - - lv_color_t lv_color_get_palette_darken_1(lv_color_palette_t palette) -{ - switch(palette) { - case LV_COLOR_PALETTE_RED: return lv_color_red_darken_1(); - case LV_COLOR_PALETTE_PINK: return lv_color_pink_darken_1(); - case LV_COLOR_PALETTE_PURPLE: return lv_color_purple_darken_1(); - case LV_COLOR_PALETTE_DEEP_PURPLE: return lv_color_deep_purple_darken_1(); - case LV_COLOR_PALETTE_INDIGO: return lv_color_indigo_darken_1(); - case LV_COLOR_PALETTE_BLUE: return lv_color_blue_darken_1(); - case LV_COLOR_PALETTE_LIGHT_BLUE: return lv_color_light_blue_darken_1(); - case LV_COLOR_PALETTE_CYAN: return lv_color_cyan_darken_1(); - case LV_COLOR_PALETTE_TEAL: return lv_color_teal_darken_1(); - case LV_COLOR_PALETTE_GREEN: return lv_color_green_darken_1(); - case LV_COLOR_PALETTE_LIGHT_GREEN: return lv_color_light_green_darken_1(); - case LV_COLOR_PALETTE_LIME: return lv_color_lime_darken_1(); - case LV_COLOR_PALETTE_YELLOW: return lv_color_yellow_darken_1(); - case LV_COLOR_PALETTE_AMBER: return lv_color_amber_darken_1(); - case LV_COLOR_PALETTE_ORANGE: return lv_color_orange_darken_1(); - case LV_COLOR_PALETTE_DEEP_ORANGE: return lv_color_deep_orange_darken_1(); - case LV_COLOR_PALETTE_BROWN: return lv_color_brown_darken_1(); - case LV_COLOR_PALETTE_BLUE_GREY: return lv_color_blue_grey_darken_1(); - case LV_COLOR_PALETTE_GREY: return lv_color_grey_darken_1(); - default: return lv_color_black(); - } -} - - lv_color_t lv_color_get_palette_darken_2(lv_color_palette_t palette) -{ - switch(palette) { - case LV_COLOR_PALETTE_RED: return lv_color_red_darken_2(); - case LV_COLOR_PALETTE_PINK: return lv_color_pink_darken_2(); - case LV_COLOR_PALETTE_PURPLE: return lv_color_purple_darken_2(); - case LV_COLOR_PALETTE_DEEP_PURPLE: return lv_color_deep_purple_darken_2(); - case LV_COLOR_PALETTE_INDIGO: return lv_color_indigo_darken_2(); - case LV_COLOR_PALETTE_BLUE: return lv_color_blue_darken_2(); - case LV_COLOR_PALETTE_LIGHT_BLUE: return lv_color_light_blue_darken_2(); - case LV_COLOR_PALETTE_CYAN: return lv_color_cyan_darken_2(); - case LV_COLOR_PALETTE_TEAL: return lv_color_teal_darken_2(); - case LV_COLOR_PALETTE_GREEN: return lv_color_green_darken_2(); - case LV_COLOR_PALETTE_LIGHT_GREEN: return lv_color_light_green_darken_2(); - case LV_COLOR_PALETTE_LIME: return lv_color_lime_darken_2(); - case LV_COLOR_PALETTE_YELLOW: return lv_color_yellow_darken_2(); - case LV_COLOR_PALETTE_AMBER: return lv_color_amber_darken_2(); - case LV_COLOR_PALETTE_ORANGE: return lv_color_orange_darken_2(); - case LV_COLOR_PALETTE_DEEP_ORANGE: return lv_color_deep_orange_darken_2(); - case LV_COLOR_PALETTE_BROWN: return lv_color_brown_darken_2(); - case LV_COLOR_PALETTE_BLUE_GREY: return lv_color_blue_grey_darken_2(); - case LV_COLOR_PALETTE_GREY: return lv_color_grey_darken_2(); - default: return lv_color_black(); - } -} - - lv_color_t lv_color_get_palette_darken_3(lv_color_palette_t palette) -{ - switch(palette) { - case LV_COLOR_PALETTE_RED: return lv_color_red_darken_3(); - case LV_COLOR_PALETTE_PINK: return lv_color_pink_darken_3(); - case LV_COLOR_PALETTE_PURPLE: return lv_color_purple_darken_3(); - case LV_COLOR_PALETTE_DEEP_PURPLE: return lv_color_deep_purple_darken_3(); - case LV_COLOR_PALETTE_INDIGO: return lv_color_indigo_darken_3(); - case LV_COLOR_PALETTE_BLUE: return lv_color_blue_darken_3(); - case LV_COLOR_PALETTE_LIGHT_BLUE: return lv_color_light_blue_darken_3(); - case LV_COLOR_PALETTE_CYAN: return lv_color_cyan_darken_3(); - case LV_COLOR_PALETTE_TEAL: return lv_color_teal_darken_3(); - case LV_COLOR_PALETTE_GREEN: return lv_color_green_darken_3(); - case LV_COLOR_PALETTE_LIGHT_GREEN: return lv_color_light_green_darken_3(); - case LV_COLOR_PALETTE_LIME: return lv_color_lime_darken_3(); - case LV_COLOR_PALETTE_YELLOW: return lv_color_yellow_darken_3(); - case LV_COLOR_PALETTE_AMBER: return lv_color_amber_darken_3(); - case LV_COLOR_PALETTE_ORANGE: return lv_color_orange_darken_3(); - case LV_COLOR_PALETTE_DEEP_ORANGE: return lv_color_deep_orange_darken_3(); - case LV_COLOR_PALETTE_BROWN: return lv_color_brown_darken_3(); - case LV_COLOR_PALETTE_BLUE_GREY: return lv_color_blue_grey_darken_3(); - case LV_COLOR_PALETTE_GREY: return lv_color_grey_darken_3(); - default: return lv_color_black(); - } -} - - lv_color_t lv_color_get_palette_darken_4(lv_color_palette_t palette) -{ - switch(palette) { - case LV_COLOR_PALETTE_RED: return lv_color_red_darken_4(); - case LV_COLOR_PALETTE_PINK: return lv_color_pink_darken_4(); - case LV_COLOR_PALETTE_PURPLE: return lv_color_purple_darken_4(); - case LV_COLOR_PALETTE_DEEP_PURPLE: return lv_color_deep_purple_darken_4(); - case LV_COLOR_PALETTE_INDIGO: return lv_color_indigo_darken_4(); - case LV_COLOR_PALETTE_BLUE: return lv_color_blue_darken_4(); - case LV_COLOR_PALETTE_LIGHT_BLUE: return lv_color_light_blue_darken_4(); - case LV_COLOR_PALETTE_CYAN: return lv_color_cyan_darken_4(); - case LV_COLOR_PALETTE_TEAL: return lv_color_teal_darken_4(); - case LV_COLOR_PALETTE_GREEN: return lv_color_green_darken_4(); - case LV_COLOR_PALETTE_LIGHT_GREEN: return lv_color_light_green_darken_4(); - case LV_COLOR_PALETTE_LIME: return lv_color_lime_darken_4(); - case LV_COLOR_PALETTE_YELLOW: return lv_color_yellow_darken_4(); - case LV_COLOR_PALETTE_AMBER: return lv_color_amber_darken_4(); - case LV_COLOR_PALETTE_ORANGE: return lv_color_orange_darken_4(); - case LV_COLOR_PALETTE_DEEP_ORANGE: return lv_color_deep_orange_darken_4(); - case LV_COLOR_PALETTE_BROWN: return lv_color_brown_darken_4(); - case LV_COLOR_PALETTE_BLUE_GREY: return lv_color_blue_grey_darken_4(); - case LV_COLOR_PALETTE_GREY: return lv_color_grey_darken_4(); - default: return lv_color_black(); - } -} diff --git a/src/misc/lv_color.h b/src/misc/lv_color.h index 7114b3aa9..2a35fb173 100644 --- a/src/misc/lv_color.h +++ b/src/misc/lv_color.h @@ -276,28 +276,28 @@ typedef struct _lv_color_filter_dsc_t { typedef enum { - LV_COLOR_PALETTE_RED, - LV_COLOR_PALETTE_PINK, - LV_COLOR_PALETTE_PURPLE, - LV_COLOR_PALETTE_DEEP_PURPLE, - LV_COLOR_PALETTE_INDIGO, - LV_COLOR_PALETTE_BLUE, - LV_COLOR_PALETTE_LIGHT_BLUE, - LV_COLOR_PALETTE_CYAN, - LV_COLOR_PALETTE_TEAL, - LV_COLOR_PALETTE_GREEN, - LV_COLOR_PALETTE_LIGHT_GREEN, - LV_COLOR_PALETTE_LIME, - LV_COLOR_PALETTE_YELLOW, - LV_COLOR_PALETTE_AMBER, - LV_COLOR_PALETTE_ORANGE, - LV_COLOR_PALETTE_DEEP_ORANGE, - LV_COLOR_PALETTE_BROWN, - LV_COLOR_PALETTE_BLUE_GREY, - LV_COLOR_PALETTE_GREY, - _LV_COLOR_PALETTE_LAST, - LV_COLOR_PALETTE_NONE = 0xff, -}lv_color_palette_t; + LV_PALETTE_RED, + LV_PALETTE_PINK, + LV_PALETTE_PURPLE, + LV_PALETTE_DEEP_PURPLE, + LV_PALETTE_INDIGO, + LV_PALETTE_BLUE, + LV_PALETTE_LIGHT_BLUE, + LV_PALETTE_CYAN, + LV_PALETTE_TEAL, + LV_PALETTE_GREEN, + LV_PALETTE_LIGHT_GREEN, + LV_PALETTE_LIME, + LV_PALETTE_YELLOW, + LV_PALETTE_AMBER, + LV_PALETTE_ORANGE, + LV_PALETTE_DEEP_ORANGE, + LV_PALETTE_BROWN, + LV_PALETTE_BLUE_GREY, + LV_PALETTE_GREY, + _LV_PALETTE_LAST, + LV_PALETTE_NONE = 0xff, +}lv_palette_t; /********************** * GLOBAL PROTOTYPES @@ -656,243 +656,36 @@ 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); -lv_color_t lv_color_get_palette_main(lv_color_palette_t palette); +lv_color_t lv_color_get_palette_main(lv_palette_t palette); -lv_color_t lv_color_get_palette_lighten_1(lv_color_palette_t palette); +lv_color_t lv_color_get_palette_lighten_1(lv_palette_t palette); -lv_color_t lv_color_get_palette_lighten_2(lv_color_palette_t palette); +lv_color_t lv_color_get_palette_lighten_2(lv_palette_t palette); -lv_color_t lv_color_get_palette_lighten_3(lv_color_palette_t palette); +lv_color_t lv_color_get_palette_lighten_3(lv_palette_t palette); -lv_color_t lv_color_get_palette_lighten_4(lv_color_palette_t palette); +lv_color_t lv_color_get_palette_lighten_4(lv_palette_t palette); -lv_color_t lv_color_get_palette_lighten_5(lv_color_palette_t palette); +lv_color_t lv_color_get_palette_lighten_5(lv_palette_t palette); -lv_color_t lv_color_get_palette_darken_1(lv_color_palette_t palette); +lv_color_t lv_color_get_palette_darken_1(lv_palette_t palette); -lv_color_t lv_color_get_palette_darken_2(lv_color_palette_t palette); +lv_color_t lv_color_get_palette_darken_2(lv_palette_t palette); -lv_color_t lv_color_get_palette_darken_3(lv_color_palette_t palette); +lv_color_t lv_color_get_palette_darken_3(lv_palette_t palette); -lv_color_t lv_color_get_palette_darken_4(lv_color_palette_t palette); +lv_color_t lv_color_get_palette_darken_4(lv_palette_t palette); /********************** * 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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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); } - +lv_color_t lv_palette_main(lv_palette_t p); +static inline lv_color_t lv_color_white(void) { return LV_COLOR_MAKE(0xff, 0xff, 0xff);}; +static inline lv_color_t lv_color_black(void) { return LV_COLOR_MAKE(0x00, 0x0, 0x00);}; +lv_color_t lv_palette_lighten(lv_palette_t p, uint8_t lvl); +lv_color_t lv_palette_darken(lv_palette_t p, uint8_t lvl); /********************** * MACROS **********************/ diff --git a/src/misc/lv_style.h b/src/misc/lv_style.h index ed97f533d..a24113181 100644 --- a/src/misc/lv_style.h +++ b/src/misc/lv_style.h @@ -287,7 +287,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_palette_main(LV_PALETTE_RED)); */ lv_style_prop_t lv_style_register_prop(void); diff --git a/tests/lv_test_core/lv_test_style.c b/tests/lv_test_core/lv_test_style.c index ed220b02c..46336c96b 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_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_RED)); +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, lv_palette_main(LV_PALETTE_BLUE)); +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, lv_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_RED)); // -// _lv_style_set_color(&style3, LV_STYLE_IMAGE_RECOLOR, lv_color_red()); +// _lv_style_set_color(&style3, LV_STYLE_IMAGE_RECOLOR, lv_palette_main(LV_PALETTE_RED)); // // lv_style_reset(&style1); // lv_style_reset(&style2); @@ -483,9 +483,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_palette_main(LV_PALETTE_RED)); +// _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, lv_palette_main(LV_PALETTE_RED)); +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, lv_palette_main(LV_PALETTE_RED)); // // _lv_style_list_add_style(&style_list, &style1); // _lv_style_list_remove_style(&style_list, &style1); @@ -509,11 +509,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_palette_main(LV_PALETTE_RED)); +// _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, lv_palette_main(LV_PALETTE_RED)); +// _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, lv_palette_main(LV_PALETTE_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_palette_main(LV_PALETTE_RED)); // // _lv_style_list_add_style(&style_list, &style1); // _lv_style_list_remove_style(&style_list, &style1); @@ -524,7 +524,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_palette_main(LV_PALETTE_RED)); // // _lv_style_list_reset(&style_list); // lv_style_reset(&style1); @@ -545,9 +545,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_palette_main(LV_PALETTE_RED)); +// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, lv_palette_main(LV_PALETTE_BLUE)); +// _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, lv_palette_main(LV_PALETTE_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);