Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
195 lines (185 sloc) 8.97 KB
#pragma once
namespace kaleidoscope {
namespace plugin {
namespace LEDFunctionalColor {
// A special color that serves, in some cases, as an "index color" and basically means, "skip this, return the next in line".
// Since colors under 18 or so are equivalent to LED off, this would otherwise be equivalent to black anyways
constexpr cRGB nocolor = CRGB(1, 1, 2);
// Here's a big list of color names based on the CSS color names.
constexpr cRGB warmwhite = CRGB(255, 250, 200);
constexpr cRGB aliceblue = CRGB(240, 248, 255);
constexpr cRGB antiquewhite = CRGB(250, 235, 215);
constexpr cRGB aqua = CRGB(0, 255, 255);
constexpr cRGB aquamarine = CRGB(127, 255, 212);
constexpr cRGB azure = CRGB(240, 255, 255);
constexpr cRGB beige = CRGB(245, 245, 220);
constexpr cRGB bisque = CRGB(255, 228, 196);
constexpr cRGB black = CRGB(0, 0, 0);
constexpr cRGB blanchedalmond = CRGB(255, 235, 205);
constexpr cRGB blue = CRGB(0, 0, 255);
constexpr cRGB blueviolet = CRGB(138, 43, 226);
constexpr cRGB brown = CRGB(165, 42, 42); //Looks more like dim red
constexpr cRGB burlywood = CRGB(222, 184, 135);
constexpr cRGB cadetblue = CRGB(95, 158, 160);
constexpr cRGB chartreuse = CRGB(127, 255, 0);
constexpr cRGB chocolate = CRGB(210, 105, 30);
constexpr cRGB coral = CRGB(255, 127, 80);
constexpr cRGB cornflowerblue = CRGB(100, 149, 237);
constexpr cRGB cornsilk = CRGB(255, 248, 220);
constexpr cRGB crimson = CRGB(220, 20, 60);
constexpr cRGB cyan = CRGB(0, 255, 255);
constexpr cRGB darkblue = CRGB(0, 0, 139);
constexpr cRGB darkcyan = CRGB(0, 139, 139);
constexpr cRGB darkgoldenrod = CRGB(184, 134, 11);
constexpr cRGB darkgray = CRGB(169, 169, 169);
constexpr cRGB darkgrey = CRGB(169, 169, 169);
constexpr cRGB darkgreen = CRGB(0, 100, 0);
constexpr cRGB darkkhaki = CRGB(189, 183, 107);
constexpr cRGB darkmagenta = CRGB(139, 0, 139);
constexpr cRGB darkolivegreen = CRGB(85, 107, 47);
constexpr cRGB darkorange = CRGB(255, 140, 0);
constexpr cRGB darkorchid = CRGB(153, 50, 204);
constexpr cRGB darkred = CRGB(139, 0, 0);
constexpr cRGB darksalmon = CRGB(233, 150, 122);
constexpr cRGB darkseagreen = CRGB(143, 188, 143);
constexpr cRGB darkslateblue = CRGB(72, 61, 139);
constexpr cRGB darkslategray = CRGB(47, 79, 79);
constexpr cRGB darkslategrey = CRGB(47, 79, 79);
constexpr cRGB darkturquoise = CRGB(0, 206, 209);
constexpr cRGB darkviolet = CRGB(148, 0, 211);
constexpr cRGB deeppink = CRGB(255, 20, 147);
constexpr cRGB deepskyblue = CRGB(0, 191, 255);
constexpr cRGB dimgray = CRGB(105, 105, 105);
constexpr cRGB dimgrey = CRGB(105, 105, 105);
constexpr cRGB dodgerblue = CRGB(30, 144, 255);
constexpr cRGB firebrick = CRGB(178, 34, 34);
constexpr cRGB floralwhite = CRGB(255, 250, 240);
constexpr cRGB forestgreen = CRGB(34, 139, 34);
constexpr cRGB fuchsia = CRGB(255, 0, 255);
constexpr cRGB gainsboro = CRGB(220, 220, 220);
constexpr cRGB ghostwhite = CRGB(248, 248, 255);
constexpr cRGB gold = CRGB(255, 215, 0);
constexpr cRGB goldenrod = CRGB(218, 165, 32);
constexpr cRGB gray = CRGB(128, 128, 128);
constexpr cRGB grey = CRGB(128, 128, 128);
constexpr cRGB green = CRGB(0, 128, 0);
constexpr cRGB greenyellow = CRGB(173, 255, 47);
constexpr cRGB honeydew = CRGB(240, 255, 240);
constexpr cRGB hotpink = CRGB(255, 105, 180);
constexpr cRGB indianred = CRGB(205, 92, 92);
constexpr cRGB indigo = CRGB(75, 0, 130);
constexpr cRGB ivory = CRGB(255, 255, 240);
constexpr cRGB khaki = CRGB(240, 230, 140);
constexpr cRGB lavender = CRGB(230, 230, 250);
constexpr cRGB lavenderblush = CRGB(255, 240, 245);
constexpr cRGB lawngreen = CRGB(124, 252, 0);
constexpr cRGB lemonchiffon = CRGB(255, 250, 205);
constexpr cRGB lightblue = CRGB(173, 216, 230);
constexpr cRGB lightcoral = CRGB(240, 128, 128);
constexpr cRGB lightcyan = CRGB(224, 255, 255);
constexpr cRGB lightgoldenrodyellow = CRGB(250, 250, 210);
constexpr cRGB lightgray = CRGB(211, 211, 211);
constexpr cRGB lightgrey = CRGB(211, 211, 211);
constexpr cRGB lightgreen = CRGB(144, 238, 144);
constexpr cRGB lightpink = CRGB(255, 182, 193);
constexpr cRGB lightsalmon = CRGB(255, 160, 122);
constexpr cRGB lightseagreen = CRGB(32, 178, 170);
constexpr cRGB lightskyblue = CRGB(135, 206, 250);
constexpr cRGB lightslategray = CRGB(119, 136, 153);
constexpr cRGB lightslategrey = CRGB(119, 136, 153);
constexpr cRGB lightsteelblue = CRGB(176, 196, 222);
constexpr cRGB lightyellow = CRGB(255, 255, 224);
constexpr cRGB lime = CRGB(0, 255, 0);
constexpr cRGB limegreen = CRGB(50, 205, 50);
constexpr cRGB linen = CRGB(250, 240, 230);
constexpr cRGB magenta = CRGB(255, 0, 255);
constexpr cRGB maroon = CRGB(128, 0, 0);
constexpr cRGB mediumaquamarine = CRGB(102, 205, 170);
constexpr cRGB mediumblue = CRGB(0, 0, 205);
constexpr cRGB mediumorchid = CRGB(186, 85, 211);
constexpr cRGB mediumpurple = CRGB(147, 112, 219);
constexpr cRGB mediumseagreen = CRGB(60, 179, 113);
constexpr cRGB mediumslateblue = CRGB(123, 104, 238);
constexpr cRGB mediumspringgreen = CRGB(0, 250, 154);
constexpr cRGB mediumturquoise = CRGB(72, 209, 204);
constexpr cRGB mediumvioletred = CRGB(199, 21, 133);
constexpr cRGB midnightblue = CRGB(25, 25, 112);
constexpr cRGB mintcream = CRGB(245, 255, 250);
constexpr cRGB mistyrose = CRGB(255, 228, 225);
constexpr cRGB moccasin = CRGB(255, 228, 181);
constexpr cRGB navajowhite = CRGB(255, 222, 173);
constexpr cRGB navy = CRGB(0, 0, 128);
constexpr cRGB oldlace = CRGB(253, 245, 230);
constexpr cRGB olive = CRGB(128, 128, 0);
constexpr cRGB olivedrab = CRGB(107, 142, 35);
constexpr cRGB orange = CRGB(255, 165, 0);
// The original orangered looked exactly like red to me, so I adjusted
//cRGB orangered = CRGB(255, 69, 0);
constexpr cRGB orangered = CRGB(255, 100, 0);
constexpr cRGB orchid = CRGB(218, 112, 214);
constexpr cRGB palegoldenrod = CRGB(238, 232, 170);
constexpr cRGB palegreen = CRGB(152, 251, 152);
constexpr cRGB paleturquoise = CRGB(175, 238, 238);
constexpr cRGB palevioletred = CRGB(219, 112, 147);
constexpr cRGB papayawhip = CRGB(255, 239, 213);
constexpr cRGB peachpuff = CRGB(255, 218, 185);
constexpr cRGB peru = CRGB(205, 133, 63);
constexpr cRGB pink = CRGB(255, 192, 203);
constexpr cRGB plum = CRGB(221, 160, 221);
constexpr cRGB powderblue = CRGB(176, 224, 230);
constexpr cRGB purple = CRGB(128, 0, 128);
constexpr cRGB rebeccapurple = CRGB(102, 51, 153);
constexpr cRGB red = CRGB(255, 0, 0);
constexpr cRGB rosybrown = CRGB(188, 143, 143);
constexpr cRGB royalblue = CRGB(65, 105, 225);
constexpr cRGB saddlebrown = CRGB(139, 69, 19);
constexpr cRGB salmon = CRGB(250, 128, 114);
constexpr cRGB sandybrown = CRGB(244, 164, 96);
constexpr cRGB seagreen = CRGB(46, 139, 87);
constexpr cRGB seashell = CRGB(255, 245, 238);
constexpr cRGB sienna = CRGB(160, 82, 45);
constexpr cRGB silver = CRGB(192, 192, 192);
constexpr cRGB skyblue = CRGB(135, 206, 235);
constexpr cRGB slateblue = CRGB(106, 90, 205);
constexpr cRGB slategray = CRGB(112, 128, 144);
constexpr cRGB slategrey = CRGB(112, 128, 144);
constexpr cRGB snow = CRGB(255, 250, 250);
constexpr cRGB springgreen = CRGB(0, 255, 127);
constexpr cRGB steelblue = CRGB(70, 130, 180);
constexpr cRGB tan = CRGB(210, 180, 140);
constexpr cRGB teal = CRGB(0, 128, 128);
constexpr cRGB thistle = CRGB(216, 191, 216);
constexpr cRGB tomato = CRGB(255, 99, 71);
constexpr cRGB turquoise = CRGB(64, 224, 208);
constexpr cRGB violet = CRGB(238, 130, 238);
constexpr cRGB wheat = CRGB(245, 222, 179);
constexpr cRGB white = CRGB(255, 255, 255);
constexpr cRGB whitesmoke = CRGB(245, 245, 245);
constexpr cRGB yellow = CRGB(255, 255, 0);
constexpr cRGB yellowgreen = CRGB(154, 205, 50);
// Not sure if this is the right place for this...
// Function to dim the color from 0-255 (by default) or over a specified range
// dims the specified color from 0 (off) to 255 (full)
inline constexpr float brightnessScale(byte brightness, byte range=255) {
return float(brightness)/float(range);
}
// dimLimit prevents small adjustments from completely shutting colors off, as they are not visible below 28.
//if brightness is over about 51, and the *original* value for an rgb was over 80, set the new value to 28 if it would otherwise fall below that.
inline constexpr byte dimLimit(byte brightness, byte rgbByte, byte range=255) {
//Uncomment this line to bypass the dimming limiting that prevents lights from blacking out at moderate values
//return brightnessScale(brightness, range)*rgbByte;
return byte(brightnessScale(brightness, range) >= 0.20 && rgbByte >= 80 && brightnessScale(brightness, range)*rgbByte < 28)?28:brightnessScale(brightness, range)*rgbByte;
}
//Note that in practice, on the model01, 28 is the lowest value that actually lights up at all
__attribute__((always_inline))
inline constexpr cRGB dim(const cRGB &color, byte brightness, byte range=255) {
return CRGB(uint8_t(dimLimit(brightness, color.r, range)),
uint8_t(dimLimit(brightness, color.g, range)),
uint8_t(dimLimit(brightness, color.b, range)));
}
inline constexpr bool isColorMatch(cRGB color1, cRGB color2) {
return (color1.r == color2.r && color1.g == color2.g && color1.b == color2.b)?true:false;
}
} // namespace LEDFunctionalColor
} // namespace plugin
} // namespace kaleidoscope
You can’t perform that action at this time.