You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.1 KiB

/*
* ws281x.h
*
* The MIT License.
* Created on: 14.07.2017
* Author: Mateusz Salamon
* www.msalamon.pl
* mateusz@msalamon.pl
*/
#ifndef WS281X_H_
#define WS281X_H_
/* Includes */
#include <stdint.h>
#include "main.h"
/* Defintions */
/* Data Structures */
typedef enum ws281x_type_e {
WS281X_TYPE_WS2811 = 0,
WS281X_TYPE_WS2812,
WS281X_TYPE_WS2812B,
WS281X_TYPE_SK6812,
WS281X_TYPE_SK6812RGBW,
WS281X_TYPE_WS2813B,
WS281X_TYPE_END
} ws281x_type_t;
typedef union __attribute__((packed, aligned(4))) ws281x_color_u {
struct __attribute__((packed, aligned(4))) rgbx_s {
uint8_t r; /* red */
uint8_t g; /* green */
uint8_t b; /* blue */
uint8_t x; /* additional color channel - commonly white or warm white */
} rgbx;
uint32_t u32;
uint8_t u8[4];
} ws281x_color_t;
typedef struct ws281x_s ws281x_t;
/* Function Prototypes */
ws281x_t *ws281x_init(ws281x_type_t type, SPI_HandleTypeDef *hspi, ws281x_color_t *leds, int32_t num_leds);
void ws281x_refresh(ws281x_t *ws281x);
int32_t ws281x_set_led(ws281x_t *ws281x, uint16_t led_id, ws281x_color_t color);
#endif /* WS281X_H_ */