From 0422e662d947198a2da6e0ad2c3ba3101f274490 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 25 Nov 2019 06:42:11 +0100 Subject: [PATCH] lv_color.h use 1 common lv_color_make --- src/lv_misc/lv_color.h | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index 8361ef282..d72c6bab2 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -465,23 +465,8 @@ static inline uint8_t lv_color_brightness(lv_color_t color) /* The most simple macro to create a color from R,G and B values */ #if LV_COLOR_DEPTH == 1 #define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){.full = (b8 >> 7 | g8 >> 7 | r8 >> 7)}) -static inline lv_color_t lv_color_make(int r8, int g8, int b8) -{ - lv_color_t color = { 0 }; - color.full = (b8 >> 7 | g8 >> 7 | r8 >> 7); - return color; -} #elif LV_COLOR_DEPTH == 8 #define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8 >> 6, g8 >> 5, r8 >> 5}}) -static inline lv_color_t lv_color_make(uint8_t r8, int g8, int b8) -{ - lv_color_t color; - LV_COLOR_SET_B(color, b8 >> 6); - LV_COLOR_SET_G(color, g8 >> 5); - LV_COLOR_SET_R(color, r8 >> 5); - LV_COLOR_SET_A(color, 0xFF); - return color; -} #elif LV_COLOR_DEPTH == 16 #if LV_COLOR_16_SWAP == 0 #define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8 >> 3, g8 >> 2, r8 >> 3}}) @@ -489,27 +474,15 @@ static inline lv_color_t lv_color_make(uint8_t r8, int g8, int b8) #define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{g8 >> 5, r8 >> 3, b8 >> 3, (g8 >> 2) & 0x7}}) #endif static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8) -{ - lv_color_t color; - LV_COLOR_SET_B(color, b8 >> 3); - LV_COLOR_SET_G(color, g8 >> 2); - LV_COLOR_SET_R(color, r8 >> 3); - LV_COLOR_SET_A(color, 0xFF); - return color; -} #elif LV_COLOR_DEPTH == 32 #define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/ -static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8) -{ - lv_color_t color; - LV_COLOR_SET_B(color, b8); - LV_COLOR_SET_G(color, g8); - LV_COLOR_SET_R(color, r8); - LV_COLOR_SET_A(color, 0xFF); - return color; -} #endif +static inline lv_color_t lv_color_make(uint8_t r, uint8_t g, uint8_t b) +{ + return LV_COLOR_MAKE(r, g, b); +} + static inline lv_color_t lv_color_hex(uint32_t c) { return lv_color_make((uint8_t)((c >> 16) & 0xFF), (uint8_t)((c >> 8) & 0xFF), (uint8_t)(c & 0xFF));