16 0, 2023680, 1011840, 674560, 505920, 404736, 337280, 289097,
17 252960, 224853, 202368, 183971, 168640, 155668, 144549, 134912,
18 126480, 119040, 112427, 106509, 101184, 96366, 91985, 87986,
19 84320, 80947, 77834, 74951, 72274, 69782, 67456, 65280};
31 return static_cast<u16
>((
static_cast<u32
>(i) * scale_plus_one) >> 8);
39 u16 bright_p1,
bool apply_brightness,
40 CRGB *out,
u8 *out_power_5bit) {
43 if ((r16 | g16 | b16) == 0) {
50 if (apply_brightness) {
71 u8 r8 =
static_cast<u8>((r16 * scalef + 0x808000) >> 24);
72 u8 g8 =
static_cast<u8>((g16 * scalef + 0x808000) >> 24);
73 u8 b8 =
static_cast<u8>((b16 * scalef + 0x808000) >> 24);
75 *out =
CRGB(r8, g8, b8);
76 *out_power_5bit =
static_cast<u8>(
scale);
87 u16 n =
static_cast<u16
>(colors.
size());
88 if (out_colors.
size() < n) n =
static_cast<u16
>(out_colors.
size());
89 if (out_power_5bit.
size() < n) n =
static_cast<u16
>(out_power_5bit.
size());
92 if (global_brightness == 0) {
93 for (u16 i = 0; i < n; ++i) {
94 out_colors[i] =
CRGB(0, 0, 0);
95 out_power_5bit[i] = 0;
103 const bool apply_r_scale = (colors_scale.r != 0xff);
104 const bool apply_g_scale = (colors_scale.g != 0xff);
105 const bool apply_b_scale = (colors_scale.b != 0xff);
106 const u16 rscale_p1 = 1u +
static_cast<u16
>(colors_scale.r);
107 const u16 gscale_p1 = 1u +
static_cast<u16
>(colors_scale.g);
108 const u16 bscale_p1 = 1u +
static_cast<u16
>(colors_scale.b);
111 const bool apply_brightness = (global_brightness != 0xff);
112 const u16 bright_p1 = 1u +
static_cast<u16
>(global_brightness);
114 for (u16 i = 0; i < n; ++i) {
115 const CRGB &c = colors[i];
117 u16 r16 = five_bit_impl::gamma_lut_read(glut, c.r);
118 u16 g16 = five_bit_impl::gamma_lut_read(glut, c.g);
119 u16 b16 = five_bit_impl::gamma_lut_read(glut, c.b);
122 if (apply_r_scale) r16 = five_bit_impl::scale16by8_nozero(r16, rscale_p1);
123 if (apply_g_scale) g16 = five_bit_impl::scale16by8_nozero(g16, gscale_p1);
124 if (apply_b_scale) b16 = five_bit_impl::scale16by8_nozero(b16, bscale_p1);
126 five_bit_impl::five_bit_pixel(r16, g16, b16, global_brightness,
127 bright_p1, apply_brightness,
128 &out_colors[i], &out_power_5bit[i]);
137 u16 n =
static_cast<u16
>(colors.
size());
138 if (out.
size() < n) n =
static_cast<u16
>(out.
size());
141 if (global_brightness == 0) {
142 for (u16 i = 0; i < n; ++i) {
143 out[i].color =
CRGB(0, 0, 0);
144 out[i].brightness_5bit = 0;
152 const bool apply_r_scale = (colors_scale.r != 0xff);
153 const bool apply_g_scale = (colors_scale.g != 0xff);
154 const bool apply_b_scale = (colors_scale.b != 0xff);
155 const u16 rscale_p1 = 1u +
static_cast<u16
>(colors_scale.r);
156 const u16 gscale_p1 = 1u +
static_cast<u16
>(colors_scale.g);
157 const u16 bscale_p1 = 1u +
static_cast<u16
>(colors_scale.b);
160 const bool apply_brightness = (global_brightness != 0xff);
161 const u16 bright_p1 = 1u +
static_cast<u16
>(global_brightness);
163 for (u16 i = 0; i < n; ++i) {
164 const CRGB &c = colors[i];
166 u16 r16 = five_bit_impl::gamma_lut_read(glut, c.r);
167 u16 g16 = five_bit_impl::gamma_lut_read(glut, c.g);
168 u16 b16 = five_bit_impl::gamma_lut_read(glut, c.b);
171 if (apply_r_scale) r16 = five_bit_impl::scale16by8_nozero(r16, rscale_p1);
172 if (apply_g_scale) g16 = five_bit_impl::scale16by8_nozero(g16, gscale_p1);
173 if (apply_b_scale) b16 = five_bit_impl::scale16by8_nozero(b16, bscale_p1);
175 five_bit_impl::five_bit_pixel(r16, g16, b16, global_brightness,
176 bright_p1, apply_brightness,
177 &out[i].color, &out[i].brightness_5bit);
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
fl::UISlider scale("Scale", 4,.1, 4,.1)
Alignment macros and utilities for FastLED.
constexpr fl::size size() const FL_NOEXCEPT
#define constexpr
Declares that it is possible to evaluate a value at compile time, introduced in C++11.
#define FL_ALIGN_PROGMEM(N)
Force N-byte alignment for platforms with unaligned access or cache-line optimization.
#define FL_PGM_READ_DWORD_ALIGNED(addr)
#define FL_PGM_READ_WORD_ALIGNED(addr)
#define FL_PROGMEM
PROGMEM keyword for storage.
Declares functions for five-bit gamma correction.
Internal FastLED header for implementation files.
FL_ALWAYS_INLINE void five_bit_pixel(u16 r16, u16 g16, u16 b16, u8 brightness, u16 bright_p1, bool apply_brightness, CRGB *out, u8 *out_power_5bit)
FL_ALWAYS_INLINE u16 gamma_lut_read(aligned_ptr< const u16, 64 > lut, u8 idx)
FL_ALWAYS_INLINE u16 scale16by8_nozero(u16 i, u16 scale_plus_one)
const u16 GAMMA_2_8_LUT[256]
FL_OPTIMIZE_FUNCTION void five_bit_hd_gamma_bitshift(fl::span< const CRGB > colors, CRGB colors_scale, u8 global_brightness, fl::span< CRGB > out_colors, fl::span< u8 > out_power_5bit)
Base definition for an LED controller.
#define FL_OPTIMIZATION_LEVEL_O3_BEGIN
#define FL_OPTIMIZATION_LEVEL_O3_END
#define FL_OPTIMIZE_FUNCTION
Representation of an 8-bit RGB pixel (Red, Green, Blue)