add LV_COLOR_SET/GET_R/G/B
It was mainly because when LV_COLOR_16_SWAP = 1 and green is split to green_h and green_l
This commit is contained in:
@@ -475,7 +475,7 @@
|
|||||||
|
|
||||||
/* If a character is at least this long, will break wherever "prettiest" */
|
/* If a character is at least this long, will break wherever "prettiest" */
|
||||||
#ifndef LV_TXT_LINE_BREAK_LONG_LEN
|
#ifndef LV_TXT_LINE_BREAK_LONG_LEN
|
||||||
#define LV_TXT_LINE_BREAK_LONG_LEN 12
|
#define LV_TXT_LINE_BREAK_LONG_LEN 120
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Minimum number of characters of a word to put on a line before a break */
|
/* Minimum number of characters of a word to put on a line before a break */
|
||||||
|
|||||||
@@ -343,11 +343,7 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t font_rgb[3];
|
uint8_t font_rgb[3];
|
||||||
#if LV_COLOR_16_SWAP == 0
|
uint8_t txt_rgb[3] = {LV_COLOR_GET_R(color), LV_COLOR_GET_G(color), LV_COLOR_GET_B(color)};
|
||||||
uint8_t txt_rgb[3] = {color.ch.red, color.ch.green, color.ch.blue};
|
|
||||||
#else
|
|
||||||
uint8_t txt_rgb[3] = {color.ch.red, (color.ch.green_h << 3) + color.ch.green_l, color.ch.blue};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for(row = row_start; row < row_end; row++) {
|
for(row = row_start; row < row_end; row++) {
|
||||||
bitmask = bitmask_init >> col_bit;
|
bitmask = bitmask_init >> col_bit;
|
||||||
@@ -407,30 +403,16 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv
|
|||||||
res_color = *vdb_buf_tmp;
|
res_color = *vdb_buf_tmp;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
#if LV_COLOR_16_SWAP == 0
|
uint8_t bg_rgb[3] = {LV_COLOR_GET_R(*vdb_buf_tmp), LV_COLOR_GET_G(*vdb_buf_tmp), LV_COLOR_GET_B(*vdb_buf_tmp)};
|
||||||
uint8_t bg_rgb[3] = {vdb_buf_tmp->ch.red, vdb_buf_tmp->ch.green, vdb_buf_tmp->ch.blue};
|
|
||||||
#else
|
|
||||||
uint8_t bg_rgb[3] = {vdb_buf_tmp->ch.red,
|
|
||||||
(vdb_buf_tmp->ch.green_h << 3) + vdb_buf_tmp->ch.green_l,
|
|
||||||
vdb_buf_tmp->ch.blue};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if LV_SUBPX_BGR
|
#if LV_SUBPX_BGR
|
||||||
res_color.ch.blue = (uint16_t)((uint16_t)txt_rgb[0] * font_rgb[0] + (bg_rgb[2] * (255 - font_rgb[0]))) >> 8;
|
LV_COLOR_SET_B(res_color, (uint16_t)((uint16_t)txt_rgb[0] * font_rgb[0] + (bg_rgb[2] * (255 - font_rgb[0]))) >> 8);
|
||||||
res_color.ch.red = (uint16_t)((uint16_t)txt_rgb[2] * font_rgb[2] + (bg_rgb[0] * (255 - font_rgb[2]))) >> 8;
|
LV_COLOR_SET_R(res_color, (uint16_t)((uint16_t)txt_rgb[2] * font_rgb[2] + (bg_rgb[0] * (255 - font_rgb[2]))) >> 8);
|
||||||
#else
|
#else
|
||||||
res_color.ch.red = (uint16_t)((uint16_t)txt_rgb[0] * font_rgb[0] + (bg_rgb[0] * (255 - font_rgb[0]))) >> 8;
|
LV_COLOR_SET_R(res_color, (uint16_t)((uint16_t)txt_rgb[0] * font_rgb[0] + (bg_rgb[0] * (255 - font_rgb[0]))) >> 8);
|
||||||
res_color.ch.blue = (uint16_t)((uint16_t)txt_rgb[2] * font_rgb[2] + (bg_rgb[2] * (255 - font_rgb[2]))) >> 8;
|
LV_COLOR_SET_B(res_color, (uint16_t)((uint16_t)txt_rgb[2] * font_rgb[2] + (bg_rgb[2] * (255 - font_rgb[2]))) >> 8);
|
||||||
#endif
|
#endif
|
||||||
|
LV_COLOR_SET_G(res_color, (uint16_t)((uint16_t)txt_rgb[1] * font_rgb[1] + (bg_rgb[1] * (255 - font_rgb[1]))) >> 8);
|
||||||
#if LV_COLOR_16_SWAP == 0
|
|
||||||
res_color.ch.green = (uint16_t)((uint16_t)txt_rgb[1] * font_rgb[1] + (bg_rgb[1] * (255 - font_rgb[1]))) >> 8;
|
|
||||||
#else
|
|
||||||
uint8_t green = (uint16_t)((uint16_t)txt_rgb[1] * font_rgb[1] + (bg_rgb[1] * (255 - font_rgb[1]))) >> 8;
|
|
||||||
res_color.ch.green_h = green >> 3;
|
|
||||||
res_color.ch.green_l = green & 0x7;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if(scr_transp == false) {
|
if(scr_transp == false) {
|
||||||
vdb_buf_tmp->full = res_color.full;
|
vdb_buf_tmp->full = res_color.full;
|
||||||
|
|||||||
@@ -90,6 +90,55 @@ enum {
|
|||||||
#error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!"
|
#error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*-----------------------
|
||||||
|
* Macros to set/get values
|
||||||
|
* of the color channels
|
||||||
|
*-----------------------*/
|
||||||
|
#if LV_COLOR_DEPTH == 1
|
||||||
|
# define LV_COLOR_SET_R(c, v) (c).ch.red = v & 0x1;
|
||||||
|
# define LV_COLOR_SET_G(c, v) (c).ch.green = v & 0x1;
|
||||||
|
# define LV_COLOR_SET_B(c, v) (c).ch.blue = v & 0x1;
|
||||||
|
|
||||||
|
# define LV_COLOR_GET_R(c) (c).ch.red
|
||||||
|
# define LV_COLOR_GET_G(c) (c).ch.green
|
||||||
|
# define LV_COLOR_GET_B(c) (c).ch.blue
|
||||||
|
|
||||||
|
#elif LV_COLOR_DEPTH == 8
|
||||||
|
# define LV_COLOR_SET_R(c, v) (c).ch.red = v & 0x7;
|
||||||
|
# define LV_COLOR_SET_G(c, v) (c).ch.green = v & 0x7;
|
||||||
|
# define LV_COLOR_SET_B(c, v) c(c).ch.blue = v & 0x3;
|
||||||
|
|
||||||
|
# define LV_COLOR_GET_R(c) (c).ch.red
|
||||||
|
# define LV_COLOR_GET_G(c) (c).ch.green
|
||||||
|
# define LV_COLOR_GET_B(c) (c).ch.blue
|
||||||
|
|
||||||
|
#elif LV_COLOR_DEPTH == 16
|
||||||
|
# define LV_COLOR_SET_R(c, v) (c).ch.red = v & 0x1F;
|
||||||
|
# if LV_COLOR_16_SWAP == 0
|
||||||
|
# define LV_COLOR_SET_G(c, v) (c).ch.green = v & 0x3F;
|
||||||
|
# else
|
||||||
|
# define LV_COLOR_SET_G(c, v) {(c).ch.green_h = ((v) >> 3) & 0x3; (c).ch.green_l = (v) & 0x3;}
|
||||||
|
# endif
|
||||||
|
# define LV_COLOR_SET_B(c, v) (c).ch.blue= v & 0x1F;
|
||||||
|
|
||||||
|
# define LV_COLOR_GET_R(c) (c).ch.red
|
||||||
|
# if LV_COLOR_16_SWAP == 0
|
||||||
|
# define LV_COLOR_GET_G(c) (c).ch.green
|
||||||
|
# else
|
||||||
|
# define LV_COLOR_GET_G(c) (((c).ch.green_h << 3) + (c).ch.green_l)
|
||||||
|
# endif
|
||||||
|
# define LV_COLOR_GET_B(c) (c).ch.blue
|
||||||
|
|
||||||
|
#elif LV_COLOR_DEPTH == 32
|
||||||
|
# define LV_COLOR_SET_R(c, v) (c).ch.red = v & 0xFF;
|
||||||
|
# define LV_COLOR_SET_G(c, v) (c).ch.green = v & 0xFF;
|
||||||
|
# define LV_COLOR_SET_B(c, v) (c).ch.blue = v & 0xFF;
|
||||||
|
|
||||||
|
# define LV_COLOR_GET_R(c) (c).ch.red
|
||||||
|
# define LV_COLOR_GET_G(c) (c).ch.green
|
||||||
|
# define LV_COLOR_GET_B(c) (c).ch.blue
|
||||||
|
#endif
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
**********************/
|
**********************/
|
||||||
@@ -194,24 +243,19 @@ static inline uint8_t lv_color_to1(lv_color_t color)
|
|||||||
#if LV_COLOR_DEPTH == 1
|
#if LV_COLOR_DEPTH == 1
|
||||||
return color.full;
|
return color.full;
|
||||||
#elif LV_COLOR_DEPTH == 8
|
#elif LV_COLOR_DEPTH == 8
|
||||||
if((color.ch.red & 0x4) || (color.ch.green & 0x4) || (color.ch.blue & 0x2)) {
|
if((LV_COLOR_GET_R(color) & 0x4) || (LV_COLOR_GET_G(color) & 0x4) || (LV_COLOR_GET_B(color) & 0x2)) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#elif LV_COLOR_DEPTH == 16
|
#elif LV_COLOR_DEPTH == 16
|
||||||
#if LV_COLOR_16_SWAP == 0
|
if((LV_COLOR_GET_R(color) & 0x10) || (LV_COLOR_GET_G(color) & 0x20) || (LV_COLOR_GET_B(color) & 0x10)) {
|
||||||
if((color.ch.red & 0x10) || (color.ch.green & 0x20) || (color.ch.blue & 0x10)) {
|
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
|
||||||
if((color.ch.red & 0x10) || (color.ch.green_h & 0x20) || (color.ch.blue & 0x10)) {
|
|
||||||
return 1;
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#elif LV_COLOR_DEPTH == 32
|
#elif LV_COLOR_DEPTH == 32
|
||||||
if((color.ch.red & 0x80) || (color.ch.green & 0x80) || (color.ch.blue & 0x80)) {
|
if((cLV_COLOR_GET_R(color) & 0x80) || (LV_COLOR_GET_G(color) & 0x80) || (LV_COLOR_GET_B(color) & 0x80)) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -229,25 +273,16 @@ static inline uint8_t lv_color_to8(lv_color_t color)
|
|||||||
#elif LV_COLOR_DEPTH == 8
|
#elif LV_COLOR_DEPTH == 8
|
||||||
return color.full;
|
return color.full;
|
||||||
#elif LV_COLOR_DEPTH == 16
|
#elif LV_COLOR_DEPTH == 16
|
||||||
|
|
||||||
#if LV_COLOR_16_SWAP == 0
|
|
||||||
lv_color8_t ret;
|
lv_color8_t ret;
|
||||||
ret.ch.red = color.ch.red >> 2; /* 5 - 3 = 2*/
|
ret.ch.red = LV_COLOR_GET_R(color) >> 2; /* 5 - 3 = 2*/
|
||||||
ret.ch.green = color.ch.green >> 3; /* 6 - 3 = 3*/
|
ret.ch.green = LV_COLOR_GET_G(color) >> 3; /* 6 - 3 = 3*/
|
||||||
ret.ch.blue = color.ch.blue >> 3; /* 5 - 2 = 3*/
|
ret.ch.blue = LV_COLOR_GET_B(color) >> 3; /* 5 - 2 = 3*/
|
||||||
return ret.full;
|
return ret.full;
|
||||||
#else
|
|
||||||
lv_color8_t ret;
|
|
||||||
ret.ch.red = color.ch.red >> 2; /* 5 - 3 = 2*/
|
|
||||||
ret.ch.green = color.ch.green_h; /* 6 - 3 = 3*/
|
|
||||||
ret.ch.blue = color.ch.blue >> 3; /* 5 - 2 = 3*/
|
|
||||||
return ret.full;
|
|
||||||
#endif
|
|
||||||
#elif LV_COLOR_DEPTH == 32
|
#elif LV_COLOR_DEPTH == 32
|
||||||
lv_color8_t ret;
|
lv_color8_t ret;
|
||||||
ret.ch.red = color.ch.red >> 5; /* 8 - 3 = 5*/
|
ret.ch.red = LV_COLOR_GET_R(color) >> 5; /* 8 - 3 = 5*/
|
||||||
ret.ch.green = color.ch.green >> 5; /* 8 - 3 = 5*/
|
ret.ch.green = LV_COLOR_GET_G(color) >> 5; /* 8 - 3 = 5*/
|
||||||
ret.ch.blue = color.ch.blue >> 6; /* 8 - 2 = 6*/
|
ret.ch.blue = LV_COLOR_GET_B(color) >> 6; /* 8 - 2 = 6*/
|
||||||
return ret.full;
|
return ret.full;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -261,32 +296,29 @@ static inline uint16_t lv_color_to16(lv_color_t color)
|
|||||||
return 0xFFFF;
|
return 0xFFFF;
|
||||||
#elif LV_COLOR_DEPTH == 8
|
#elif LV_COLOR_DEPTH == 8
|
||||||
lv_color16_t ret;
|
lv_color16_t ret;
|
||||||
|
ret.ch.red = LV_COLOR_GET_R(color) * 4; /*(2^5 - 1)/(2^3 - 1) = 31/7 = 4*/
|
||||||
#if LV_COLOR_16_SWAP == 0
|
#if LV_COLOR_16_SWAP == 0
|
||||||
ret.ch.red = color.ch.red * 4; /*(2^5 - 1)/(2^3 - 1) = 31/7 = 4*/
|
ret.ch.green = LV_COLOR_GET_G(color) * 9; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/
|
||||||
ret.ch.green = color.ch.green * 9; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/
|
|
||||||
ret.ch.blue = color.ch.blue * 10; /*(2^5 - 1)/(2^2 - 1) = 31/3 = 10*/
|
|
||||||
#else
|
#else
|
||||||
ret.red = color.ch.red * 4;
|
ret.ch.green_h = (LV_COLOR_GET_G(color) * 9) >> 3; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/
|
||||||
uint8_t g_tmp = color.ch.green * 9;
|
ret.ch.green_l = (LV_COLOR_GET_G(color) * 9) & 0x7;
|
||||||
ret.ch.green_h = (g_tmp & 0x1F) >> 3;
|
|
||||||
ret.ch.green_l = g_tmp & 0x07;
|
|
||||||
ret.ch.blue = color.ch.blue * 10;
|
|
||||||
#endif
|
#endif
|
||||||
|
ret.ch.blue = LV_COLOR_GET_B(color) * 10; /*(2^5 - 1)/(2^2 - 1) = 31/3 = 10*/
|
||||||
return ret.full;
|
return ret.full;
|
||||||
#elif LV_COLOR_DEPTH == 16
|
#elif LV_COLOR_DEPTH == 16
|
||||||
return color.full;
|
return color.full;
|
||||||
#elif LV_COLOR_DEPTH == 32
|
#elif LV_COLOR_DEPTH == 32
|
||||||
lv_color16_t ret;
|
lv_color16_t ret;
|
||||||
|
ret.ch.red = LV_COLOR_GET_R(color) >> 3; /* 8 - 5 = 3*/
|
||||||
|
|
||||||
#if LV_COLOR_16_SWAP == 0
|
#if LV_COLOR_16_SWAP == 0
|
||||||
ret.ch.red = color.ch.red >> 3; /* 8 - 5 = 3*/
|
ret.ch.green = LV_COLOR_GET_G(color) >> 2; /* 8 - 6 = 2*/
|
||||||
ret.ch.green = color.ch.green >> 2; /* 8 - 6 = 2*/
|
|
||||||
ret.ch.blue = color.ch.blue >> 3; /* 8 - 5 = 3*/
|
|
||||||
#else
|
#else
|
||||||
ret.ch.red = color.ch.red >> 3;
|
ret.ch.green_h = (LV_COLOR_GET_G(color) >> 5; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/
|
||||||
ret.ch.green_h = (color.ch.green & 0xE0) >> 5;
|
ret.ch.green_l = (LV_COLOR_GET_G(color) >> 2) & 0x7;
|
||||||
ret.ch.green_l = (color.ch.green & 0x1C) >> 2;
|
|
||||||
ret.ch.blue = color.ch.blue >> 3;
|
|
||||||
#endif
|
#endif
|
||||||
|
ret.ch.green = LV_COLOR_GET_G(color) >> 2; /* 8 - 6 = 2*/
|
||||||
|
ret.ch.blue = LV_COLOR_GET_B(color) >> 3; /* 8 - 5 = 3*/
|
||||||
return ret.full;
|
return ret.full;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -300,9 +332,9 @@ static inline uint32_t lv_color_to32(lv_color_t color)
|
|||||||
return 0xFFFFFFFF;
|
return 0xFFFFFFFF;
|
||||||
#elif LV_COLOR_DEPTH == 8
|
#elif LV_COLOR_DEPTH == 8
|
||||||
lv_color32_t ret;
|
lv_color32_t ret;
|
||||||
ret.ch.red = color.ch.red * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/
|
ret.ch.red = LV_COLOR_GET_R(color) * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/
|
||||||
ret.ch.green = color.ch.green * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/
|
ret.ch.green = LV_COLOR_GET_G(color) * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/
|
||||||
ret.ch.blue = color.ch.blue * 85; /*(2^8 - 1)/(2^2 - 1) = 255/3 = 85*/
|
ret.ch.blue = LV_COLOR_GET_B(color) * 85; /*(2^8 - 1)/(2^2 - 1) = 255/3 = 85*/
|
||||||
ret.ch.alpha = 0xFF;
|
ret.ch.alpha = 0xFF;
|
||||||
return ret.full;
|
return ret.full;
|
||||||
#elif LV_COLOR_DEPTH == 16
|
#elif LV_COLOR_DEPTH == 16
|
||||||
@@ -335,13 +367,9 @@ static inline uint32_t lv_color_to32(lv_color_t color)
|
|||||||
* 6 259 3 0 255
|
* 6 259 3 0 255
|
||||||
*/
|
*/
|
||||||
lv_color32_t ret;
|
lv_color32_t ret;
|
||||||
ret.ch.red = ( color.ch.red * 263 + 7 ) >> 5;
|
ret.ch.red = (LV_COLOR_GET_R(color) * 263 + 7 ) >> 5;
|
||||||
#if LV_COLOR_16_SWAP == 0
|
ret.ch.green = (LV_COLOR_GET_G(color) * 259 + 3 ) >> 6;
|
||||||
ret.ch.green = ( color.ch.green * 259 + 3 ) >> 6;
|
ret.ch.blue = (LV_COLOR_GET_B(color) * 263 + 7 ) >> 5;
|
||||||
#else
|
|
||||||
ret.ch.green = (((color.ch.green_h << 3) + color.ch.green_l) * 259 + 3 ) >> 6;
|
|
||||||
#endif
|
|
||||||
ret.ch.blue = ( color.ch.blue * 263 + 7 ) >> 5;
|
|
||||||
ret.ch.alpha = 0xFF;
|
ret.ch.alpha = 0xFF;
|
||||||
return ret.full;
|
return ret.full;
|
||||||
#elif LV_COLOR_DEPTH == 32
|
#elif LV_COLOR_DEPTH == 32
|
||||||
@@ -354,18 +382,9 @@ static inline lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix)
|
|||||||
lv_color_t ret;
|
lv_color_t ret;
|
||||||
#if LV_COLOR_DEPTH != 1
|
#if LV_COLOR_DEPTH != 1
|
||||||
/*LV_COLOR_DEPTH == 8, 16 or 32*/
|
/*LV_COLOR_DEPTH == 8, 16 or 32*/
|
||||||
ret.ch.red = (uint16_t)((uint16_t)c1.ch.red * mix + (c2.ch.red * (255 - mix))) >> 8;
|
LV_COLOR_SET_R(ret, (uint16_t)((uint16_t) LV_COLOR_GET_R(c1) * mix + LV_COLOR_GET_R(c2) * (255 - mix)) >> 8);
|
||||||
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP
|
LV_COLOR_SET_G(ret, (uint16_t)((uint16_t) LV_COLOR_GET_G(c1) * mix + LV_COLOR_GET_G(c2) * (255 - mix)) >> 8);
|
||||||
/*If swapped Green is in 2 parts*/
|
LV_COLOR_SET_B(ret, (uint16_t)((uint16_t) LV_COLOR_GET_B(c1) * mix + LV_COLOR_GET_B(c2) * (255 - mix)) >> 8);
|
||||||
uint16_t g_1 = (c1.ch.green_h << 3) + c1.ch.green_l;
|
|
||||||
uint16_t g_2 = (c2.ch.green_h << 3) + c2.ch.green_l;
|
|
||||||
uint16_t g_out = (uint16_t)((uint16_t)g_1 * mix + (g_2 * (255 - mix))) >> 8;
|
|
||||||
ret.ch.green_h = g_out >> 3;
|
|
||||||
ret.ch.green_l = g_out & 0x7;
|
|
||||||
#else
|
|
||||||
ret.ch.green = (uint16_t)((uint16_t)c1.ch.green * mix + (c2.ch.green * (255 - mix))) >> 8;
|
|
||||||
#endif
|
|
||||||
ret.ch.blue = (uint16_t)((uint16_t)c1.ch.blue * mix + (c2.ch.blue * (255 - mix))) >> 8;
|
|
||||||
#if LV_COLOR_DEPTH == 32
|
#if LV_COLOR_DEPTH == 32
|
||||||
ret.ch.alpha = 0xFF;
|
ret.ch.alpha = 0xFF;
|
||||||
#endif
|
#endif
|
||||||
@@ -386,7 +405,7 @@ static inline uint8_t lv_color_brightness(lv_color_t color)
|
|||||||
{
|
{
|
||||||
lv_color32_t c32;
|
lv_color32_t c32;
|
||||||
c32.full = lv_color_to32(color);
|
c32.full = lv_color_to32(color);
|
||||||
uint16_t bright = 3 * c32.ch.red + c32.ch.blue + 4 * c32.ch.green;
|
uint16_t bright = 3 * LV_COLOR_GET_R(c32) + LV_COLOR_GET_B(c32) + 4 * LV_COLOR_GET_G(c32);
|
||||||
return (uint16_t)bright >> 3;
|
return (uint16_t)bright >> 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -275,12 +275,8 @@ bool lv_cpicker_set_hsv(lv_obj_t * cpicker, lv_color_hsv_t hsv)
|
|||||||
*/
|
*/
|
||||||
bool lv_cpicker_set_color(lv_obj_t * cpicker, lv_color_t color)
|
bool lv_cpicker_set_color(lv_obj_t * cpicker, lv_color_t color)
|
||||||
{
|
{
|
||||||
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP != 0
|
return lv_cpicker_set_hsv(cpicker,
|
||||||
uint8_t green = (color.ch.green_h << 3) + color.ch.green_l;
|
lv_color_rgb_to_hsv(LV_COLOR_GET_R(color), LV_COLOR_GET_G(color), LV_COLOR_GET_B(color)));
|
||||||
return lv_cpicker_set_hsv(cpicker, lv_color_rgb_to_hsv(color.ch.red, green, color.ch.blue));
|
|
||||||
#else
|
|
||||||
return lv_cpicker_set_hsv(cpicker, lv_color_rgb_to_hsv(color.ch.red, color.ch.green, color.ch.blue));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user