diff options
Diffstat (limited to 'quantum/color.c')
-rw-r--r-- | quantum/color.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/quantum/color.c b/quantum/color.c index 1f398e2403..85a6d52cf0 100644 --- a/quantum/color.c +++ b/quantum/color.c @@ -85,3 +85,18 @@ RGB hsv_to_rgb(HSV hsv) { return rgb; } + + +#ifdef RGBW +#ifndef MIN +# define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif +void convert_rgb_to_rgbw(LED_TYPE *led) { + // Determine lowest value in all three colors, put that into + // the white channel and then shift all colors by that amount + led->w = MIN(led->r, MIN(led->g, led->b)); + led->r -= led->w; + led->g -= led->w; + led->b -= led->w; +} +#endif |