50 :
r(r_ & 0xF),
g(g_ & 0xF),
b(b_ & 0xF),
w(w_ & 0xF) {}
68template <
typename OutputIterator>
70 u8 r_current,
u8 g_current,
71 u8 b_current,
u8 w_current) {
85 *out++ =
static_cast<u8>(mode);
88 *out++ = r_current & 0x0F;
89 *out++ = g_current & 0x0F;
90 *out++ = b_current & 0x0F;
91 *out++ = w_current & 0x0F;
105template <
typename InputIterator,
typename OutputIterator>
107 while (first != last) {
108 const auto& pixel = *first;
123template <
typename InputIterator,
typename OutputIterator>
125 while (first != last) {
126 const auto& pixel = *first;
143template <
typename InputIterator,
typename OutputIterator>
146 while (first != last) {
147 const auto& pixel = *first;
150 u8 rgb_in[3] = { pixel[0], pixel[1], pixel[2] };
155 *out++ = rgb_out[0] >> 8;
156 *out++ = rgb_out[0] & 0xFF;
157 *out++ = rgb_out[1] >> 8;
158 *out++ = rgb_out[1] & 0xFF;
159 *out++ = rgb_out[2] >> 8;
160 *out++ = rgb_out[2] & 0xFF;
173template <
typename InputIterator,
typename OutputIterator>
176 while (first != last) {
177 const auto& pixel = *first;
180 u8 rgbw_in[4] = { pixel[0], pixel[1], pixel[2], pixel[3] };
185 *out++ = rgbw_out[0] >> 8;
186 *out++ = rgbw_out[0] & 0xFF;
187 *out++ = rgbw_out[1] >> 8;
188 *out++ = rgbw_out[1] & 0xFF;
189 *out++ = rgbw_out[2] >> 8;
190 *out++ = rgbw_out[2] & 0xFF;
191 *out++ = rgbw_out[3] >> 8;
192 *out++ = rgbw_out[3] & 0xFF;
208template <
typename OutputIterator>
212 constexpr size_t PREAMBLE_LEN = 15;
215 size_t bytes_per_led;
217 bytes_per_led = is_rgbw ? 4 : 3;
219 bytes_per_led = is_rgbw ? 8 : 6;
223 size_t led_data_size = num_leds * bytes_per_led;
224 size_t total_data_size = PREAMBLE_LEN + led_data_size;
225 size_t padding = (3 - (total_data_size % 3)) % 3;
231 for (
size_t i = 0; i < padding; ++i) {
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
static fl::shared_ptr< const Gamma8 > getOrCreate(float gamma) FL_NOEXCEPT
pair< detail::ScaledPixelIteratorRGB, detail::ScaledPixelIteratorRGB > makeScaledPixelRangeRGB(PixelIterator *pixels) FL_NOEXCEPT
Create RGB input iterator range from PixelIterator.
void buildUCS7604Preamble(OutputIterator out, UCS7604Mode mode, u8 r_current, u8 g_current, u8 b_current, u8 w_current)
Build UCS7604 preamble (15 bytes)
void encodeUCS7604_8bit_RGB(InputIterator first, InputIterator last, OutputIterator out)
Encode RGB pixels in UCS7604 8-bit format.
void encodeUCS7604_16bit_RGBW(InputIterator first, InputIterator last, OutputIterator out, const Gamma8 &gamma)
Encode RGBW pixels in UCS7604 16-bit format with gamma correction.
pair< detail::ScaledPixelIteratorRGBW, detail::ScaledPixelIteratorRGBW > makeScaledPixelRangeRGBW(PixelIterator *pixels) FL_NOEXCEPT
Create RGBW input iterator range from PixelIterator.
UCS7604Mode
UCS7604 protocol configuration modes.
@ UCS7604_MODE_8BIT_800KHZ
@ UCS7604_MODE_16BIT_1600KHZ
@ UCS7604_MODE_16BIT_800KHZ
constexpr u32 gamma(float g) FL_NOEXCEPT
void encodeUCS7604_8bit_RGBW(InputIterator first, InputIterator last, OutputIterator out)
Encode RGBW pixels in UCS7604 8-bit format.
void encodeUCS7604_16bit_RGB(InputIterator first, InputIterator last, OutputIterator out, const Gamma8 &gamma)
Encode RGB pixels in UCS7604 16-bit format with gamma correction.
void encodeUCS7604(PixelIterator &pixel_iter, size_t num_leds, OutputIterator out, UCS7604Mode mode, const UCS7604CurrentControl ¤t, bool is_rgbw, const Gamma8 *gamma=nullptr)
Encode complete UCS7604 frame (preamble + padding + pixel data)
Base definition for an LED controller.
Adapter layer bridging PixelIterator to encoder input iterators.
UCS7604CurrentControl(u8 brightness)
Construct from single brightness value (all channels)
u8 g
Green channel current (0x0-0xF)
u8 b
Blue channel current (0x0-0xF)
UCS7604CurrentControl() FL_NOEXCEPT
Default constructor - maximum brightness.
u8 w
White channel current (0x0-0xF)
UCS7604CurrentControl(u8 r_, u8 g_, u8 b_, u8 w_)
Construct from individual channel values.
u8 r
Red channel current (0x0-0xF)
UCS7604 current control structure with 4-bit fields for each channel.