diff options
Diffstat (limited to 'quantum/light_ws2812.h')
| -rwxr-xr-x | quantum/light_ws2812.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/quantum/light_ws2812.h b/quantum/light_ws2812.h new file mode 100755 index 000000000..54eef22d9 --- /dev/null +++ b/quantum/light_ws2812.h | |||
| @@ -0,0 +1,73 @@ | |||
| 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" | ||
| 19 | |||
| 20 | /* | ||
| 21 | * Structure of the LED array | ||
| 22 | * | ||
| 23 | * cRGB: RGB for WS2812S/B/C/D, SK6812, SK6812Mini, SK6812WWA, APA104, APA106 | ||
| 24 | * cRGBW: RGBW for SK6812RGBW | ||
| 25 | */ | ||
| 26 | |||
| 27 | struct cRGB { uint8_t g; uint8_t r; uint8_t b; }; | ||
| 28 | struct cRGBW { uint8_t g; uint8_t r; uint8_t b; uint8_t w;}; | ||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | /* User Interface | ||
| 33 | * | ||
| 34 | * Input: | ||
| 35 | * ledarray: An array of GRB data describing the LED colors | ||
| 36 | * number_of_leds: The number of LEDs to write | ||
| 37 | * pinmask (optional): Bitmask describing the output bin. e.g. _BV(PB0) | ||
| 38 | * | ||
| 39 | * The functions will perform the following actions: | ||
| 40 | * - Set the data-out pin as output | ||
| 41 | * - Send out the LED data | ||
| 42 | * - Wait 50�s to reset the LEDs | ||
| 43 | */ | ||
| 44 | |||
| 45 | void ws2812_setleds (struct cRGB *ledarray, uint16_t number_of_leds); | ||
| 46 | void ws2812_setleds_pin (struct cRGB *ledarray, uint16_t number_of_leds,uint8_t pinmask); | ||
| 47 | void ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t number_of_leds); | ||
| 48 | |||
| 49 | /* | ||
| 50 | * Old interface / Internal functions | ||
| 51 | * | ||
| 52 | * The functions take a byte-array and send to the data output as WS2812 bitstream. | ||
| 53 | * The length is the number of bytes to send - three per LED. | ||
| 54 | */ | ||
| 55 | |||
| 56 | void ws2812_sendarray (uint8_t *array,uint16_t length); | ||
| 57 | void ws2812_sendarray_mask(uint8_t *array,uint16_t length, uint8_t pinmask); | ||
| 58 | |||
| 59 | |||
| 60 | /* | ||
| 61 | * Internal defines | ||
| 62 | */ | ||
| 63 | #ifndef CONCAT | ||
| 64 | #define CONCAT(a, b) a ## b | ||
| 65 | #endif | ||
| 66 | #ifndef CONCAT_EXP | ||
| 67 | #define CONCAT_EXP(a, b) CONCAT(a, b) | ||
| 68 | #endif | ||
| 69 | |||
| 70 | // #define ws2812_PORTREG CONCAT_EXP(PORT,ws2812_port) | ||
| 71 | // #define ws2812_DDRREG CONCAT_EXP(DDR,ws2812_port) | ||
| 72 | |||
| 73 | #endif /* LIGHT_WS2812_H_ */ | ||
