FastLED 3.9.15
Loading...
Searching...
No Matches
fl::third_party::ezWS2812 Class Reference

Detailed Description

ezWS2812 SPI driver for WS2812 LEDs

This driver uses the SPI peripheral to generate WS2812 timing signals. Each WS2812 bit is encoded as 8 SPI bits to achieve the required timing.

Hardware Requirements:

  • Consumes one SPI peripheral
  • Requires SPI clock of 3.2MHz for proper WS2812 timing
  • SPI MOSI pin must be connected to LED data line

Usage:

ezWS2812 leds(60); // 60 LEDs
leds.begin();
leds.set_all(255, 0, 0); // All red
leds.end_transfer();
fl::CRGB leds[NUM_LEDS]
ezWS2812(uint16_t num_leds, SPIClass &spi=SPI)
Constructor.
Definition ezWS2812.h:91

Definition at line 56 of file ezWS2812.h.

#include <ezWS2812.h>

Public Member Functions

 ezWS2812 (uint16_t num_leds, SPIClass &spi=SPI)
 Constructor.
 
void begin ()
 Initialize SPI communication.
 
void end ()
 End SPI communication.
 
void end_transfer ()
 Complete LED data transfer Sends reset signal to latch data into LEDs.
 
void set_all (uint8_t red, uint8_t green, uint8_t blue)
 Set all LEDs to the same color.
 
void set_brightness (uint8_t brightness)
 Set brightness (0-100%)
 
void set_pixel (uint8_t red, uint8_t green, uint8_t blue, uint16_t count=1)
 Set color for specific number of LEDs.
 

Private Member Functions

void color_to_spi (uint8_t color, uint8_t *buffer) const
 Convert color byte to SPI bit pattern.
 
uint8_t one () const
 Convert color bit to SPI signal for '1' bit.
 
uint8_t zero () const
 Convert color bit to SPI signal for '0' bit.
 

Private Attributes

uint8_t brightness_
 
uint16_t num_leds_
 
SPIClass * spi_
 

Static Private Attributes

static constexpr uint8_t kResetByte = 0x00
 
static constexpr uint8_t kResetBytes = 32
 
static constexpr uint16_t kResetTimeUs = 80
 
static constexpr uint32_t kSpiClockHz = 6400000
 

The documentation for this class was generated from the following file: