aboutsummaryrefslogtreecommitdiff
path: root/quantum/rgb_matrix
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgb_matrix')
-rw-r--r--quantum/rgb_matrix/animations/alpha_mods_anim.h2
-rw-r--r--quantum/rgb_matrix/animations/breathing_anim.h2
-rw-r--r--quantum/rgb_matrix/animations/fractal_anim.h74
-rw-r--r--quantum/rgb_matrix/animations/gradient_left_right_anim.h2
-rw-r--r--quantum/rgb_matrix/animations/gradient_up_down_anim.h2
-rw-r--r--quantum/rgb_matrix/animations/hue_breathing_anim.h2
-rw-r--r--quantum/rgb_matrix/animations/jellybean_raindrops_anim.h2
-rw-r--r--quantum/rgb_matrix/animations/pixel_rain_anim.h44
-rw-r--r--quantum/rgb_matrix/animations/raindrops_anim.h2
-rw-r--r--quantum/rgb_matrix/animations/rgb_matrix_effects.inc2
-rw-r--r--quantum/rgb_matrix/animations/runners/effect_runner_dx_dy.h2
-rw-r--r--quantum/rgb_matrix/animations/runners/effect_runner_dx_dy_dist.h2
-rw-r--r--quantum/rgb_matrix/animations/runners/effect_runner_i.h2
-rw-r--r--quantum/rgb_matrix/animations/runners/effect_runner_reactive.h2
-rw-r--r--quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h2
-rw-r--r--quantum/rgb_matrix/animations/runners/effect_runner_sin_cos_i.h2
-rw-r--r--quantum/rgb_matrix/animations/solid_color_anim.h2
-rw-r--r--quantum/rgb_matrix/rgb_matrix.c41
-rw-r--r--quantum/rgb_matrix/rgb_matrix.h47
-rw-r--r--quantum/rgb_matrix/rgb_matrix_drivers.c184
20 files changed, 316 insertions, 104 deletions
diff --git a/quantum/rgb_matrix/animations/alpha_mods_anim.h b/quantum/rgb_matrix/animations/alpha_mods_anim.h
index 3f2c9b799..b8f507268 100644
--- a/quantum/rgb_matrix/animations/alpha_mods_anim.h
+++ b/quantum/rgb_matrix/animations/alpha_mods_anim.h
@@ -19,7 +19,7 @@ bool ALPHAS_MODS(effect_params_t* params) {
19 rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b); 19 rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b);
20 } 20 }
21 } 21 }
22 return led_max < DRIVER_LED_TOTAL; 22 return rgb_matrix_check_finished_leds(led_max);
23} 23}
24 24
25# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 25# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix/animations/breathing_anim.h b/quantum/rgb_matrix/animations/breathing_anim.h
index a00ccb83a..baac51ed1 100644
--- a/quantum/rgb_matrix/animations/breathing_anim.h
+++ b/quantum/rgb_matrix/animations/breathing_anim.h
@@ -13,7 +13,7 @@ bool BREATHING(effect_params_t* params) {
13 RGB_MATRIX_TEST_LED_FLAGS(); 13 RGB_MATRIX_TEST_LED_FLAGS();
14 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 14 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
15 } 15 }
16 return led_max < DRIVER_LED_TOTAL; 16 return rgb_matrix_check_finished_leds(led_max);
17} 17}
18 18
19# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 19# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix/animations/fractal_anim.h b/quantum/rgb_matrix/animations/fractal_anim.h
new file mode 100644
index 000000000..83a69daa6
--- /dev/null
+++ b/quantum/rgb_matrix/animations/fractal_anim.h
@@ -0,0 +1,74 @@
1/* Copyright (C) 2021 @filterpaper
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17// Inspired from 4x12 fractal created by @schwarzgrau
18
19#ifdef ENABLE_RGB_MATRIX_FRACTAL
20RGB_MATRIX_EFFECT(FRACTAL)
21# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
22
23static bool FRACTAL(effect_params_t* params) {
24# define MID_COL MATRIX_COLS / 2
25 static bool led[MATRIX_ROWS][MATRIX_COLS];
26
27 static uint32_t wait_timer = 0;
28 if (wait_timer > g_rgb_timer) {
29 return false;
30 }
31
32 inline uint32_t interval(void) { return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); }
33
34 RGB rgb = rgb_matrix_hsv_to_rgb(rgb_matrix_config.hsv);
35 for (uint8_t h = 0; h < MATRIX_ROWS; ++h) {
36 for (uint8_t l = 0; l < MID_COL - 1; ++l) { // Light and move left columns outwards
37 if (led[h][l]) {
38 rgb_matrix_set_color(g_led_config.matrix_co[h][l], rgb.r, rgb.g, rgb.b);
39 } else {
40 rgb_matrix_set_color(g_led_config.matrix_co[h][l], 0, 0, 0);
41 }
42 led[h][l] = led[h][l + 1];
43 }
44
45 for (uint8_t r = MATRIX_COLS - 1; r > MID_COL; --r) { // Light and move right columns outwards
46 if (led[h][r]) {
47 rgb_matrix_set_color(g_led_config.matrix_co[h][r], rgb.r, rgb.g, rgb.b);
48 } else {
49 rgb_matrix_set_color(g_led_config.matrix_co[h][r], 0, 0, 0);
50 }
51 led[h][r] = led[h][r - 1];
52 }
53
54 // Light both middle columns
55 if (led[h][MID_COL]) {
56 rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL], rgb.r, rgb.g, rgb.b);
57 } else {
58 rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL], 0, 0, 0);
59 }
60 if (led[h][MID_COL - 1]) {
61 rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL - 1], rgb.r, rgb.g, rgb.b);
62 } else {
63 rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL - 1], 0, 0, 0);
64 }
65
66 // Generate new random fractal columns
67 led[h][MID_COL] = led[h][MID_COL - 1] = (random8() & 3) ? false : true;
68 }
69
70 wait_timer = g_rgb_timer + interval();
71 return false;
72}
73# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
74#endif // ENABLE_RGB_MATRIX_FRACTAL
diff --git a/quantum/rgb_matrix/animations/gradient_left_right_anim.h b/quantum/rgb_matrix/animations/gradient_left_right_anim.h
index b4f2752ff..8b13d4e48 100644
--- a/quantum/rgb_matrix/animations/gradient_left_right_anim.h
+++ b/quantum/rgb_matrix/animations/gradient_left_right_anim.h
@@ -15,7 +15,7 @@ bool GRADIENT_LEFT_RIGHT(effect_params_t* params) {
15 RGB rgb = rgb_matrix_hsv_to_rgb(hsv); 15 RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
16 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 16 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
17 } 17 }
18 return led_max < DRIVER_LED_TOTAL; 18 return rgb_matrix_check_finished_leds(led_max);
19} 19}
20 20
21# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 21# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix/animations/gradient_up_down_anim.h b/quantum/rgb_matrix/animations/gradient_up_down_anim.h
index 3fd45cf99..7431ddcd9 100644
--- a/quantum/rgb_matrix/animations/gradient_up_down_anim.h
+++ b/quantum/rgb_matrix/animations/gradient_up_down_anim.h
@@ -15,7 +15,7 @@ bool GRADIENT_UP_DOWN(effect_params_t* params) {
15 RGB rgb = rgb_matrix_hsv_to_rgb(hsv); 15 RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
16 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 16 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
17 } 17 }
18 return led_max < DRIVER_LED_TOTAL; 18 return rgb_matrix_check_finished_leds(led_max);
19} 19}
20 20
21# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 21# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix/animations/hue_breathing_anim.h b/quantum/rgb_matrix/animations/hue_breathing_anim.h
index 6d974b8c3..82be1a442 100644
--- a/quantum/rgb_matrix/animations/hue_breathing_anim.h
+++ b/quantum/rgb_matrix/animations/hue_breathing_anim.h
@@ -15,7 +15,7 @@ bool HUE_BREATHING(effect_params_t* params) {
15 RGB_MATRIX_TEST_LED_FLAGS(); 15 RGB_MATRIX_TEST_LED_FLAGS();
16 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 16 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
17 } 17 }
18 return led_max < DRIVER_LED_TOTAL; 18 return rgb_matrix_check_finished_leds(led_max);
19} 19}
20 20
21# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 21# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h
index 7d8eafffb..d639ba9b6 100644
--- a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h
+++ b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h
@@ -22,7 +22,7 @@ bool JELLYBEAN_RAINDROPS(effect_params_t* params) {
22 for (int i = led_min; i < led_max; i++) { 22 for (int i = led_min; i < led_max; i++) {
23 jellybean_raindrops_set_color(i, params); 23 jellybean_raindrops_set_color(i, params);
24 } 24 }
25 return led_max < DRIVER_LED_TOTAL; 25 return rgb_matrix_check_finished_leds(led_max);
26} 26}
27 27
28# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 28# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix/animations/pixel_rain_anim.h b/quantum/rgb_matrix/animations/pixel_rain_anim.h
new file mode 100644
index 000000000..0209d3303
--- /dev/null
+++ b/quantum/rgb_matrix/animations/pixel_rain_anim.h
@@ -0,0 +1,44 @@
1/* Copyright (C) 2021 @filterpaper
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifdef ENABLE_RGB_MATRIX_PIXEL_RAIN
18RGB_MATRIX_EFFECT(PIXEL_RAIN)
19# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
20
21static bool PIXEL_RAIN(effect_params_t* params) {
22 static uint32_t wait_timer = 0;
23 if (wait_timer > g_rgb_timer) { return false; }
24
25 inline uint32_t interval(void) { return 500 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); }
26
27 bool rain_pixel(uint8_t i, effect_params_t* params, bool off) {
28 if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) { return true; }
29 if (off) {
30 rgb_matrix_set_color(i, 0,0,0);
31 } else {
32 HSV hsv = {random8(), qadd8(random8() >> 1, 127), rgb_matrix_config.hsv.v};
33 RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
34 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
35 }
36 wait_timer = g_rgb_timer + interval();
37 return false;
38 }
39
40 return rain_pixel(mod8(random8(), DRIVER_LED_TOTAL), params, random8() & 2);
41}
42
43# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
44#endif // ENABLE_RGB_MATRIX_PIXEL_RAIN
diff --git a/quantum/rgb_matrix/animations/raindrops_anim.h b/quantum/rgb_matrix/animations/raindrops_anim.h
index c01688e2c..fa61f9e0b 100644
--- a/quantum/rgb_matrix/animations/raindrops_anim.h
+++ b/quantum/rgb_matrix/animations/raindrops_anim.h
@@ -32,7 +32,7 @@ bool RAINDROPS(effect_params_t* params) {
32 for (int i = led_min; i < led_max; i++) { 32 for (int i = led_min; i < led_max; i++) {
33 raindrops_set_color(i, params); 33 raindrops_set_color(i, params);
34 } 34 }
35 return led_max < DRIVER_LED_TOTAL; 35 return rgb_matrix_check_finished_leds(led_max);
36} 36}
37 37
38# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 38# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc
index 302ad79c0..8ecf4367f 100644
--- a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc
+++ b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc
@@ -26,6 +26,8 @@
26#include "hue_breathing_anim.h" 26#include "hue_breathing_anim.h"
27#include "hue_pendulum_anim.h" 27#include "hue_pendulum_anim.h"
28#include "hue_wave_anim.h" 28#include "hue_wave_anim.h"
29#include "fractal_anim.h"
30#include "pixel_rain_anim.h"
29#include "typing_heatmap_anim.h" 31#include "typing_heatmap_anim.h"
30#include "digital_rain_anim.h" 32#include "digital_rain_anim.h"
31#include "solid_reactive_simple_anim.h" 33#include "solid_reactive_simple_anim.h"
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy.h b/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy.h
index 4867609c8..2ad0f22c2 100644
--- a/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy.h
+++ b/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy.h
@@ -13,5 +13,5 @@ bool effect_runner_dx_dy(effect_params_t* params, dx_dy_f effect_func) {
13 RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, time)); 13 RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, time));
14 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 14 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
15 } 15 }
16 return led_max < DRIVER_LED_TOTAL; 16 return rgb_matrix_check_finished_leds(led_max);
17} 17}
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy_dist.h b/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy_dist.h
index 9545b418d..bcae7c79b 100644
--- a/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy_dist.h
+++ b/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy_dist.h
@@ -14,5 +14,5 @@ bool effect_runner_dx_dy_dist(effect_params_t* params, dx_dy_dist_f effect_func)
14 RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, dist, time)); 14 RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, dist, time));
15 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 15 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
16 } 16 }
17 return led_max < DRIVER_LED_TOTAL; 17 return rgb_matrix_check_finished_leds(led_max);
18} 18}
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_i.h b/quantum/rgb_matrix/animations/runners/effect_runner_i.h
index 1881cd6c6..b4de2992b 100644
--- a/quantum/rgb_matrix/animations/runners/effect_runner_i.h
+++ b/quantum/rgb_matrix/animations/runners/effect_runner_i.h
@@ -11,5 +11,5 @@ bool effect_runner_i(effect_params_t* params, i_f effect_func) {
11 RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time)); 11 RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
12 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 12 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
13 } 13 }
14 return led_max < DRIVER_LED_TOTAL; 14 return rgb_matrix_check_finished_leds(led_max);
15} 15}
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h b/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h
index 75b7c0df4..d5c1a26ce 100644
--- a/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h
+++ b/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h
@@ -23,7 +23,7 @@ bool effect_runner_reactive(effect_params_t* params, reactive_f effect_func) {
23 RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, offset)); 23 RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, offset));
24 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 24 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
25 } 25 }
26 return led_max < DRIVER_LED_TOTAL; 26 return rgb_matrix_check_finished_leds(led_max);
27} 27}
28 28
29#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 29#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h b/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h
index 2e46ffb35..d3a6e4e72 100644
--- a/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h
+++ b/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h
@@ -23,7 +23,7 @@ bool effect_runner_reactive_splash(uint8_t start, effect_params_t* params, react
23 RGB rgb = rgb_matrix_hsv_to_rgb(hsv); 23 RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
24 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 24 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
25 } 25 }
26 return led_max < DRIVER_LED_TOTAL; 26 return rgb_matrix_check_finished_leds(led_max);
27} 27}
28 28
29#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 29#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_sin_cos_i.h b/quantum/rgb_matrix/animations/runners/effect_runner_sin_cos_i.h
index 02351de51..7776491d5 100644
--- a/quantum/rgb_matrix/animations/runners/effect_runner_sin_cos_i.h
+++ b/quantum/rgb_matrix/animations/runners/effect_runner_sin_cos_i.h
@@ -13,5 +13,5 @@ bool effect_runner_sin_cos_i(effect_params_t* params, sin_cos_i_f effect_func) {
13 RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, cos_value, sin_value, i, time)); 13 RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, cos_value, sin_value, i, time));
14 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 14 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
15 } 15 }
16 return led_max < DRIVER_LED_TOTAL; 16 return rgb_matrix_check_finished_leds(led_max);
17} 17}
diff --git a/quantum/rgb_matrix/animations/solid_color_anim.h b/quantum/rgb_matrix/animations/solid_color_anim.h
index 79d63cf13..420995946 100644
--- a/quantum/rgb_matrix/animations/solid_color_anim.h
+++ b/quantum/rgb_matrix/animations/solid_color_anim.h
@@ -9,7 +9,7 @@ bool SOLID_COLOR(effect_params_t* params) {
9 RGB_MATRIX_TEST_LED_FLAGS(); 9 RGB_MATRIX_TEST_LED_FLAGS();
10 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); 10 rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
11 } 11 }
12 return led_max < DRIVER_LED_TOTAL; 12 return rgb_matrix_check_finished_leds(led_max);
13} 13}
14 14
15#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 15#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c
index 8f00b4087..558c7bd41 100644
--- a/quantum/rgb_matrix/rgb_matrix.c
+++ b/quantum/rgb_matrix/rgb_matrix.c
@@ -31,14 +31,6 @@ const led_point_t k_rgb_matrix_center = {112, 32};
31const led_point_t k_rgb_matrix_center = RGB_MATRIX_CENTER; 31const led_point_t k_rgb_matrix_center = RGB_MATRIX_CENTER;
32#endif 32#endif
33 33
34// clang-format off
35#ifndef RGB_MATRIX_IMMEDIATE_EEPROM
36# define rgb_eeconfig_update(v) rgb_update_eeprom |= v
37#else
38# define rgb_eeconfig_update(v) if (v) eeconfig_update_rgb_matrix()
39#endif
40// clang-format on
41
42__attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv); } 34__attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv); }
43 35
44// Generic effect runners 36// Generic effect runners
@@ -128,7 +120,6 @@ last_hit_t g_last_hit_tracker;
128 120
129// internals 121// internals
130static bool suspend_state = false; 122static bool suspend_state = false;
131static bool rgb_update_eeprom = false;
132static uint8_t rgb_last_enable = UINT8_MAX; 123static uint8_t rgb_last_enable = UINT8_MAX;
133static uint8_t rgb_last_effect = UINT8_MAX; 124static uint8_t rgb_last_effect = UINT8_MAX;
134static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false}; 125static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false};
@@ -148,9 +139,9 @@ static last_hit_t last_hit_buffer;
148const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; 139const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT;
149#endif 140#endif
150 141
151void eeconfig_read_rgb_matrix(void) { eeprom_read_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); } 142EECONFIG_DEBOUNCE_HELPER(rgb_matrix, EECONFIG_RGB_MATRIX, rgb_matrix_config);
152 143
153void eeconfig_update_rgb_matrix(void) { eeprom_update_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); } 144void eeconfig_update_rgb_matrix(void) { eeconfig_flush_rgb_matrix(true); }
154 145
155void eeconfig_update_rgb_matrix_default(void) { 146void eeconfig_update_rgb_matrix_default(void) {
156 dprintf("eeconfig_update_rgb_matrix_default\n"); 147 dprintf("eeconfig_update_rgb_matrix_default\n");
@@ -159,7 +150,7 @@ void eeconfig_update_rgb_matrix_default(void) {
159 rgb_matrix_config.hsv = (HSV){RGB_MATRIX_STARTUP_HUE, RGB_MATRIX_STARTUP_SAT, RGB_MATRIX_STARTUP_VAL}; 150 rgb_matrix_config.hsv = (HSV){RGB_MATRIX_STARTUP_HUE, RGB_MATRIX_STARTUP_SAT, RGB_MATRIX_STARTUP_VAL};
160 rgb_matrix_config.speed = RGB_MATRIX_STARTUP_SPD; 151 rgb_matrix_config.speed = RGB_MATRIX_STARTUP_SPD;
161 rgb_matrix_config.flags = LED_FLAG_ALL; 152 rgb_matrix_config.flags = LED_FLAG_ALL;
162 eeconfig_update_rgb_matrix(); 153 eeconfig_flush_rgb_matrix(true);
163} 154}
164 155
165void eeconfig_debug_rgb_matrix(void) { 156void eeconfig_debug_rgb_matrix(void) {
@@ -187,14 +178,7 @@ uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *l
187 178
188void rgb_matrix_update_pwm_buffers(void) { rgb_matrix_driver.flush(); } 179void rgb_matrix_update_pwm_buffers(void) { rgb_matrix_driver.flush(); }
189 180
190void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { 181void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color(index, red, green, blue); }
191#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
192 if (!is_keyboard_left() && index >= k_rgb_matrix_split[0])
193 rgb_matrix_driver.set_color(index - k_rgb_matrix_split[0], red, green, blue);
194 else if (is_keyboard_left() && index < k_rgb_matrix_split[0])
195#endif
196 rgb_matrix_driver.set_color(index, red, green, blue);
197}
198 182
199void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { 183void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
200#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) 184#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
@@ -314,9 +298,8 @@ static void rgb_task_timers(void) {
314} 298}
315 299
316static void rgb_task_sync(void) { 300static void rgb_task_sync(void) {
301 eeconfig_flush_rgb_matrix(false);
317 // next task 302 // next task
318 if (rgb_update_eeprom) eeconfig_update_rgb_matrix();
319 rgb_update_eeprom = false;
320 if (sync_timer_elapsed32(g_rgb_timer) >= RGB_MATRIX_LED_FLUSH_LIMIT) rgb_task_state = STARTING; 303 if (sync_timer_elapsed32(g_rgb_timer) >= RGB_MATRIX_LED_FLUSH_LIMIT) rgb_task_state = STARTING;
321} 304}
322 305
@@ -491,7 +474,7 @@ void rgb_matrix_init(void) {
491 eeconfig_update_rgb_matrix_default(); 474 eeconfig_update_rgb_matrix_default();
492 } 475 }
493 476
494 eeconfig_read_rgb_matrix(); 477 eeconfig_init_rgb_matrix();
495 if (!rgb_matrix_config.mode) { 478 if (!rgb_matrix_config.mode) {
496 dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n"); 479 dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n");
497 eeconfig_update_rgb_matrix_default(); 480 eeconfig_update_rgb_matrix_default();
@@ -514,7 +497,7 @@ bool rgb_matrix_get_suspend_state(void) { return suspend_state; }
514void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) { 497void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) {
515 rgb_matrix_config.enable ^= 1; 498 rgb_matrix_config.enable ^= 1;
516 rgb_task_state = STARTING; 499 rgb_task_state = STARTING;
517 rgb_eeconfig_update(write_to_eeprom); 500 eeconfig_flag_rgb_matrix(write_to_eeprom);
518 dprintf("rgb matrix toggle [%s]: rgb_matrix_config.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.enable); 501 dprintf("rgb matrix toggle [%s]: rgb_matrix_config.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.enable);
519} 502}
520void rgb_matrix_toggle_noeeprom(void) { rgb_matrix_toggle_eeprom_helper(false); } 503void rgb_matrix_toggle_noeeprom(void) { rgb_matrix_toggle_eeprom_helper(false); }
@@ -522,7 +505,7 @@ void rgb_matrix_toggle(void) { rgb_matrix_toggle_eeprom_helper(true); }
522 505
523void rgb_matrix_enable(void) { 506void rgb_matrix_enable(void) {
524 rgb_matrix_enable_noeeprom(); 507 rgb_matrix_enable_noeeprom();
525 rgb_eeconfig_update(true); 508 eeconfig_flag_rgb_matrix(true);
526} 509}
527 510
528void rgb_matrix_enable_noeeprom(void) { 511void rgb_matrix_enable_noeeprom(void) {
@@ -532,7 +515,7 @@ void rgb_matrix_enable_noeeprom(void) {
532 515
533void rgb_matrix_disable(void) { 516void rgb_matrix_disable(void) {
534 rgb_matrix_disable_noeeprom(); 517 rgb_matrix_disable_noeeprom();
535 rgb_eeconfig_update(true); 518 eeconfig_flag_rgb_matrix(true);
536} 519}
537 520
538void rgb_matrix_disable_noeeprom(void) { 521void rgb_matrix_disable_noeeprom(void) {
@@ -554,7 +537,7 @@ void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
554 rgb_matrix_config.mode = mode; 537 rgb_matrix_config.mode = mode;
555 } 538 }
556 rgb_task_state = STARTING; 539 rgb_task_state = STARTING;
557 rgb_eeconfig_update(write_to_eeprom); 540 eeconfig_flag_rgb_matrix(write_to_eeprom);
558 dprintf("rgb matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.mode); 541 dprintf("rgb matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.mode);
559} 542}
560void rgb_matrix_mode_noeeprom(uint8_t mode) { rgb_matrix_mode_eeprom_helper(mode, false); } 543void rgb_matrix_mode_noeeprom(uint8_t mode) { rgb_matrix_mode_eeprom_helper(mode, false); }
@@ -583,7 +566,7 @@ void rgb_matrix_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, boo
583 rgb_matrix_config.hsv.h = hue; 566 rgb_matrix_config.hsv.h = hue;
584 rgb_matrix_config.hsv.s = sat; 567 rgb_matrix_config.hsv.s = sat;
585 rgb_matrix_config.hsv.v = (val > RGB_MATRIX_MAXIMUM_BRIGHTNESS) ? RGB_MATRIX_MAXIMUM_BRIGHTNESS : val; 568 rgb_matrix_config.hsv.v = (val > RGB_MATRIX_MAXIMUM_BRIGHTNESS) ? RGB_MATRIX_MAXIMUM_BRIGHTNESS : val;
586 rgb_eeconfig_update(write_to_eeprom); 569 eeconfig_flag_rgb_matrix(write_to_eeprom);
587 dprintf("rgb matrix set hsv [%s]: %u,%u,%u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); 570 dprintf("rgb matrix set hsv [%s]: %u,%u,%u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v);
588} 571}
589void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { rgb_matrix_sethsv_eeprom_helper(hue, sat, val, false); } 572void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { rgb_matrix_sethsv_eeprom_helper(hue, sat, val, false); }
@@ -620,7 +603,7 @@ void rgb_matrix_decrease_val(void) { rgb_matrix_decrease_val_helper(true); }
620 603
621void rgb_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { 604void rgb_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) {
622 rgb_matrix_config.speed = speed; 605 rgb_matrix_config.speed = speed;
623 rgb_eeconfig_update(write_to_eeprom); 606 eeconfig_flag_rgb_matrix(write_to_eeprom);
624 dprintf("rgb matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.speed); 607 dprintf("rgb matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.speed);
625} 608}
626void rgb_matrix_set_speed_noeeprom(uint8_t speed) { rgb_matrix_set_speed_eeprom_helper(speed, false); } 609void rgb_matrix_set_speed_noeeprom(uint8_t speed) { rgb_matrix_set_speed_eeprom_helper(speed, false); }
diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h
index f53e011c1..af5ca9e79 100644
--- a/quantum/rgb_matrix/rgb_matrix.h
+++ b/quantum/rgb_matrix/rgb_matrix.h
@@ -33,6 +33,8 @@
33# include "is31fl3737.h" 33# include "is31fl3737.h"
34#elif defined(IS31FL3741) 34#elif defined(IS31FL3741)
35# include "is31fl3741.h" 35# include "is31fl3741.h"
36#elif defined(CKLED2001)
37# include "ckled2001.h"
36#elif defined(AW20216) 38#elif defined(AW20216)
37# include "aw20216.h" 39# include "aw20216.h"
38#elif defined(WS2812) 40#elif defined(WS2812)
@@ -48,14 +50,33 @@
48#endif 50#endif
49 51
50#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL 52#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL
51# define RGB_MATRIX_USE_LIMITS(min, max) \ 53# if defined(RGB_MATRIX_SPLIT)
52 uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \ 54# define RGB_MATRIX_USE_LIMITS(min, max) \
53 uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \ 55 uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \
54 if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL; 56 uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
57 if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL; \
58 uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \
59 if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \
60 if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0];
61# else
62# define RGB_MATRIX_USE_LIMITS(min, max) \
63 uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \
64 uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
65 if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL;
66# endif
55#else 67#else
56# define RGB_MATRIX_USE_LIMITS(min, max) \ 68# if defined(RGB_MATRIX_SPLIT)
57 uint8_t min = 0; \ 69# define RGB_MATRIX_USE_LIMITS(min, max) \
58 uint8_t max = DRIVER_LED_TOTAL; 70 uint8_t min = 0; \
71 uint8_t max = DRIVER_LED_TOTAL; \
72 const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \
73 if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \
74 if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0];
75# else
76# define RGB_MATRIX_USE_LIMITS(min, max) \
77 uint8_t min = 0; \
78 uint8_t max = DRIVER_LED_TOTAL;
79# endif
59#endif 80#endif
60 81
61#define RGB_MATRIX_INDICATOR_SET_COLOR(i, r, g, b) \ 82#define RGB_MATRIX_INDICATOR_SET_COLOR(i, r, g, b) \
@@ -214,6 +235,18 @@ typedef struct {
214 void (*flush)(void); 235 void (*flush)(void);
215} rgb_matrix_driver_t; 236} rgb_matrix_driver_t;
216 237
238static inline bool rgb_matrix_check_finished_leds(uint8_t led_idx) {
239#if defined(RGB_MATRIX_SPLIT)
240 if (is_keyboard_left()) {
241 uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT;
242 return led_idx < k_rgb_matrix_split[0];
243 } else
244 return led_idx < DRIVER_LED_TOTAL;
245#else
246 return led_idx < DRIVER_LED_TOTAL;
247#endif
248}
249
217extern const rgb_matrix_driver_t rgb_matrix_driver; 250extern const rgb_matrix_driver_t rgb_matrix_driver;
218 251
219extern rgb_config_t rgb_matrix_config; 252extern rgb_config_t rgb_matrix_config;
diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c
index 2cec162e2..130ca47a6 100644
--- a/quantum/rgb_matrix/rgb_matrix_drivers.c
+++ b/quantum/rgb_matrix/rgb_matrix_drivers.c
@@ -23,111 +23,153 @@
23 * be here if shared between boards. 23 * be here if shared between boards.
24 */ 24 */
25 25
26#if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FL3737) || defined(IS31FL3741) 26#if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FL3737) || defined(IS31FL3741) || defined(CKLED2001)
27
28# include "i2c_master.h" 27# include "i2c_master.h"
29 28
29// TODO: Remove this at some later date
30# if defined(DRIVER_ADDR_1) && defined(DRIVER_ADDR_2)
31# if DRIVER_ADDR_1 == DRIVER_ADDR_2
32# error "Setting DRIVER_ADDR_2 == DRIVER_ADDR_1 is obsolete. If you are only using one ISSI driver, set DRIVER_COUNT to 1 and remove DRIVER_ADDR_2"
33# endif
34# endif
35
30static void init(void) { 36static void init(void) {
31 i2c_init(); 37 i2c_init();
32# ifdef IS31FL3731 38
39# if defined(IS31FL3731)
33 IS31FL3731_init(DRIVER_ADDR_1); 40 IS31FL3731_init(DRIVER_ADDR_1);
34# ifdef DRIVER_ADDR_2 41# if defined(DRIVER_ADDR_2)
35 IS31FL3731_init(DRIVER_ADDR_2); 42 IS31FL3731_init(DRIVER_ADDR_2);
36# endif 43# if defined(DRIVER_ADDR_3)
37# ifdef DRIVER_ADDR_3
38 IS31FL3731_init(DRIVER_ADDR_3); 44 IS31FL3731_init(DRIVER_ADDR_3);
39# endif 45# if defined(DRIVER_ADDR_4)
40# ifdef DRIVER_ADDR_4
41 IS31FL3731_init(DRIVER_ADDR_4); 46 IS31FL3731_init(DRIVER_ADDR_4);
47# endif
48# endif
42# endif 49# endif
50
43# elif defined(IS31FL3733) 51# elif defined(IS31FL3733)
44# ifndef DRIVER_SYNC_1 52# if !defined(DRIVER_SYNC_1)
45# define DRIVER_SYNC_1 0 53# define DRIVER_SYNC_1 0
46# endif 54# endif
47 IS31FL3733_init(DRIVER_ADDR_1, DRIVER_SYNC_1); 55 IS31FL3733_init(DRIVER_ADDR_1, DRIVER_SYNC_1);
48# if defined DRIVER_ADDR_2 && (DRIVER_ADDR_1 != DRIVER_ADDR_2) 56# if defined(DRIVER_ADDR_2)
49# ifndef DRIVER_SYNC_2 57# if !defined(DRIVER_SYNC_2)
50# define DRIVER_SYNC_2 0 58# define DRIVER_SYNC_2 0
51# endif 59# endif
52 IS31FL3733_init(DRIVER_ADDR_2, DRIVER_SYNC_2); 60 IS31FL3733_init(DRIVER_ADDR_2, DRIVER_SYNC_2);
53# endif 61# if defined(DRIVER_ADDR_3)
54# ifdef DRIVER_ADDR_3 62# if !defined(DRIVER_SYNC_3)
55# ifndef DRIVER_SYNC_3 63# define DRIVER_SYNC_3 0
56# define DRIVER_SYNC_3 0 64# endif
57# endif
58 IS31FL3733_init(DRIVER_ADDR_3, DRIVER_SYNC_3); 65 IS31FL3733_init(DRIVER_ADDR_3, DRIVER_SYNC_3);
59# endif 66# if defined(DRIVER_ADDR_4)
60# ifdef DRIVER_ADDR_4 67# if !defined(DRIVER_SYNC_4)
61# ifndef DRIVER_SYNC_4 68# define DRIVER_SYNC_4 0
62# define DRIVER_SYNC_4 0 69# endif
63# endif
64 IS31FL3733_init(DRIVER_ADDR_4, DRIVER_SYNC_4); 70 IS31FL3733_init(DRIVER_ADDR_4, DRIVER_SYNC_4);
71# endif
72# endif
65# endif 73# endif
74
66# elif defined(IS31FL3737) 75# elif defined(IS31FL3737)
67 IS31FL3737_init(DRIVER_ADDR_1); 76 IS31FL3737_init(DRIVER_ADDR_1);
68# if defined(DRIVER_ADDR_2) && (DRIVER_ADDR_2 != DRIVER_ADDR_1) // provides backward compatibility 77# if defined(DRIVER_ADDR_2)
69 IS31FL3737_init(DRIVER_ADDR_2); 78 IS31FL3737_init(DRIVER_ADDR_2);
70# endif 79# endif
71# else 80
81# elif defined(IS31FL3741)
72 IS31FL3741_init(DRIVER_ADDR_1); 82 IS31FL3741_init(DRIVER_ADDR_1);
83
84# elif defined(CKLED2001)
85 CKLED2001_init(DRIVER_ADDR_1);
86# if defined(DRIVER_ADDR_2)
87 CKLED2001_init(DRIVER_ADDR_2);
88# if defined(DRIVER_ADDR_3)
89 CKLED2001_init(DRIVER_ADDR_3);
90# if defined(DRIVER_ADDR_4)
91 CKLED2001_init(DRIVER_ADDR_4);
92# endif
93# endif
94# endif
73# endif 95# endif
96
74 for (int index = 0; index < DRIVER_LED_TOTAL; index++) { 97 for (int index = 0; index < DRIVER_LED_TOTAL; index++) {
75 bool enabled = true; 98 bool enabled = true;
99
76 // This only caches it for later 100 // This only caches it for later
77# ifdef IS31FL3731 101# if defined(IS31FL3731)
78 IS31FL3731_set_led_control_register(index, enabled, enabled, enabled); 102 IS31FL3731_set_led_control_register(index, enabled, enabled, enabled);
79# elif defined(IS31FL3733) 103# elif defined(IS31FL3733)
80 IS31FL3733_set_led_control_register(index, enabled, enabled, enabled); 104 IS31FL3733_set_led_control_register(index, enabled, enabled, enabled);
81# elif defined(IS31FL3737) 105# elif defined(IS31FL3737)
82 IS31FL3737_set_led_control_register(index, enabled, enabled, enabled); 106 IS31FL3737_set_led_control_register(index, enabled, enabled, enabled);
83# else 107# elif defined(IS31FL3741)
84 IS31FL3741_set_led_control_register(index, enabled, enabled, enabled); 108 IS31FL3741_set_led_control_register(index, enabled, enabled, enabled);
109# elif defined(CKLED2001)
110 CKLED2001_set_led_control_register(index, enabled, enabled, enabled);
85# endif 111# endif
86 } 112 }
113
87 // This actually updates the LED drivers 114 // This actually updates the LED drivers
88# ifdef IS31FL3731 115# if defined(IS31FL3731)
89 IS31FL3731_update_led_control_registers(DRIVER_ADDR_1, 0); 116 IS31FL3731_update_led_control_registers(DRIVER_ADDR_1, 0);
90# ifdef DRIVER_ADDR_2 117# if defined(DRIVER_ADDR_2)
91 IS31FL3731_update_led_control_registers(DRIVER_ADDR_2, 1); 118 IS31FL3731_update_led_control_registers(DRIVER_ADDR_2, 1);
92# endif 119# if defined(DRIVER_ADDR_3)
93# ifdef DRIVER_ADDR_3
94 IS31FL3731_update_led_control_registers(DRIVER_ADDR_3, 2); 120 IS31FL3731_update_led_control_registers(DRIVER_ADDR_3, 2);
95# endif 121# if defined(DRIVER_ADDR_4)
96# ifdef DRIVER_ADDR_4
97 IS31FL3731_update_led_control_registers(DRIVER_ADDR_4, 3); 122 IS31FL3731_update_led_control_registers(DRIVER_ADDR_4, 3);
123# endif
124# endif
98# endif 125# endif
126
99# elif defined(IS31FL3733) 127# elif defined(IS31FL3733)
100 IS31FL3733_update_led_control_registers(DRIVER_ADDR_1, 0); 128 IS31FL3733_update_led_control_registers(DRIVER_ADDR_1, 0);
101# ifdef DRIVER_ADDR_2 129# if defined(DRIVER_ADDR_2)
102 IS31FL3733_update_led_control_registers(DRIVER_ADDR_2, 1); 130 IS31FL3733_update_led_control_registers(DRIVER_ADDR_2, 1);
103# endif 131# if defined(DRIVER_ADDR_3)
104# ifdef DRIVER_ADDR_3
105 IS31FL3733_update_led_control_registers(DRIVER_ADDR_3, 2); 132 IS31FL3733_update_led_control_registers(DRIVER_ADDR_3, 2);
106# endif 133# if defined(DRIVER_ADDR_4)
107# ifdef DRIVER_ADDR_4
108 IS31FL3733_update_led_control_registers(DRIVER_ADDR_4, 3); 134 IS31FL3733_update_led_control_registers(DRIVER_ADDR_4, 3);
135# endif
136# endif
109# endif 137# endif
138
110# elif defined(IS31FL3737) 139# elif defined(IS31FL3737)
111 IS31FL3737_update_led_control_registers(DRIVER_ADDR_1, 0); 140 IS31FL3737_update_led_control_registers(DRIVER_ADDR_1, 0);
112# if defined(DRIVER_ADDR_2) && (DRIVER_ADDR_2 != DRIVER_ADDR_1) // provides backward compatibility 141# if defined(DRIVER_ADDR_2)
113 IS31FL3737_update_led_control_registers(DRIVER_ADDR_2, 1); 142 IS31FL3737_update_led_control_registers(DRIVER_ADDR_2, 1);
114# endif 143# endif
115# else 144
145# elif defined(IS31FL3741)
116 IS31FL3741_update_led_control_registers(DRIVER_ADDR_1, 0); 146 IS31FL3741_update_led_control_registers(DRIVER_ADDR_1, 0);
147
148# elif defined(CKLED2001)
149 CKLED2001_update_led_control_registers(DRIVER_ADDR_1, 0);
150# if defined(DRIVER_ADDR_2)
151 CKLED2001_update_led_control_registers(DRIVER_ADDR_2, 1);
152# if defined(DRIVER_ADDR_3)
153 CKLED2001_update_led_control_registers(DRIVER_ADDR_3, 2);
154# if defined(DRIVER_ADDR_4)
155 CKLED2001_update_led_control_registers(DRIVER_ADDR_4, 3);
156# endif
157# endif
158# endif
117# endif 159# endif
118} 160}
119 161
120# ifdef IS31FL3731 162# if defined(IS31FL3731)
121static void flush(void) { 163static void flush(void) {
122 IS31FL3731_update_pwm_buffers(DRIVER_ADDR_1, 0); 164 IS31FL3731_update_pwm_buffers(DRIVER_ADDR_1, 0);
123# ifdef DRIVER_ADDR_2 165# if defined(DRIVER_ADDR_2)
124 IS31FL3731_update_pwm_buffers(DRIVER_ADDR_2, 1); 166 IS31FL3731_update_pwm_buffers(DRIVER_ADDR_2, 1);
125# endif 167# if defined(DRIVER_ADDR_3)
126# ifdef DRIVER_ADDR_3
127 IS31FL3731_update_pwm_buffers(DRIVER_ADDR_3, 2); 168 IS31FL3731_update_pwm_buffers(DRIVER_ADDR_3, 2);
128# endif 169# if defined(DRIVER_ADDR_4)
129# ifdef DRIVER_ADDR_4
130 IS31FL3731_update_pwm_buffers(DRIVER_ADDR_4, 3); 170 IS31FL3731_update_pwm_buffers(DRIVER_ADDR_4, 3);
171# endif
172# endif
131# endif 173# endif
132} 174}
133 175
@@ -137,17 +179,18 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
137 .set_color = IS31FL3731_set_color, 179 .set_color = IS31FL3731_set_color,
138 .set_color_all = IS31FL3731_set_color_all, 180 .set_color_all = IS31FL3731_set_color_all,
139}; 181};
182
140# elif defined(IS31FL3733) 183# elif defined(IS31FL3733)
141static void flush(void) { 184static void flush(void) {
142 IS31FL3733_update_pwm_buffers(DRIVER_ADDR_1, 0); 185 IS31FL3733_update_pwm_buffers(DRIVER_ADDR_1, 0);
143# ifdef DRIVER_ADDR_2 186# if defined(DRIVER_ADDR_2)
144 IS31FL3733_update_pwm_buffers(DRIVER_ADDR_2, 1); 187 IS31FL3733_update_pwm_buffers(DRIVER_ADDR_2, 1);
145# endif 188# if defined(DRIVER_ADDR_3)
146# ifdef DRIVER_ADDR_3
147 IS31FL3733_update_pwm_buffers(DRIVER_ADDR_3, 2); 189 IS31FL3733_update_pwm_buffers(DRIVER_ADDR_3, 2);
148# endif 190# if defined(DRIVER_ADDR_4)
149# ifdef DRIVER_ADDR_4
150 IS31FL3733_update_pwm_buffers(DRIVER_ADDR_4, 3); 191 IS31FL3733_update_pwm_buffers(DRIVER_ADDR_4, 3);
192# endif
193# endif
151# endif 194# endif
152} 195}
153 196
@@ -157,10 +200,11 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
157 .set_color = IS31FL3733_set_color, 200 .set_color = IS31FL3733_set_color,
158 .set_color_all = IS31FL3733_set_color_all, 201 .set_color_all = IS31FL3733_set_color_all,
159}; 202};
203
160# elif defined(IS31FL3737) 204# elif defined(IS31FL3737)
161static void flush(void) { 205static void flush(void) {
162 IS31FL3737_update_pwm_buffers(DRIVER_ADDR_1, 0); 206 IS31FL3737_update_pwm_buffers(DRIVER_ADDR_1, 0);
163# if defined(DRIVER_ADDR_2) && (DRIVER_ADDR_2 != DRIVER_ADDR_1) // provides backward compatibility 207# if defined(DRIVER_ADDR_2)
164 IS31FL3737_update_pwm_buffers(DRIVER_ADDR_2, 1); 208 IS31FL3737_update_pwm_buffers(DRIVER_ADDR_2, 1);
165# endif 209# endif
166} 210}
@@ -171,10 +215,11 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
171 .set_color = IS31FL3737_set_color, 215 .set_color = IS31FL3737_set_color,
172 .set_color_all = IS31FL3737_set_color_all, 216 .set_color_all = IS31FL3737_set_color_all,
173}; 217};
174# else 218
219# elif defined(IS31FL3741)
175static void flush(void) { 220static void flush(void) {
176 IS31FL3741_update_pwm_buffers(DRIVER_ADDR_1, 0); 221 IS31FL3741_update_pwm_buffers(DRIVER_ADDR_1, 0);
177# if defined(DRIVER_ADDR_2) && (DRIVER_ADDR_2 != DRIVER_ADDR_1) // provides backward compatibility 222# if defined(DRIVER_ADDR_2)
178 IS31FL3741_update_pwm_buffers(DRIVER_ADDR_2, 1); 223 IS31FL3741_update_pwm_buffers(DRIVER_ADDR_2, 1);
179# endif 224# endif
180} 225}
@@ -185,21 +230,44 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
185 .set_color = IS31FL3741_set_color, 230 .set_color = IS31FL3741_set_color,
186 .set_color_all = IS31FL3741_set_color_all, 231 .set_color_all = IS31FL3741_set_color_all,
187}; 232};
233
234# elif defined(CKLED2001)
235static void flush(void) {
236 CKLED2001_update_pwm_buffers(DRIVER_ADDR_1, 0);
237# if defined(DRIVER_ADDR_2)
238 CKLED2001_update_pwm_buffers(DRIVER_ADDR_2, 1);
239# if defined(DRIVER_ADDR_3)
240 CKLED2001_update_pwm_buffers(DRIVER_ADDR_3, 2);
241# if defined(DRIVER_ADDR_4)
242 CKLED2001_update_pwm_buffers(DRIVER_ADDR_4, 3);
243# endif
244# endif
245# endif
246}
247
248const rgb_matrix_driver_t rgb_matrix_driver = {
249 .init = init,
250 .flush = flush,
251 .set_color = CKLED2001_set_color,
252 .set_color_all = CKLED2001_set_color_all,
253};
188# endif 254# endif
189 255
190#elif defined(AW20216) 256#elif defined(AW20216)
191# include "spi_master.h" 257# include "spi_master.h"
258
192static void init(void) { 259static void init(void) {
193 spi_init(); 260 spi_init();
261
194 AW20216_init(DRIVER_1_CS, DRIVER_1_EN); 262 AW20216_init(DRIVER_1_CS, DRIVER_1_EN);
195# ifdef DRIVER_2_CS 263# if defined(DRIVER_2_CS)
196 AW20216_init(DRIVER_2_CS, DRIVER_2_EN); 264 AW20216_init(DRIVER_2_CS, DRIVER_2_EN);
197# endif 265# endif
198} 266}
199 267
200static void flush(void) { 268static void flush(void) {
201 AW20216_update_pwm_buffers(DRIVER_1_CS, 0); 269 AW20216_update_pwm_buffers(DRIVER_1_CS, 0);
202# ifdef DRIVER_2_CS 270# if defined(DRIVER_2_CS)
203 AW20216_update_pwm_buffers(DRIVER_2_CS, 1); 271 AW20216_update_pwm_buffers(DRIVER_2_CS, 1);
204# endif 272# endif
205} 273}
@@ -229,6 +297,14 @@ static void flush(void) {
229 297
230// Set an led in the buffer to a color 298// Set an led in the buffer to a color
231static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) { 299static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) {
300# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
301 const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT;
302 if (!is_keyboard_left() && (i >= k_rgb_matrix_split[0])) {
303 i -= k_rgb_matrix_split[0];
304 } else if (is_keyboard_left() && (i >= k_rgb_matrix_split[0]))
305 return;
306# endif
307
232 rgb_matrix_ws2812_array[i].r = r; 308 rgb_matrix_ws2812_array[i].r = r;
233 rgb_matrix_ws2812_array[i].g = g; 309 rgb_matrix_ws2812_array[i].g = g;
234 rgb_matrix_ws2812_array[i].b = b; 310 rgb_matrix_ws2812_array[i].b = b;