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 /quantum | |
| 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 'quantum')
| -rw-r--r-- | quantum/rgb_matrix_drivers.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/quantum/rgb_matrix_drivers.c b/quantum/rgb_matrix_drivers.c index 5b54bd595..503f97014 100644 --- a/quantum/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix_drivers.c | |||
| @@ -97,19 +97,33 @@ const rgb_matrix_driver_t rgb_matrix_driver = { | |||
| 97 | 97 | ||
| 98 | #elif defined(WS2812) | 98 | #elif defined(WS2812) |
| 99 | 99 | ||
| 100 | extern LED_TYPE led[DRIVER_LED_TOTAL]; | 100 | // LED color buffer |
| 101 | LED_TYPE led[DRIVER_LED_TOTAL]; | ||
| 102 | |||
| 103 | static void init(void) {} | ||
| 101 | 104 | ||
| 102 | static void flush(void) { | 105 | static void flush(void) { |
| 103 | // Assumes use of RGB_DI_PIN | 106 | // Assumes use of RGB_DI_PIN |
| 104 | ws2812_setleds(led, DRIVER_LED_TOTAL); | 107 | ws2812_setleds(led, DRIVER_LED_TOTAL); |
| 105 | } | 108 | } |
| 106 | 109 | ||
| 107 | static void init(void) {} | 110 | // Set an led in the buffer to a color |
| 111 | static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) { | ||
| 112 | led[i].r = r; | ||
| 113 | led[i].g = g; | ||
| 114 | led[i].b = b; | ||
| 115 | } | ||
| 116 | |||
| 117 | static void setled_all(uint8_t r, uint8_t g, uint8_t b) { | ||
| 118 | for (int i = 0; i < sizeof(led) / sizeof(led[0]); i++) { | ||
| 119 | setled(i, r, g, b); | ||
| 120 | } | ||
| 121 | } | ||
| 108 | 122 | ||
| 109 | const rgb_matrix_driver_t rgb_matrix_driver = { | 123 | const rgb_matrix_driver_t rgb_matrix_driver = { |
| 110 | .init = init, | 124 | .init = init, |
| 111 | .flush = flush, | 125 | .flush = flush, |
| 112 | .set_color = ws2812_setled, | 126 | .set_color = setled, |
| 113 | .set_color_all = ws2812_setled_all, | 127 | .set_color_all = setled_all, |
| 114 | }; | 128 | }; |
| 115 | #endif | 129 | #endif |
