/* * ws2812b.h * * The MIT License. * Created on: 14.07.2017 * Author: Mateusz Salamon * www.msalamon.pl * mateusz@msalamon.pl */ #ifndef WS2812B_H_ #define WS2812B_H_ /* Includes */ #include /* Defintions */ #define WS2812B_LEDS (1) /* Data Structures */ typedef union __attribute__((packed, aligned(4))) ws2812b_color_u { struct __attribute__((packed, aligned(4))) rgbx_s { uint8_t green; uint8_t red; uint8_t blue; uint8_t x; } rgbx; struct __attribute__((packed, aligned(4))) rgb_s { uint8_t _pad; uint8_t green; uint8_t red; uint8_t blue; } rgb; uint32_t u32; uint8_t u8[4]; } ws2812b_color; /* Function Prototypes */ void WS2812B_Init(SPI_HandleTypeDef * spi_handler); void WS2812B_SetDiodeColor(uint16_t diode_id, uint32_t color); void WS2812B_SetDiodeColorStruct(uint16_t diode_id, ws2812b_color color); void WS2812B_SetDiodeRGB(uint16_t diode_id, uint8_t r, uint8_t g, uint8_t b); void WS2812B_SetDiodeRGBX(uint16_t diode_id, uint8_t r, uint8_t g, uint8_t b, uint8_t x); void WS2812B_SetDiodeHSV(uint16_t diode_id, uint16_t hue, uint8_t sat, uint8_t brt); uint32_t WS2812B_GetColor(uint16_t diode_id); uint8_t* WS2812B_GetPixels(void); void WS2812B_Refresh(); // color correction uint8_t sine8(uint8_t x); uint8_t gamma8(uint8_t x); #endif /* WS2812B_H_ */