16 #ifdef LV_CONF_INCLUDE_SIMPLE 19 #include "../../../lv_conf.h" 23 #if LV_COLOR_DEPTH == 24 24 #error "LV_COLOR_DEPTH 24 is deprecated. Use LV_COLOR_DEPTH 32 instead (lv_conf.h)" 27 #if LV_COLOR_DEPTH != 32 && LV_COLOR_SCREEN_TRANSP != 0 28 #error "LV_COLOR_SCREEN_TRANSP requires LV_COLOR_DEPTH == 32. Set it in lv_conf.h" 31 #if LV_COLOR_DEPTH != 16 && LV_COLOR_16_SWAP != 0 32 #error "LV_COLOR_16_SWAP requires LV_COLOR_DEPTH == 16. Set it in lv_conf.h" 40 #define LV_COLOR_WHITE LV_COLOR_MAKE(0xFF, 0xFF, 0xFF) 41 #define LV_COLOR_SILVER LV_COLOR_MAKE(0xC0, 0xC0, 0xC0) 42 #define LV_COLOR_GRAY LV_COLOR_MAKE(0x80, 0x80, 0x80) 43 #define LV_COLOR_BLACK LV_COLOR_MAKE(0x00, 0x00, 0x00) 44 #define LV_COLOR_RED LV_COLOR_MAKE(0xFF, 0x00, 0x00) 45 #define LV_COLOR_MAROON LV_COLOR_MAKE(0x80, 0x00, 0x00) 46 #define LV_COLOR_YELLOW LV_COLOR_MAKE(0xFF, 0xFF, 0x00) 47 #define LV_COLOR_OLIVE LV_COLOR_MAKE(0x80, 0x80, 0x00) 48 #define LV_COLOR_LIME LV_COLOR_MAKE(0x00, 0xFF, 0x00) 49 #define LV_COLOR_GREEN LV_COLOR_MAKE(0x00, 0x80, 0x00) 50 #define LV_COLOR_CYAN LV_COLOR_MAKE(0x00, 0xFF, 0xFF) 51 #define LV_COLOR_AQUA LV_COLOR_CYAN 52 #define LV_COLOR_TEAL LV_COLOR_MAKE(0x00, 0x80, 0x80) 53 #define LV_COLOR_BLUE LV_COLOR_MAKE(0x00, 0x00, 0xFF) 54 #define LV_COLOR_NAVY LV_COLOR_MAKE(0x00, 0x00, 0x80) 55 #define LV_COLOR_MAGENTA LV_COLOR_MAKE(0xFF, 0x00, 0xFF) 56 #define LV_COLOR_PURPLE LV_COLOR_MAKE(0x80, 0x00, 0x80) 57 #define LV_COLOR_ORANGE LV_COLOR_MAKE(0xFF, 0xA5, 0x00) 79 #define LV_OPA_MAX 251 81 #if LV_COLOR_DEPTH == 1 82 #define LV_COLOR_SIZE 8 83 #elif LV_COLOR_DEPTH == 8 84 #define LV_COLOR_SIZE 8 85 #elif LV_COLOR_DEPTH == 16 86 #define LV_COLOR_SIZE 16 87 #elif LV_COLOR_DEPTH == 32 88 #define LV_COLOR_SIZE 32 90 #error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!" 120 #if LV_COLOR_16_SWAP == 0 125 uint16_t green_h : 3;
128 uint16_t green_l : 3;
146 #if LV_COLOR_DEPTH == 1 147 typedef uint8_t lv_color_int_t;
149 #elif LV_COLOR_DEPTH == 8 150 typedef uint8_t lv_color_int_t;
152 #elif LV_COLOR_DEPTH == 16 153 typedef uint16_t lv_color_int_t;
155 #elif LV_COLOR_DEPTH == 32 156 typedef uint32_t lv_color_int_t;
159 #error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!" 189 static inline uint8_t lv_color_to1(lv_color_t color)
191 #if LV_COLOR_DEPTH == 1 193 #elif LV_COLOR_DEPTH == 8 194 if((color.ch.red & 0x4) || (color.ch.green & 0x4) || (color.ch.blue & 0x2)) {
199 #elif LV_COLOR_DEPTH == 16 200 #if LV_COLOR_16_SWAP == 0 201 if((color.ch.red & 0x10) || (color.ch.green & 0x20) || (color.ch.blue & 0x10)) {
204 if((color.ch.red & 0x10) || (color.ch.green_h & 0x20) || (color.ch.blue & 0x10)) {
210 #elif LV_COLOR_DEPTH == 32 211 if((color.ch.red & 0x80) || (color.ch.green & 0x80) || (color.ch.blue & 0x80)) {
219 static inline uint8_t lv_color_to8(lv_color_t color)
221 #if LV_COLOR_DEPTH == 1 226 #elif LV_COLOR_DEPTH == 8 228 #elif LV_COLOR_DEPTH == 16 230 #if LV_COLOR_16_SWAP == 0 232 ret.
ch.
red = color.ch.red >> 2;
233 ret.
ch.
green = color.ch.green >> 3;
234 ret.
ch.
blue = color.ch.blue >> 3;
238 ret.
ch.
red = color.ch.red >> 2;
239 ret.
ch.
green = color.ch.green_h;
240 ret.
ch.
blue = color.ch.blue >> 3;
243 #elif LV_COLOR_DEPTH == 32 245 ret.
ch.
red = color.ch.red >> 5;
246 ret.
ch.
green = color.ch.green >> 5;
247 ret.
ch.
blue = color.ch.blue >> 6;
252 static inline uint16_t lv_color_to16(lv_color_t color)
254 #if LV_COLOR_DEPTH == 1 259 #elif LV_COLOR_DEPTH == 8 261 #if LV_COLOR_16_SWAP == 0 262 ret.
ch.
red = color.ch.red * 4;
263 ret.
ch.
green = color.ch.green * 9;
264 ret.
ch.
blue = color.ch.blue * 10;
266 ret.
red = color.ch.red * 4;
267 uint8_t g_tmp = color.ch.green * 9;
268 ret.
ch.green_h = (g_tmp & 0x1F) >> 3;
269 ret.
ch.green_l = g_tmp & 0x07;
270 ret.
ch.
blue = color.ch.blue * 10;
273 #elif LV_COLOR_DEPTH == 16 275 #elif LV_COLOR_DEPTH == 32 277 #if LV_COLOR_16_SWAP == 0 278 ret.
ch.
red = color.ch.red >> 3;
279 ret.
ch.
green = color.ch.green >> 2;
280 ret.
ch.
blue = color.ch.blue >> 3;
282 ret.
ch.
red = color.ch.red >> 3;
283 ret.
ch.green_h = (color.ch.green & 0xE0) >> 5;
284 ret.
ch.green_l = (color.ch.green & 0x1C) >> 2;
285 ret.
ch.
blue = color.ch.blue >> 3;
291 static inline uint32_t lv_color_to32(lv_color_t color)
293 #if LV_COLOR_DEPTH == 1 298 #elif LV_COLOR_DEPTH == 8 300 ret.
ch.
red = color.ch.red * 36;
301 ret.
ch.
green = color.ch.green * 36;
302 ret.
ch.
blue = color.ch.blue * 85;
305 #elif LV_COLOR_DEPTH == 16 306 #if LV_COLOR_16_SWAP == 0 308 ret.
ch.
red = color.ch.red * 8;
309 ret.
ch.
green = color.ch.green * 4;
310 ret.
ch.
blue = color.ch.blue * 8;
315 ret.
ch.
red = color.ch.red * 8;
316 ret.
ch.
green = ((color.ch.green_h << 3) + color.ch.green_l) * 4;
317 ret.
ch.
blue = color.ch.blue * 8;
321 #elif LV_COLOR_DEPTH == 32 326 static inline lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix)
329 #if LV_COLOR_DEPTH != 1 331 ret.ch.red = (uint16_t)((uint16_t)c1.ch.red * mix + (c2.ch.red * (255 - mix))) >> 8;
332 #if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP 334 uint16_t g_1 = (c1.ch.green_h << 3) + c1.ch.green_l;
335 uint16_t g_2 = (c2.ch.green_h << 3) + c2.ch.green_l;
336 uint16_t g_out = (uint16_t)((uint16_t)g_1 * mix + (g_2 * (255 - mix))) >> 8;
337 ret.ch.green_h = g_out >> 3;
338 ret.ch.green_l = g_out & 0x7;
340 ret.ch.green = (uint16_t)((uint16_t)c1.ch.green * mix + (c2.ch.green * (255 - mix))) >> 8;
342 ret.ch.blue = (uint16_t)((uint16_t)c1.ch.blue * mix + (c2.ch.blue * (255 - mix))) >> 8;
343 #if LV_COLOR_DEPTH == 32 348 ret.full = mix >
LV_OPA_50 ? c1.full : c2.full;
359 static inline uint8_t lv_color_brightness(lv_color_t color)
362 c32.
full = lv_color_to32(color);
364 return (uint16_t)bright >> 3;
368 #if LV_COLOR_DEPTH == 1 369 #define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){(b8 >> 7 | g8 >> 7 | r8 >> 7)}) 370 static inline lv_color_t lv_color_make(
int r8,
int g8,
int b8)
373 color.full = (b8 >> 7 | g8 >> 7 | r8 >> 7);
376 #elif LV_COLOR_DEPTH == 8 377 #define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8 >> 6, g8 >> 5, r8 >> 5}}) 378 static inline lv_color_t lv_color_make(uint8_t r8,
int g8,
int b8)
381 color.ch.blue = b8 >> 6;
382 color.ch.green = g8 >> 5;
383 color.ch.red = r8 >> 5;
386 #elif LV_COLOR_DEPTH == 16 387 #if LV_COLOR_16_SWAP == 0 388 #define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8 >> 3, g8 >> 2, r8 >> 3}}) 389 static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8)
392 color.ch.blue = (uint16_t)(b8 >> 3);
393 color.ch.green = (uint16_t)(g8 >> 2);
394 color.ch.red = (uint16_t)(r8 >> 3);
398 #define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{g8 >> 5, r8 >> 3, b8 >> 3, (g8 >> 2) & 0x7}}) 399 static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8)
402 color.ch.green_h = (uint16_t)(g8 >> 5);
403 color.ch.red = (uint16_t)(r8 >> 3);
404 color.ch.blue = (uint16_t)(b8 >> 3);
405 color.ch.green_l = (uint16_t)((g8 >> 2) & 0x7);
409 #elif LV_COLOR_DEPTH == 32 410 #define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8, g8, r8, 0xff}}) 411 static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8)
417 color.ch.alpha = 0xff;
422 static inline lv_color_t lv_color_hex(uint32_t c)
424 return lv_color_make((uint8_t)((c >> 16) & 0xFF), (uint8_t)((c >> 8) & 0xFF), (uint8_t)(c & 0xFF));
427 static inline lv_color_t lv_color_hex3(uint32_t c)
429 return lv_color_make((uint8_t)(((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), (uint8_t)((c & 0xF0) | ((c & 0xF0) >> 4)),
430 (uint8_t)((c & 0xF) | ((c & 0xF) << 4)));
struct lv_color16_t::@28 ch
Definition: lv_color.h:65
Definition: lv_color.h:69
Definition: lv_color.h:105
Definition: lv_color.h:66
uint8_t blue
Definition: lv_color.h:109
Definition: lv_color.h:134
uint8_t red
Definition: lv_color.h:140
Definition: lv_color.h:97
uint8_t alpha
Definition: lv_color.h:141
uint8_t v
Definition: lv_color.h:168
struct lv_color8_t::@27 ch
Definition: lv_color.h:64
lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v)
Definition: lv_color.h:73
Definition: lv_color.h:164
Definition: lv_color.h:68
uint16_t green
Definition: lv_color.h:122
lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r, uint8_t g, uint8_t b)
uint16_t blue
Definition: lv_color.h:121
Definition: lv_color.h:116
uint16_t full
Definition: lv_color.h:131
uint16_t red
Definition: lv_color.h:123
Definition: lv_color.h:70
uint8_t lv_opa_t
Definition: lv_color.h:162
uint8_t red
Definition: lv_color.h:111
Definition: lv_color.h:72
uint8_t blue
Definition: lv_color.h:138
Definition: lv_color.h:71
uint8_t s
Definition: lv_color.h:167
Definition: lv_color.h:63
uint8_t green
Definition: lv_color.h:110
uint8_t green
Definition: lv_color.h:139
Definition: lv_color.h:75
Definition: lv_color.h:67
uint32_t full
Definition: lv_color.h:143
Definition: lv_color.h:74
uint8_t full
Definition: lv_color.h:113
struct lv_color32_t::@29 ch
uint16_t h
Definition: lv_color.h:166