Kaleidoscope
light_ws2812.h
Go to the documentation of this file.
1 /*
2  * light weight WS2812 lib include
3  *
4  * Version 2.3 - Nev 29th 2015
5  * Author: Tim (cpldcpu@gmail.com)
6  *
7  * Please do not change this file! All configuration is handled in "ws2812_config.h"
8  *
9  * License: GNU GPL v2 (see License.txt)
10  +
11  */
12 
13 #ifndef LIGHT_WS2812_H_
14 #define LIGHT_WS2812_H_
15 
16 #include <avr/io.h>
17 #include <avr/interrupt.h>
18 #include "ws2812_config.h"
20 
21 /*
22  * Structure of the LED array
23  *
24  * cRGB: RGB for WS2812S/B/C/D, SK6812, SK6812Mini, SK6812WWA, APA104, APA106
25  * cRGBW: RGBW for SK6812RGBW
26  */
27 /*
28 struct cRGB { uint8_t g; uint8_t r; uint8_t b; };
29 struct cRGBW { uint8_t g; uint8_t r; uint8_t b; uint8_t w;};
30 */
31 
32 
33 
34 /* User Interface
35  *
36  * Input:
37  * ledarray: An array of GRB data describing the LED colors
38  * number_of_leds: The number of LEDs to write
39  * pinmask (optional): Bitmask describing the output bin. e.g. _BV(PB0)
40  *
41  * The functions will perform the following actions:
42  * - Set the data-out pin as output
43  * - Send out the LED data
44  * - Wait 50µs to reset the LEDs
45  */
46 
47 void ws2812_setleds (cRGB *ledarray, uint16_t number_of_leds);
48 void ws2812_setleds_pin (cRGB *ledarray, uint16_t number_of_leds,uint8_t pinmask);
49 
50 /*
51  * Old interface / Internal functions
52  *
53  * The functions take a byte-array and send to the data output as WS2812 bitstream.
54  * The length is the number of bytes to send - three per LED.
55  */
56 
57 void ws2812_sendarray (uint8_t *array,uint16_t length);
58 void ws2812_sendarray_mask(uint8_t *array,uint16_t length, uint8_t pinmask);
59 
60 
61 /*
62  * Internal defines
63  */
64 
65 #define CONCAT(a, b) a ## b
66 #define CONCAT_EXP(a, b) CONCAT(a, b)
67 
68 #define ws2812_PORTREG CONCAT_EXP(PORT,ws2812_port)
69 #define ws2812_DDRREG CONCAT_EXP(DDR,ws2812_port)
70 
71 #endif /* LIGHT_WS2812_H_ */
void ws2812_sendarray_mask(uint8_t *array, uint16_t length, uint8_t pinmask)
Definition: light_ws2812.cpp:97
void ws2812_sendarray(uint8_t *array, uint16_t length)
Definition: light_ws2812.cpp:31
Definition: Kaleidoscope-Hardware-Shortcut.h:29
void ws2812_setleds(cRGB *ledarray, uint16_t number_of_leds)
Definition: light_ws2812.cpp:19
void ws2812_setleds_pin(cRGB *ledarray, uint16_t number_of_leds, uint8_t pinmask)
Definition: light_ws2812.cpp:24