OpenThread_app
Loading...
Searching...
No Matches
WS2812B Effects Library

WS2812B lighting effects library - Ported from Arduino WS2812FX Library based on https://github.com/lamik/WS2812B_STM32_HAL. More...

Topics

 WS2812B RMT Driver
 WS2812B driver implementation using ESP32 RMT peripheral.
 Constants and Macros
 Configuration constants and predefined colors.
 Predefined Colors
 Common color constants in 0x00RRGGBB format.
 Type Definitions
 Enumerations and type definitions.
 WS2812B Interface Layer
 WS2812B driver interface - Hardware abstraction layer.

Functions

FX_STATUS WS2812BFX_Init (const ws2812b_drv_t *drv, uint16_t Segments)
FX_STATUS WS2812BFX_SegmentIncrease (ws2812b_drv_t *drv)
FX_STATUS WS2812BFX_SegmentDecrease (ws2812b_drv_t *drv)
uint8_t WS2812BFX_GetSegmentsQuantity (void)
void WS2812BFX_SysTickCallback (void)
void WS2812BFX_Callback (void)
FX_STATUS WS2812BFX_ForceAllColor (uint16_t Segment, uint8_t r, uint8_t g, uint8_t b)
FX_STATUS WS2812BFX_Start (uint16_t Segment)
FX_STATUS WS2812BFX_Stop (uint16_t Segment)
FX_STATUS WS2812BFX_IsRunning (uint16_t Segment, uint8_t *Running)
FX_STATUS WS2812BFX_SetMode (uint16_t Segment, fx_mode Mode)
FX_STATUS WS2812BFX_GetMode (uint16_t Segment, fx_mode *Mode)
FX_STATUS WS2812BFX_NextMode (uint16_t Segment)
FX_STATUS WS2812BFX_PrevMode (uint16_t Segment)
FX_STATUS WS2812BFX_SetReverse (uint16_t Segment, uint8_t Reverse)
FX_STATUS WS2812BFX_GetReverse (uint16_t Segment, uint8_t *Reverse)
FX_STATUS WS2812BFX_SetSegmentSize (uint16_t Segment, uint16_t Start, uint16_t Stop)
FX_STATUS WS2812BFX_GetSegmentSize (uint16_t Segment, uint16_t *Start, uint16_t *Stop)
FX_STATUS WS2812BFX_SegmentIncreaseEnd (uint16_t Segment)
FX_STATUS WS2812BFX_SegmentDecreaseEnd (uint16_t Segment)
FX_STATUS WS2812BFX_SegmentIncreaseStart (uint16_t Segment)
FX_STATUS WS2812BFX_SegmentDecreaseStart (uint16_t Segment)
FX_STATUS WS2812BFX_SetSpeed (uint16_t Segment, uint16_t Speed)
FX_STATUS WS2812BFX_GetSpeed (uint16_t Segment, uint16_t *Speed)
FX_STATUS WS2812BFX_IncreaseSpeed (uint16_t Segment, uint16_t Speed)
FX_STATUS WS2812BFX_DecreaseSpeed (uint16_t Segment, uint16_t Speed)
void WS2812BFX_SetColorStruct (uint8_t id, ws2812b_color c)
void WS2812BFX_SetColorRGB (uint8_t id, uint8_t r, uint8_t g, uint8_t b)
FX_STATUS WS2812BFX_GetColorRGB (uint8_t id, uint8_t *r, uint8_t *g, uint8_t *b)
void WS2812BFX_SetColorHSV (uint8_t id, uint16_t h, uint8_t s, uint8_t v)
void WS2812BFX_SetColor (uint8_t id, uint32_t c)
FX_STATUS WS2812BFX_SetAll (uint16_t Segment, uint32_t c)
FX_STATUS WS2812BFX_SetAllRGB (uint16_t Segment, uint8_t r, uint8_t g, uint8_t b)
void WS2812BFX_RGBtoHSV (uint8_t r, uint8_t g, uint8_t b, uint16_t *h, uint8_t *s, uint8_t *v)
void WS2812BFX_HSVtoRGB (uint16_t h, uint8_t s, uint8_t v, uint8_t *r, uint8_t *g, uint8_t *b)

Detailed Description

WS2812B lighting effects library - Ported from Arduino WS2812FX Library based on https://github.com/lamik/WS2812B_STM32_HAL.

Description

Rich lighting effects library for WS2812B LEDs ported from Arduino WS2812FX. Provides 58 predefined effects with segment support for independent control of different LED strip sections.

Key Features:

  • 58 predefined lighting effects
  • Multi-segment support (independent strip sections)
  • Adjustable speed per segment
  • Reversible effects
  • HSV and RGB color space support
  • Configurable segment size

Credits:

Basic Usage

#include "ws2812b_fx.h"
void app_main() {
// Initialize hardware
// Initialize effects library with 1 segment
WS2812BFX_Init(drv, 1);
// Configure segment 0 (entire strip)
// Main loop
while(1) {
WS2812BFX_Callback(); // Process effects
vTaskDelay(pdMS_TO_TICKS(10));
}
}
@ FX_MODE_RAINBOW_CYCLE
18: Rotating rainbow
Definition ws2812b_fx.h:218
void WS2812BFX_Callback(void)
Definition ws2812b_fx.c:334
FX_STATUS WS2812BFX_Start(uint16_t Segment)
Definition ws2812b_fx.c:516
FX_STATUS WS2812BFX_SetMode(uint16_t Segment, fx_mode Mode)
Definition ws2812b_fx.c:360
FX_STATUS WS2812BFX_Init(const ws2812b_drv_t *drv, uint16_t Segments)
Definition ws2812b_fx.c:215
FX_STATUS WS2812BFX_SetSpeed(uint16_t Segment, uint16_t Speed)
Definition ws2812b_fx.c:737
FX_STATUS WS2812BFX_SetSegmentSize(uint16_t Segment, uint16_t Start, uint16_t Stop)
Definition ws2812b_fx.c:494
#define WS2812B_IF_LEDS
Number of WS2812B LEDs in strip.
Definition ws2812b_drv_RMT.h:98
const ws2812b_drv_t * ws2812b_if_getDrvRMT(void)
Get RMT driver interface.
Definition ws2812b_drv_RMT.c:66
void ws2812b_if_init(void)
Initialize RMT peripheral for WS2812B control.
Definition ws2812b_drv_RMT.c:166
WS2812B driver interface structure.
Definition ws2812b_if.h:81
WS2812B driver implementation using ESP32 RMT peripheral.
WS2812B lighting effects library - Ported from Arduino WS2812FX Library based on https://github....

Segment Support

Segments allow independent control of different LED strip sections:

// Initialize with 2 segments
// Segment 0: LEDs 0-24 (rainbow effect)
// Segment 1: LEDs 25-49 (fire effect)
@ FX_MODE_FIRE_FLICKER
50: Realistic fire
Definition ws2812b_fx.h:250
Version
0.1
Date
15-04-2025
Author
Jan Łukaszewicz (plhar.nosp@m.eo@g.nosp@m.mail..nosp@m.com)

Function Documentation

◆ WS2812BFX_Callback()

void WS2812BFX_Callback ( void )

◆ WS2812BFX_DecreaseSpeed()

FX_STATUS WS2812BFX_DecreaseSpeed ( uint16_t Segment,
uint16_t Speed )

◆ WS2812BFX_ForceAllColor()

FX_STATUS WS2812BFX_ForceAllColor ( uint16_t Segment,
uint8_t r,
uint8_t g,
uint8_t b )

◆ WS2812BFX_GetColorRGB()

FX_STATUS WS2812BFX_GetColorRGB ( uint8_t id,
uint8_t * r,
uint8_t * g,
uint8_t * b )

◆ WS2812BFX_GetMode()

FX_STATUS WS2812BFX_GetMode ( uint16_t Segment,
fx_mode * Mode )

◆ WS2812BFX_GetReverse()

FX_STATUS WS2812BFX_GetReverse ( uint16_t Segment,
uint8_t * Reverse )

◆ WS2812BFX_GetSegmentSize()

FX_STATUS WS2812BFX_GetSegmentSize ( uint16_t Segment,
uint16_t * Start,
uint16_t * Stop )

◆ WS2812BFX_GetSegmentsQuantity()

uint8_t WS2812BFX_GetSegmentsQuantity ( void )

◆ WS2812BFX_GetSpeed()

FX_STATUS WS2812BFX_GetSpeed ( uint16_t Segment,
uint16_t * Speed )

◆ WS2812BFX_HSVtoRGB()

void WS2812BFX_HSVtoRGB ( uint16_t h,
uint8_t s,
uint8_t v,
uint8_t * r,
uint8_t * g,
uint8_t * b )

◆ WS2812BFX_IncreaseSpeed()

FX_STATUS WS2812BFX_IncreaseSpeed ( uint16_t Segment,
uint16_t Speed )

◆ WS2812BFX_Init()

FX_STATUS WS2812BFX_Init ( const ws2812b_drv_t * drv,
uint16_t Segments )

◆ WS2812BFX_IsRunning()

FX_STATUS WS2812BFX_IsRunning ( uint16_t Segment,
uint8_t * Running )

◆ WS2812BFX_NextMode()

FX_STATUS WS2812BFX_NextMode ( uint16_t Segment)

◆ WS2812BFX_PrevMode()

FX_STATUS WS2812BFX_PrevMode ( uint16_t Segment)

◆ WS2812BFX_RGBtoHSV()

void WS2812BFX_RGBtoHSV ( uint8_t r,
uint8_t g,
uint8_t b,
uint16_t * h,
uint8_t * s,
uint8_t * v )

◆ WS2812BFX_SegmentDecrease()

FX_STATUS WS2812BFX_SegmentDecrease ( ws2812b_drv_t * drv)

◆ WS2812BFX_SegmentDecreaseEnd()

FX_STATUS WS2812BFX_SegmentDecreaseEnd ( uint16_t Segment)

◆ WS2812BFX_SegmentDecreaseStart()

FX_STATUS WS2812BFX_SegmentDecreaseStart ( uint16_t Segment)

◆ WS2812BFX_SegmentIncrease()

FX_STATUS WS2812BFX_SegmentIncrease ( ws2812b_drv_t * drv)

◆ WS2812BFX_SegmentIncreaseEnd()

FX_STATUS WS2812BFX_SegmentIncreaseEnd ( uint16_t Segment)

◆ WS2812BFX_SegmentIncreaseStart()

FX_STATUS WS2812BFX_SegmentIncreaseStart ( uint16_t Segment)

◆ WS2812BFX_SetAll()

FX_STATUS WS2812BFX_SetAll ( uint16_t Segment,
uint32_t c )

◆ WS2812BFX_SetAllRGB()

FX_STATUS WS2812BFX_SetAllRGB ( uint16_t Segment,
uint8_t r,
uint8_t g,
uint8_t b )

◆ WS2812BFX_SetColor()

void WS2812BFX_SetColor ( uint8_t id,
uint32_t c )

◆ WS2812BFX_SetColorHSV()

void WS2812BFX_SetColorHSV ( uint8_t id,
uint16_t h,
uint8_t s,
uint8_t v )

◆ WS2812BFX_SetColorRGB()

void WS2812BFX_SetColorRGB ( uint8_t id,
uint8_t r,
uint8_t g,
uint8_t b )

◆ WS2812BFX_SetColorStruct()

void WS2812BFX_SetColorStruct ( uint8_t id,
ws2812b_color c )

◆ WS2812BFX_SetMode()

FX_STATUS WS2812BFX_SetMode ( uint16_t Segment,
fx_mode Mode )

◆ WS2812BFX_SetReverse()

FX_STATUS WS2812BFX_SetReverse ( uint16_t Segment,
uint8_t Reverse )

◆ WS2812BFX_SetSegmentSize()

FX_STATUS WS2812BFX_SetSegmentSize ( uint16_t Segment,
uint16_t Start,
uint16_t Stop )

◆ WS2812BFX_SetSpeed()

FX_STATUS WS2812BFX_SetSpeed ( uint16_t Segment,
uint16_t Speed )

◆ WS2812BFX_Start()

FX_STATUS WS2812BFX_Start ( uint16_t Segment)

◆ WS2812BFX_Stop()

FX_STATUS WS2812BFX_Stop ( uint16_t Segment)

◆ WS2812BFX_SysTickCallback()

void WS2812BFX_SysTickCallback ( void )