[wpilib] Tweak Color HSV formula and use in AddressableLED (#4724)

The Color algorithm was tweaked to:
a) not produce incorrect values if the user happens to input a hue outside the [0, 180) range, and
b) more accurately convert the hue remainder from range 0-30 to 0-255. The current conversion vastly overshoots the multiplier (converts 0-30 to 0-270) and relies on clamping the value when constructing the Color object to produce a slightly incorrect result.
This commit is contained in:
Colin Wong
2022-11-28 16:42:22 -06:00
committed by GitHub
parent ec124bb662
commit e82cd5147b
4 changed files with 42 additions and 25 deletions

View File

@@ -35,16 +35,16 @@ class AddressableLEDBufferTest {
arguments(0, 255, 255, 255, 0, 0), // Red
arguments(60, 255, 255, 0, 255, 0), // Lime
arguments(120, 255, 255, 0, 0, 255), // Blue
arguments(30, 255, 255, 254, 255, 0), // Yellow (ish)
arguments(90, 255, 255, 0, 254, 255), // Cyan (ish)
arguments(150, 255, 255, 255, 0, 254), // Magenta (ish)
arguments(30, 255, 255, 255, 255, 0), // Yellow
arguments(90, 255, 255, 0, 255, 255), // Cyan
arguments(150, 255, 255, 255, 0, 255), // Magenta
arguments(0, 0, 191, 191, 191, 191), // Silver
arguments(0, 0, 128, 128, 128, 128), // Gray
arguments(0, 255, 128, 128, 0, 0), // Maroon
arguments(30, 255, 128, 127, 128, 0), // Olive (ish)
arguments(30, 255, 128, 128, 128, 0), // Olive
arguments(60, 255, 128, 0, 128, 0), // Green
arguments(150, 255, 128, 128, 0, 127), // Purple (ish)
arguments(90, 255, 128, 0, 127, 128), // Teal (ish)
arguments(150, 255, 128, 128, 0, 128), // Purple
arguments(90, 255, 128, 0, 128, 128), // Teal
arguments(120, 255, 128, 0, 0, 128) // Navy
);
}