diff options
author | XScorpion2 <rcalt2vt@gmail.com> | 2019-05-01 20:59:01 -0500 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2019-05-01 19:08:52 -0700 |
commit | 22426a4b4a29781b1d4b416717d44ceb434b67a2 (patch) | |
tree | 83457a98fc3d1edc9d480db8eebc08c2feb133d7 /quantum/color.c | |
parent | 59d28fe2884c0639ef020ece3e1bc6967ab0881f (diff) |
Adjusted the linear led table and hsv_to_rgb to better handle 255 hue (#5739)
* Adjusted the linear led table and hsv_to_rgb to better handle 255 hue
* small math adjustments to better handle specific uint8_t rounding and overflows
Diffstat (limited to 'quantum/color.c')
-rw-r--r-- | quantum/color.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/quantum/color.c b/quantum/color.c index c49877592e..466e6edacb 100644 --- a/quantum/color.c +++ b/quantum/color.c @@ -22,8 +22,8 @@ RGB hsv_to_rgb( HSV hsv ) { RGB rgb; - uint8_t region, p, q, t; - uint16_t h, s, v, remainder; + uint8_t region, remainder, p, q, t; + uint16_t h, s, v; if ( hsv.s == 0 ) { @@ -37,8 +37,8 @@ RGB hsv_to_rgb( HSV hsv ) s = hsv.s; v = hsv.v; - region = h / 43; - remainder = (h - (region * 43)) * 6; + region = h * 6 / 255; + remainder = (h * 2 - region * 85) * 3; p = (v * (255 - s)) >> 8; q = (v * (255 - ((s * remainder) >> 8))) >> 8; @@ -46,6 +46,7 @@ RGB hsv_to_rgb( HSV hsv ) switch ( region ) { + case 6: case 0: rgb.r = v; rgb.g = t; |