PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Driver for WS2812 and WS2812B RGB LEDs. More...
#include <stdint.h>
Go to the source code of this file.
Classes | |
struct | ws2812_t |
Macros | |
#define | TYPE_RGB 0 |
#define | TYPE_GRB 1 |
#define | COLOR(r, g, b) (((r) << 16) | ((g) << 8) | (b)) |
#define | SCALE(x, l) ((x) * (l) / 255) |
#define | COLORX(r, g, b, l) ((SCALE(r, l) << 16) | (SCALE(g, l) << 8) | SCALE(b, l)) |
#define | COLOR_BLACK 0x000000 |
#define | COLOR_RED 0xFF0000 |
#define | COLOR_GREEN 0x00FF00 |
#define | COLOR_BLUE 0x0000FF |
#define | COLOR_WHITE 0xFFFFFF |
#define | COLOR_CYAN 0x00FFFF |
#define | COLOR_MAGENTA 0xFF00FF |
#define | COLOR_YELLOW 0xFFFF00 |
#define | COLOR_CHARTREUSE 0x7FFF00 |
#define | COLOR_ORANGE 0xFF6000 |
#define | COLOR_AQUAMARINE 0x7FFFD4 |
#define | COLOR_PINK 0xFF5F5F |
#define | COLOR_TURQUOISE 0x3FE0C0 |
#define | COLOR_REALWHITE 0xC8FFFF |
#define | COLOR_INDIGO 0x3F007F |
#define | COLOR_VIOLET 0xBF7FBF |
#define | COLOR_MAROON 0x320010 |
#define | COLOR_BROWN 0x0E0600 |
#define | COLOR_CRIMSON 0xDC283C |
#define | COLOR_PURPLE 0x8C00FF |
Typedefs | |
typedef ws2812_t | ws2812 |
Functions | |
ws2812_t * | ws2812_open (void) |
Open a driver for WS2812 chips. More... | |
ws2812_t * | ws2812b_open (void) |
Open a driver for WS2812B chips. More... | |
void | ws2812_close (ws2812_t *driver) |
Close a WS2812 or WS2812B driver. More... | |
int | ws2812_start (ws2812_t *driver) |
Start a driver for WS2812 chips. More... | |
int | ws2812b_start (ws2812_t *driver) |
Start a driver for WS2812B chips. More... | |
int | ws_start (ws2812_t *driver, int usreset, int ns0h, int ns0l, int ns1h, int ns1l, int type) |
Load a COG with a driver using custom parameters. More... | |
void | ws2812_stop (ws2812_t *driver) |
Shut down the COG running a driver. More... | |
void | ws2812_set (ws2812_t *driver, int pin, uint32_t *colors, int count) |
Set color pattern on a chain of LEDs. More... | |
uint32_t | ws2812_wheel (int pos) |
Create color from a 0 to 255 position input. More... | |
uint32_t | ws2812_wheel_dim (int pos, int brightness) |
Create color from a 0 to 255 position input. More... | |
Driver for WS2812 and WS2812B RGB LEDs.
Definition in file ws2812.h.
struct ws2812_t |
void ws2812_close | ( | ws2812_t * | driver | ) |
Close a WS2812 or WS2812B driver.
driver | Pointer to the driver structure |
Definition at line 17 of file ws2812_close.c.
ws2812_t* ws2812_open | ( | void | ) |
Open a driver for WS2812 chips.
Definition at line 17 of file ws2812_open.c.
void ws2812_set | ( | ws2812_t * | driver, |
int | pin, | ||
uint32_t * | colors, | ||
int | count | ||
) |
int ws2812_start | ( | ws2812_t * | driver | ) |
Start a driver for WS2812 chips.
driver | Pointer to a driver structure |
Definition at line 16 of file ws2812_start.c.
void ws2812_stop | ( | ws2812_t * | driver | ) |
Shut down the COG running a driver.
driver | Pointer to the driver structure |
Definition at line 17 of file ws2812_stop.c.
uint32_t ws2812_wheel | ( | int | pos | ) |
Create color from a 0 to 255 position input.
Colors transition red to green to blue.
pos | Position in the color spectrum where 0 is on the red end and 255 is on the blue end |
Definition at line 16 of file ws2812_wheel.c.
uint32_t ws2812_wheel_dim | ( | int | pos, |
int | brightness | ||
) |
Create color from a 0 to 255 position input.
Colors transition red to green to blue.
pos | Position in the color spectrum where 0 is on the red end and 255 is on the blue end |
brightness | The brightness of the generated color where 0 is off and 255 is full |
Definition at line 16 of file ws2812_wheel_dim.c.
ws2812_t* ws2812b_open | ( | void | ) |
Open a driver for WS2812B chips.
Definition at line 17 of file ws2812b_open.c.
int ws2812b_start | ( | ws2812_t * | driver | ) |
Start a driver for WS2812B chips.
driver | Pointer to a driver structure |
Definition at line 16 of file ws2812b_start.c.
int ws_start | ( | ws2812_t * | driver, |
int | usreset, | ||
int | ns0h, | ||
int | ns0l, | ||
int | ns1h, | ||
int | ns1l, | ||
int | type | ||
) |
Load a COG with a driver using custom parameters.
usreset | Reset timing (us) |
ns0h | 0-bit high timing (ns) |
ns0l | 0-bit low timing (ns) |
ns1h | 1-bit high timing (ns) |
ns1l | 1-bit low timing (ns) |
type | color format (either TYPE_RGB or TYPE_GRB) |
Definition at line 35 of file ws2812.c.