SNAKE_STM32F3
Loading...
Searching...
No Matches
ws2812b.c File Reference

Implementation of ws2812b diodes handling module (STM32 HAL). More...

#include "ws2812b.h"
Include dependency graph for ws2812b.c:

Data Structures

struct  ws2812b_color

Macros

#define BRIGHTNESS_MODE   2
#define BRIGHTNESS   0.5
#define zero   0b1100000
#define one   0b11111000

Functions

void ws2812b_init (SPI_HandleTypeDef *spi_handler)
 Initializes ws2812b handling module by passing given SPI handler.
void ws2812b_set_rgb (uint16_t diode_id, uint8_t R, uint8_t G, uint8_t B)
 Sets chosen diode to specified RGB color.
void ws2812b_update (void)
 Transfers diode color values specified with ws2812b_set_rgb to physical display.

Detailed Description

Implementation of ws2812b diodes handling module (STM32 HAL).

Author
bslrd
Date
2026

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ BRIGHTNESS

#define BRIGHTNESS   0.5

◆ BRIGHTNESS_MODE

#define BRIGHTNESS_MODE   2

◆ one

#define one   0b11111000

◆ zero

#define zero   0b1100000

Function Documentation

◆ ws2812b_init()

void ws2812b_init ( SPI_HandleTypeDef * spi_handler)

Initializes ws2812b handling module by passing given SPI handler.

Parameters
spi_handlerpointer to spi handler of choice.
Note
Should be called from main() before use of other ws2812b functions

◆ ws2812b_set_rgb()

void ws2812b_set_rgb ( uint16_t diode_id,
uint8_t R,
uint8_t G,
uint8_t B )

Sets chosen diode to specified RGB color.

Parameters
diode_idIndex of LED (0 to LED_NUMBER-1).
RR value of color (0 to 255)
GG value of color (0 to 255)
BB value of color (0 to 255)
Note
Stores RGB value in internal buffer (ws2812b_color); does not update physical LEDs.

◆ ws2812b_update()

void ws2812b_update ( void )

Transfers diode color values specified with ws2812b_set_rgb to physical display.