diff options
author | stein3 <stein3@gmail.com> | 2020-10-06 07:15:41 -0700 |
---|---|---|
committer | stein3 <stein3@gmail.com> | 2020-10-06 07:15:41 -0700 |
commit | 2e402741a89c5eec8cf30c966ce6f36d6ec9249b (patch) | |
tree | 3592e8c5e6bd19943ae55db7fc02a5f755afbb51 /quantum/color.c | |
parent | 3e5e4f74272c610bb9fa737f674f8e65ed6100ca (diff) | |
parent | 2013f6313430b977e557e482d30daa279a46e75d (diff) |
Merge branch 'master' into meteor
Diffstat (limited to 'quantum/color.c')
-rw-r--r-- | quantum/color.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/quantum/color.c b/quantum/color.c index c050300627..1c5128e4a2 100644 --- a/quantum/color.c +++ b/quantum/color.c @@ -18,14 +18,20 @@ #include "led_tables.h" #include "progmem.h" -RGB hsv_to_rgb(HSV hsv) { +RGB hsv_to_rgb_impl(HSV hsv, bool use_cie) { RGB rgb; uint8_t region, remainder, p, q, t; uint16_t h, s, v; if (hsv.s == 0) { #ifdef USE_CIE1931_CURVE - rgb.r = rgb.g = rgb.b = pgm_read_byte(&CIE1931_CURVE[hsv.v]); + if (use_cie) { + rgb.r = rgb.g = rgb.b = pgm_read_byte(&CIE1931_CURVE[hsv.v]); + } else { + rgb.r = hsv.v; + rgb.g = hsv.v; + rgb.b = hsv.v; + } #else rgb.r = hsv.v; rgb.g = hsv.v; @@ -37,7 +43,11 @@ RGB hsv_to_rgb(HSV hsv) { h = hsv.h; s = hsv.s; #ifdef USE_CIE1931_CURVE - v = pgm_read_byte(&CIE1931_CURVE[hsv.v]); + if (use_cie) { + v = pgm_read_byte(&CIE1931_CURVE[hsv.v]); + } else { + v = hsv.v; + } #else v = hsv.v; #endif @@ -86,6 +96,16 @@ RGB hsv_to_rgb(HSV hsv) { return rgb; } +RGB hsv_to_rgb(HSV hsv) { +#ifdef USE_CIE1931_CURVE + return hsv_to_rgb_impl(hsv, true); +#else + return hsv_to_rgb_impl(hsv, false); +#endif +} + +RGB hsv_to_rgb_nocie(HSV hsv) { return hsv_to_rgb_impl(hsv, false); } + #ifdef RGBW # ifndef MIN # define MIN(a, b) ((a) < (b) ? (a) : (b)) |