From b7d553796171adf3bf5996236be5b469e3ef2ede Mon Sep 17 00:00:00 2001 From: Folke Will Date: Sat, 9 Feb 2019 13:46:29 +0100 Subject: [PATCH] Fix color narrowing warning --- lv_misc/lv_color.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lv_misc/lv_color.h b/lv_misc/lv_color.h index 3d2d23157..e386d69f5 100644 --- a/lv_misc/lv_color.h +++ b/lv_misc/lv_color.h @@ -393,14 +393,14 @@ static inline uint8_t lv_color_brightness(lv_color_t color) #endif -#define LV_COLOR_HEX(c) LV_COLOR_MAKE(((uint32_t)((uint32_t)c >> 16) & 0xFF), \ - ((uint32_t)((uint32_t)c >> 8) & 0xFF), \ - ((uint32_t) c & 0xFF)) +#define LV_COLOR_HEX(c) LV_COLOR_MAKE((uint8_t) ((uint32_t)((uint32_t)c >> 16) & 0xFF), \ + (uint8_t) ((uint32_t)((uint32_t)c >> 8) & 0xFF), \ + (uint8_t) ((uint32_t) c & 0xFF)) /*Usage LV_COLOR_HEX3(0x16C) which means LV_COLOR_HEX(0x1166CC)*/ -#define LV_COLOR_HEX3(c) LV_COLOR_MAKE((((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), \ - ((uint32_t)(c & 0xF0) | ((c & 0xF0) >> 4)), \ - ((uint32_t)(c & 0xF) | ((c & 0xF) << 4))) +#define LV_COLOR_HEX3(c) LV_COLOR_MAKE((uint8_t) (((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), \ + (uint8_t) ((uint32_t)(c & 0xF0) | ((c & 0xF0) >> 4)), \ + (uint8_t) ((uint32_t)(c & 0xF) | ((c & 0xF) << 4))) static inline lv_color_t lv_color_hex(uint32_t c){ return LV_COLOR_HEX(c);