ws2812 library
v0.85
Supports ws2812 and ws2812b
Main Page
Data Structures
Files
File List
Globals
ws2812.h
Go to the documentation of this file.
1
14
#ifndef __WS2812_H__
15
#define __WS2812_H__
16
17
#include <stdint.h>
18
19
#if defined(__cplusplus)
20
extern
"C"
{
21
#endif
22
23
#define TYPE_RGB 0
24
#define TYPE_GRB 1 // for WS2812 and WS2812B
25
26
#define COLOR(r, g, b) (((r) << 16) | ((g) << 8) | (b))
27
#define SCALE(x, l) ((x) * (l) / 255)
28
#define COLORX(r, g, b, l) ((SCALE(r, l) << 16) | (SCALE(g, l) << 8) | SCALE(b, l))
29
30
// RRGGBB
31
#define COLOR_BLACK 0x000000
32
#define COLOR_RED 0xFF0000
33
#define COLOR_GREEN 0x00FF00
34
#define COLOR_BLUE 0x0000FF
35
#define COLOR_WHITE 0xFFFFFF
36
#define COLOR_CYAN 0x00FFFF
37
#define COLOR_MAGENTA 0xFF00FF
38
#define COLOR_YELLOW 0xFFFF00
39
#define COLOR_CHARTREUSE 0x7FFF00
40
#define COLOR_ORANGE 0xFF6000
41
#define COLOR_AQUAMARINE 0x7FFFD4
42
#define COLOR_PINK 0xFF5F5F
43
#define COLOR_TURQUOISE 0x3FE0C0
44
#define COLOR_REALWHITE 0xC8FFFF
45
#define COLOR_INDIGO 0x3F007F
46
#define COLOR_VIOLET 0xBF7FBF
47
#define COLOR_MAROON 0x320010
48
#define COLOR_BROWN 0x0E0600
49
#define COLOR_CRIMSON 0xDC283C
50
#define COLOR_PURPLE 0x8C00FF
51
52
// driver state structure
53
typedef
struct
{
54
volatile
uint32_t command;
55
int
cog;
56
}
ws2812_t
;
57
58
// simpler type name for use with SimpleIDE
59
typedef
ws2812_t
ws2812
;
60
66
ws2812_t
*
ws2812_open
(
void
);
67
73
ws2812_t
*
ws2812b_open
(
void
);
74
80
void
ws2812_close
(
ws2812_t
*driver);
81
88
int
ws2812_start
(
ws2812_t
*driver);
89
96
int
ws2812b_start
(
ws2812_t
*driver);
97
109
int
ws_start(
ws2812_t
*driver,
int
usreset,
int
ns0h,
int
ns0l,
int
ns1h,
int
ns1l,
int
type);
110
116
void
ws2812_stop
(
ws2812_t
*driver);
117
126
void
ws2812_set(
ws2812_t
*driver,
int
pin, uint32_t *colors,
int
count);
127
136
uint32_t
ws2812_wheel
(
int
pos);
137
147
uint32_t
ws2812_wheel_dim
(
int
pos,
int
brightness);
148
149
#if defined(__cplusplus)
150
}
151
#endif
152
153
#endif
154
Generated on Fri Oct 31 2014 10:59:10 for ws2812 library by
1.8.1.2