aboutsummaryrefslogtreecommitdiffstats
path: root/quantum/color.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/color.c')
-rw-r--r--quantum/color.c14
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) {
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