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 | |
| 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')
| -rw-r--r-- | drivers/avr/ws2812.c | 33 | ||||
| -rw-r--r-- | drivers/avr/ws2812.h | 35 |
2 files changed, 11 insertions, 57 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)); |
diff --git a/drivers/avr/ws2812.h b/drivers/avr/ws2812.h index a9dd89718..9652b94bb 100644 --- a/drivers/avr/ws2812.h +++ b/drivers/avr/ws2812.h | |||
| @@ -20,13 +20,7 @@ | |||
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #ifndef LIGHT_WS2812_H_ | 23 | #pragma once |
| 24 | #define LIGHT_WS2812_H_ | ||
| 25 | |||
| 26 | #include <avr/io.h> | ||
| 27 | #include <avr/interrupt.h> | ||
| 28 | //#include "ws2812_config.h" | ||
| 29 | //#include "i2cmaster.h" | ||
| 30 | 24 | ||
| 31 | #include "quantum/color.h" | 25 | #include "quantum/color.h" |
| 32 | 26 | ||
| @@ -42,33 +36,6 @@ | |||
| 42 | * - Send out the LED data | 36 | * - Send out the LED data |
| 43 | * - Wait 50�s to reset the LEDs | 37 | * - Wait 50�s to reset the LEDs |
| 44 | */ | 38 | */ |
| 45 | #ifdef RGB_MATRIX_ENABLE | ||
| 46 | void ws2812_setled(int index, uint8_t r, uint8_t g, uint8_t b); | ||
| 47 | void ws2812_setled_all(uint8_t r, uint8_t g, uint8_t b); | ||
| 48 | #endif | ||
| 49 | |||
| 50 | void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds); | 39 | void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds); |
| 51 | void ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t number_of_leds, uint8_t pinmask); | 40 | void ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t number_of_leds, uint8_t pinmask); |
| 52 | void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds); | 41 | void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds); |
| 53 | |||
| 54 | /* | ||
| 55 | * Old interface / Internal functions | ||
| 56 | * | ||
| 57 | * The functions take a byte-array and send to the data output as WS2812 bitstream. | ||
| 58 | * The length is the number of bytes to send - three per LED. | ||
| 59 | */ | ||
| 60 | |||
| 61 | void ws2812_sendarray(uint8_t *array, uint16_t length); | ||
| 62 | void ws2812_sendarray_mask(uint8_t *array, uint16_t length, uint8_t pinmask); | ||
| 63 | |||
| 64 | /* | ||
| 65 | * Internal defines | ||
| 66 | */ | ||
| 67 | #ifndef CONCAT | ||
| 68 | # define CONCAT(a, b) a##b | ||
| 69 | #endif | ||
| 70 | #ifndef CONCAT_EXP | ||
| 71 | # define CONCAT_EXP(a, b) CONCAT(a, b) | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #endif /* LIGHT_WS2812_H_ */ | ||
