aboutsummaryrefslogtreecommitdiff
path: root/drivers/avr
diff options
context:
space:
mode:
authorXScorpion2 <rcalt2vt@gmail.com>2019-04-14 20:50:35 -0400
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-04-14 17:50:35 -0700
commit5fcd744ddba591829a129560992b2e43fb615d4d (patch)
tree33b78133af1563f5dfa1e125a37f86e30a7df1cb /drivers/avr
parentd7ba190cd9b90bce3a00dfa2a9afe4b3bf0a1dbb (diff)
downloadqmk_firmware-5fcd744ddba591829a129560992b2e43fb615d4d.tar.gz
qmk_firmware-5fcd744ddba591829a129560992b2e43fb615d4d.zip
Features/ws2812 matrix driver (#5418)
* WS2812 driver implementation for RGB Matrix * Added driver configuration docs
Diffstat (limited to 'drivers/avr')
-rw-r--r--drivers/avr/ws2812.c25
-rw-r--r--drivers/avr/ws2812.h5
2 files changed, 29 insertions, 1 deletions
diff --git a/drivers/avr/ws2812.c b/drivers/avr/ws2812.c
index 5bd837ec7..b3ed4fd0b 100644
--- a/drivers/avr/ws2812.c
+++ b/drivers/avr/ws2812.c
@@ -27,6 +27,12 @@
27#include <util/delay.h> 27#include <util/delay.h>
28#include "debug.h" 28#include "debug.h"
29 29
30#if !defined(LED_ARRAY) && defined(RGB_MATRIX_ENABLE)
31// LED color buffer
32LED_TYPE led[DRIVER_LED_TOTAL];
33 #define LED_ARRAY led
34#endif
35
30#ifdef RGBW_BB_TWI 36#ifdef RGBW_BB_TWI
31 37
32// Port for the I2C 38// Port for the I2C
@@ -141,6 +147,25 @@ unsigned char I2C_Write(unsigned char c)
141 147
142#endif 148#endif
143 149
150#ifdef RGB_MATRIX_ENABLE
151// Set an led in the buffer to a color
152void inline ws2812_setled(int i, uint8_t r, uint8_t g, uint8_t b)
153{
154 led[i].r = r;
155 led[i].g = g;
156 led[i].b = b;
157}
158
159void ws2812_setled_all (uint8_t r, uint8_t g, uint8_t b)
160{
161 for (int i = 0; i < RGBLED_NUM; i++) {
162 led[i].r = r;
163 led[i].g = g;
164 led[i].b = b;
165 }
166}
167#endif
168
144// Setleds for standard RGB 169// Setleds for standard RGB
145void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) 170void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds)
146{ 171{
diff --git a/drivers/avr/ws2812.h b/drivers/avr/ws2812.h
index 1f9299ffb..ecb1dc4d1 100644
--- a/drivers/avr/ws2812.h
+++ b/drivers/avr/ws2812.h
@@ -30,7 +30,6 @@
30 30
31#include "rgblight_types.h" 31#include "rgblight_types.h"
32 32
33
34/* User Interface 33/* User Interface
35 * 34 *
36 * Input: 35 * Input:
@@ -43,6 +42,10 @@
43 * - Send out the LED data 42 * - Send out the LED data
44 * - Wait 50�s to reset the LEDs 43 * - Wait 50�s to reset the LEDs
45 */ 44 */
45#ifdef RGB_MATRIX_ENABLE
46void ws2812_setled (int index, uint8_t r, uint8_t g, uint8_t b);
47void ws2812_setled_all (uint8_t r, uint8_t g, uint8_t b);
48#endif
46 49
47void ws2812_setleds (LED_TYPE *ledarray, uint16_t number_of_leds); 50void ws2812_setleds (LED_TYPE *ledarray, uint16_t number_of_leds);
48void ws2812_setleds_pin (LED_TYPE *ledarray, uint16_t number_of_leds,uint8_t pinmask); 51void ws2812_setleds_pin (LED_TYPE *ledarray, uint16_t number_of_leds,uint8_t pinmask);