diff options
Diffstat (limited to 'quantum/color.c')
-rw-r--r-- | quantum/color.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/quantum/color.c b/quantum/color.c index 1f398e240..8bd52444f 100644 --- a/quantum/color.c +++ b/quantum/color.c | |||
@@ -85,3 +85,17 @@ RGB hsv_to_rgb(HSV hsv) { | |||
85 | 85 | ||
86 | return rgb; | 86 | return rgb; |
87 | } | 87 | } |
88 | |||
89 | #ifdef RGBW | ||
90 | #ifndef MIN | ||
91 | # define MIN(a, b) ((a) < (b) ? (a) : (b)) | ||
92 | #endif | ||
93 | void convert_rgb_to_rgbw(LED_TYPE *led) { | ||
94 | // Determine lowest value in all three colors, put that into | ||
95 | // the white channel and then shift all colors by that amount | ||
96 | led->w = MIN(led->r, MIN(led->g, led->b)); | ||
97 | led->r -= led->w; | ||
98 | led->g -= led->w; | ||
99 | led->b -= led->w; | ||
100 | } | ||
101 | #endif | ||