diff options
author | Joel Challis <git@zvecr.com> | 2019-10-29 01:00:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-29 01:00:03 +0000 |
commit | e48fdebe5a351772c4f34b201130271a42c1496d (patch) | |
tree | fae47f5c1eb817e8f36c0ae87b60ab152ea171f1 /drivers/avr/ws2812.c | |
parent | 1b06ea0c863b493215d80400f00797ceb0eabc3d (diff) | |
download | qmk_firmware-e48fdebe5a351772c4f34b201130271a42c1496d.tar.gz qmk_firmware-e48fdebe5a351772c4f34b201130271a42c1496d.zip |
Reduce duplication for ARM/AVR ws2812 RGB Matrix driver (#7180)
* Reduce duplication for ARM/AVR ws2812 rgb_matrix driver
* Reduce duplication for ARM/AVR ws2812 rgb_matrix driver - Fix setled_all use of r,g,b
Diffstat (limited to 'drivers/avr/ws2812.c')
-rw-r--r-- | drivers/avr/ws2812.c | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/drivers/avr/ws2812.c b/drivers/avr/ws2812.c index 0a02c6f7f..5c733c4ab 100644 --- a/drivers/avr/ws2812.c +++ b/drivers/avr/ws2812.c | |||
@@ -25,13 +25,17 @@ | |||
25 | #include <avr/interrupt.h> | 25 | #include <avr/interrupt.h> |
26 | #include <avr/io.h> | 26 | #include <avr/io.h> |
27 | #include <util/delay.h> | 27 | #include <util/delay.h> |
28 | #include "debug.h" | ||
29 | 28 | ||
30 | #if !defined(LED_ARRAY) && defined(RGB_MATRIX_ENABLE) | 29 | /* |
31 | // LED color buffer | 30 | * Forward declare internal functions |
32 | LED_TYPE led[DRIVER_LED_TOTAL]; | 31 | * |
33 | # define LED_ARRAY led | 32 | * The functions take a byte-array and send to the data output as WS2812 bitstream. |
34 | #endif | 33 | * The length is the number of bytes to send - three per LED. |
34 | */ | ||
35 | |||
36 | void ws2812_sendarray(uint8_t *array, uint16_t length); | ||
37 | void ws2812_sendarray_mask(uint8_t *array, uint16_t length, uint8_t pinmask); | ||
38 | |||
35 | 39 | ||
36 | #ifdef RGBW_BB_TWI | 40 | #ifdef RGBW_BB_TWI |
37 | 41 | ||
@@ -135,23 +139,6 @@ unsigned char I2C_Write(unsigned char c) { | |||
135 | 139 | ||
136 | #endif | 140 | #endif |
137 | 141 | ||
138 | #ifdef RGB_MATRIX_ENABLE | ||
139 | // Set an led in the buffer to a color | ||
140 | void inline ws2812_setled(int i, uint8_t r, uint8_t g, uint8_t b) { | ||
141 | led[i].r = r; | ||
142 | led[i].g = g; | ||
143 | led[i].b = b; | ||
144 | } | ||
145 | |||
146 | void ws2812_setled_all(uint8_t r, uint8_t g, uint8_t b) { | ||
147 | for (int i = 0; i < sizeof(led) / sizeof(led[0]); i++) { | ||
148 | led[i].r = r; | ||
149 | led[i].g = g; | ||
150 | led[i].b = b; | ||
151 | } | ||
152 | } | ||
153 | #endif | ||
154 | |||
155 | // Setleds for standard RGB | 142 | // Setleds for standard RGB |
156 | void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) { | 143 | void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) { |
157 | // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin)); | 144 | // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin)); |