4#define FASTLED_INTERNAL
10FASTLED_NAMESPACE_BEGIN
13inline uint8_t min3(uint8_t a, uint8_t b, uint8_t c) {
29inline uint8_t divide_by_3(uint8_t x) {
30 uint16_t y = (uint16_t(x) * 85) >> 8;
31 return static_cast<uint8_t
>(y);
38void rgb_2_rgbw_exact(uint16_t w_color_temperature, uint8_t r, uint8_t g,
39 uint8_t b, uint8_t r_scale, uint8_t g_scale,
40 uint8_t b_scale, uint8_t *out_r, uint8_t *out_g,
41 uint8_t *out_b, uint8_t *out_w) {
45 uint8_t min_component = min3(r, g, b);
46 *out_r = r - min_component;
47 *out_g = g - min_component;
48 *out_b = b - min_component;
49 *out_w = min_component;
52void rgb_2_rgbw_max_brightness(uint16_t w_color_temperature, uint8_t r,
53 uint8_t g, uint8_t b, uint8_t r_scale,
54 uint8_t g_scale, uint8_t b_scale, uint8_t *out_r,
55 uint8_t *out_g, uint8_t *out_b, uint8_t *out_w) {
56 *out_r =
scale8(r, r_scale);
57 *out_g =
scale8(g, g_scale);
58 *out_b =
scale8(b, b_scale);
59 *out_w = min3(r, g, b);
62void rgb_2_rgbw_null_white_pixel(uint16_t w_color_temperature, uint8_t r,
63 uint8_t g, uint8_t b, uint8_t r_scale,
64 uint8_t g_scale, uint8_t b_scale,
65 uint8_t *out_r, uint8_t *out_g, uint8_t *out_b,
67 *out_r =
scale8(r, r_scale);
68 *out_g =
scale8(g, g_scale);
69 *out_b =
scale8(b, b_scale);
73void rgb_2_rgbw_white_boosted(uint16_t w_color_temperature, uint8_t r,
74 uint8_t g, uint8_t b, uint8_t r_scale,
75 uint8_t g_scale, uint8_t b_scale, uint8_t *out_r,
76 uint8_t *out_g, uint8_t *out_b, uint8_t *out_w) {
80 uint8_t min_component = min3(r, g, b);
83 if (min_component <= 84) {
84 w = 3 * min_component;
93 r_prime = r - min_component;
94 g_prime = g - min_component;
95 b_prime = b - min_component;
97 uint8_t w3 = divide_by_3(w);
109rgb_2_rgbw_function g_user_function = rgb_2_rgbw_exact;
111void set_rgb_2_rgbw_function(rgb_2_rgbw_function func) {
112 if (func ==
nullptr) {
113 g_user_function = rgb_2_rgbw_exact;
116 g_user_function = func;
119void rgb_2_rgbw_user_function(uint16_t w_color_temperature, uint8_t r,
120 uint8_t g, uint8_t b, uint8_t r_scale,
121 uint8_t g_scale, uint8_t b_scale, uint8_t *out_r,
122 uint8_t *out_g, uint8_t *out_b, uint8_t *out_w) {
123 g_user_function(w_color_temperature, r, g, b, r_scale, g_scale, b_scale,
124 out_r, out_g, out_b, out_w);
127void rgbw_partial_reorder(EOrderW w_placement, uint8_t b0, uint8_t b1,
128 uint8_t b2, uint8_t w, uint8_t *out_b0,
129 uint8_t *out_b1, uint8_t *out_b2, uint8_t *out_b3) {
131 uint8_t out[4] = {b0, b1, b2, 0};
132 switch (w_placement) {
central include file for FastLED, defines the CFastLED class/object
LIB8STATIC_ALWAYS_INLINE uint8_t scale8(uint8_t i, fract8 scale)
Scale one byte by a second one, which is treated as the numerator of a fraction whose denominator is ...