FastLED 3.9.15
Loading...
Searching...
No Matches

◆ set_pixel()

void fl::third_party::ezWS2812::set_pixel ( uint8_t red,
uint8_t green,
uint8_t blue,
uint16_t count = 1 )
inline

Set color for specific number of LEDs.

Parameters
redRed value (0-255)
greenGreen value (0-255)
blueBlue value (0-255)
countNumber of LEDs to set (default: 1)

Definition at line 115 of file ezWS2812.h.

115 {
116 uint8_t spi_buffer[24]; // 3 colors × 8 bits = 24 SPI bytes per pixel
117
118 // Apply brightness
119 red = (red * brightness_) / 100;
120 green = (green * brightness_) / 100;
121 blue = (blue * brightness_) / 100;
122
123 // Convert to SPI bit patterns (GRB order for WS2812)
124 color_to_spi(green, &spi_buffer[0]); // Green first
125 color_to_spi(red, &spi_buffer[8]); // Red second
126 color_to_spi(blue, &spi_buffer[16]); // Blue third
127
128 // Send pixel data
129 for (uint16_t i = 0; i < count && i < num_leds_; i++) {
130 for (int j = 0; j < 24; j++) {
131 spi_->transfer(spi_buffer[j]);
132 }
133 }
134 }
void color_to_spi(uint8_t color, uint8_t *buffer) const
Convert color byte to SPI bit pattern.
Definition ezWS2812.h:81
fl::u16 uint16_t
Definition coder.h:214
unsigned char uint8_t
Definition coder.h:209

References brightness_, color_to_spi(), num_leds_, and spi_.

Referenced by set_all().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: