summaryrefslogtreecommitdiff
path: root/drivers/avr
diff options
context:
space:
mode:
authorXScorpion2 <rcalt2vt@gmail.com>2019-04-14 20:50:35 -0400
committerDrashna Jaelre <drashna@live.com>2019-04-16 18:11:33 -0700
commite3fce19c55271f4a383ac81a0ba33875262897f4 (patch)
tree3daa55aa215609d5e411574b3959e5275bb10b81 /drivers/avr
parent590a07bf946c47dc80604b54e9f1a45b517b5e05 (diff)
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 5bd837ec75..b3ed4fd0b0 100644
--- a/drivers/avr/ws2812.c
+++ b/drivers/avr/ws2812.c
@@ -27,6 +27,12 @@
#include <util/delay.h>
#include "debug.h"
+#if !defined(LED_ARRAY) && defined(RGB_MATRIX_ENABLE)
+// LED color buffer
+LED_TYPE led[DRIVER_LED_TOTAL];
+ #define LED_ARRAY led
+#endif
+
#ifdef RGBW_BB_TWI
// Port for the I2C
@@ -141,6 +147,25 @@ unsigned char I2C_Write(unsigned char c)
#endif
+#ifdef RGB_MATRIX_ENABLE
+// Set an led in the buffer to a color
+void inline ws2812_setled(int i, uint8_t r, uint8_t g, uint8_t b)
+{
+ led[i].r = r;
+ led[i].g = g;
+ led[i].b = b;
+}
+
+void ws2812_setled_all (uint8_t r, uint8_t g, uint8_t b)
+{
+ for (int i = 0; i < RGBLED_NUM; i++) {
+ led[i].r = r;
+ led[i].g = g;
+ led[i].b = b;
+ }
+}
+#endif
+
// Setleds for standard RGB
void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds)
{
diff --git a/drivers/avr/ws2812.h b/drivers/avr/ws2812.h
index 1f9299ffb5..ecb1dc4d18 100644
--- a/drivers/avr/ws2812.h
+++ b/drivers/avr/ws2812.h
@@ -30,7 +30,6 @@
#include "rgblight_types.h"
-
/* User Interface
*
* Input:
@@ -43,6 +42,10 @@
* - Send out the LED data
* - Wait 50�s to reset the LEDs
*/
+#ifdef RGB_MATRIX_ENABLE
+void ws2812_setled (int index, uint8_t r, uint8_t g, uint8_t b);
+void ws2812_setled_all (uint8_t r, uint8_t g, uint8_t b);
+#endif
void ws2812_setleds (LED_TYPE *ledarray, uint16_t number_of_leds);
void ws2812_setleds_pin (LED_TYPE *ledarray, uint16_t number_of_leds,uint8_t pinmask);