diff options
Diffstat (limited to 'quantum')
22 files changed, 53 insertions, 71 deletions
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 5528a0834..edbcee9cd 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
@@ -105,6 +105,7 @@ | |||
105 | 105 | ||
106 | bool g_suspend_state = false; | 106 | bool g_suspend_state = false; |
107 | 107 | ||
108 | extern led_config_t g_led_config; | ||
108 | rgb_config_t rgb_matrix_config; | 109 | rgb_config_t rgb_matrix_config; |
109 | 110 | ||
110 | rgb_counters_t g_rgb_counters; | 111 | rgb_counters_t g_rgb_counters; |
@@ -150,14 +151,11 @@ uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t | |||
150 | } | 151 | } |
151 | 152 | ||
152 | uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { | 153 | uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { |
153 | // TODO: This is kinda expensive, fix this soonish | ||
154 | uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i); | 154 | uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i); |
155 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL && led_count < LED_HITS_TO_REMEMBER; i++) { | 155 | uint8_t led_index = g_led_config.matrix_co[row][column]; |
156 | matrix_co_t matrix_co = g_rgb_leds[i].matrix_co; | 156 | if (led_index != NO_LED) { |
157 | if (row == matrix_co.row && column == matrix_co.col) { | 157 | led_i[led_count] = led_index; |
158 | led_i[led_count] = i; | 158 | led_count++; |
159 | led_count++; | ||
160 | } | ||
161 | } | 159 | } |
162 | return led_count; | 160 | return led_count; |
163 | } | 161 | } |
@@ -201,8 +199,8 @@ bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { | |||
201 | 199 | ||
202 | for(uint8_t i = 0; i < led_count; i++) { | 200 | for(uint8_t i = 0; i < led_count; i++) { |
203 | uint8_t index = last_hit_buffer.count; | 201 | uint8_t index = last_hit_buffer.count; |
204 | last_hit_buffer.x[index] = g_rgb_leds[led[i]].point.x; | 202 | last_hit_buffer.x[index] = g_led_config.point[led[i]].x; |
205 | last_hit_buffer.y[index] = g_rgb_leds[led[i]].point.y; | 203 | last_hit_buffer.y[index] = g_led_config.point[led[i]].y; |
206 | last_hit_buffer.index[index] = led[i]; | 204 | last_hit_buffer.index[index] = led[i]; |
207 | last_hit_buffer.tick[index] = 0; | 205 | last_hit_buffer.tick[index] = 0; |
208 | last_hit_buffer.count++; | 206 | last_hit_buffer.count++; |
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index 33665ffff..365a92bbf 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h | |||
@@ -54,9 +54,7 @@ | |||
54 | uint8_t max = DRIVER_LED_TOTAL; | 54 | uint8_t max = DRIVER_LED_TOTAL; |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | #define RGB_MATRIX_TEST_LED_FLAGS() if (!HAS_ANY_FLAGS(g_rgb_leds[i].flags, params->flags)) continue | 57 | #define RGB_MATRIX_TEST_LED_FLAGS() if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) continue |
58 | |||
59 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | ||
60 | 58 | ||
61 | typedef struct | 59 | typedef struct |
62 | { | 60 | { |
diff --git a/quantum/rgb_matrix_animations/alpha_mods_anim.h b/quantum/rgb_matrix_animations/alpha_mods_anim.h index 4bd01c4fc..d7f6f4655 100644 --- a/quantum/rgb_matrix_animations/alpha_mods_anim.h +++ b/quantum/rgb_matrix_animations/alpha_mods_anim.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #pragma once | 1 | #pragma once |
2 | #ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS | 2 | #ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS |
3 | 3 | ||
4 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 4 | extern led_config_t g_led_config; |
5 | extern rgb_config_t rgb_matrix_config; | 5 | extern rgb_config_t rgb_matrix_config; |
6 | 6 | ||
7 | // alphas = color1, mods = color2 | 7 | // alphas = color1, mods = color2 |
@@ -15,7 +15,7 @@ bool rgb_matrix_alphas_mods(effect_params_t* params) { | |||
15 | 15 | ||
16 | for (uint8_t i = led_min; i < led_max; i++) { | 16 | for (uint8_t i = led_min; i < led_max; i++) { |
17 | RGB_MATRIX_TEST_LED_FLAGS(); | 17 | RGB_MATRIX_TEST_LED_FLAGS(); |
18 | if (HAS_FLAGS(g_rgb_leds[i].flags, LED_FLAG_MODIFIER)) { | 18 | if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { |
19 | rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b); | 19 | rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b); |
20 | } else { | 20 | } else { |
21 | rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b); | 21 | rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b); |
diff --git a/quantum/rgb_matrix_animations/cycle_all_anim.h b/quantum/rgb_matrix_animations/cycle_all_anim.h index 513dff128..e93798f90 100644 --- a/quantum/rgb_matrix_animations/cycle_all_anim.h +++ b/quantum/rgb_matrix_animations/cycle_all_anim.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL | 2 | #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL |
3 | 3 | ||
4 | extern rgb_counters_t g_rgb_counters; | 4 | extern rgb_counters_t g_rgb_counters; |
5 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 5 | extern led_config_t g_led_config; |
6 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
7 | 7 | ||
8 | bool rgb_matrix_cycle_all(effect_params_t* params) { | 8 | bool rgb_matrix_cycle_all(effect_params_t* params) { |
diff --git a/quantum/rgb_matrix_animations/cycle_left_right_anim.h b/quantum/rgb_matrix_animations/cycle_left_right_anim.h index 428adea22..4b09d5826 100644 --- a/quantum/rgb_matrix_animations/cycle_left_right_anim.h +++ b/quantum/rgb_matrix_animations/cycle_left_right_anim.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT | 2 | #ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT |
3 | 3 | ||
4 | extern rgb_counters_t g_rgb_counters; | 4 | extern rgb_counters_t g_rgb_counters; |
5 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 5 | extern led_config_t g_led_config; |
6 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
7 | 7 | ||
8 | bool rgb_matrix_cycle_left_right(effect_params_t* params) { | 8 | bool rgb_matrix_cycle_left_right(effect_params_t* params) { |
@@ -12,8 +12,7 @@ bool rgb_matrix_cycle_left_right(effect_params_t* params) { | |||
12 | uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); | 12 | uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); |
13 | for (uint8_t i = led_min; i < led_max; i++) { | 13 | for (uint8_t i = led_min; i < led_max; i++) { |
14 | RGB_MATRIX_TEST_LED_FLAGS(); | 14 | RGB_MATRIX_TEST_LED_FLAGS(); |
15 | point_t point = g_rgb_leds[i].point; | 15 | hsv.h = g_led_config.point[i].x - time; |
16 | hsv.h = point.x - time; | ||
17 | RGB rgb = hsv_to_rgb(hsv); | 16 | RGB rgb = hsv_to_rgb(hsv); |
18 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | 17 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); |
19 | } | 18 | } |
diff --git a/quantum/rgb_matrix_animations/cycle_up_down_anim.h b/quantum/rgb_matrix_animations/cycle_up_down_anim.h index ea63095d2..403214bb7 100644 --- a/quantum/rgb_matrix_animations/cycle_up_down_anim.h +++ b/quantum/rgb_matrix_animations/cycle_up_down_anim.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN | 2 | #ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN |
3 | 3 | ||
4 | extern rgb_counters_t g_rgb_counters; | 4 | extern rgb_counters_t g_rgb_counters; |
5 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 5 | extern led_config_t g_led_config; |
6 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
7 | 7 | ||
8 | bool rgb_matrix_cycle_up_down(effect_params_t* params) { | 8 | bool rgb_matrix_cycle_up_down(effect_params_t* params) { |
@@ -12,8 +12,7 @@ bool rgb_matrix_cycle_up_down(effect_params_t* params) { | |||
12 | uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); | 12 | uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); |
13 | for (uint8_t i = led_min; i < led_max; i++) { | 13 | for (uint8_t i = led_min; i < led_max; i++) { |
14 | RGB_MATRIX_TEST_LED_FLAGS(); | 14 | RGB_MATRIX_TEST_LED_FLAGS(); |
15 | point_t point = g_rgb_leds[i].point; | 15 | hsv.h = g_led_config.point[i].y - time; |
16 | hsv.h = point.y - time; | ||
17 | RGB rgb = hsv_to_rgb(hsv); | 16 | RGB rgb = hsv_to_rgb(hsv); |
18 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | 17 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); |
19 | } | 18 | } |
diff --git a/quantum/rgb_matrix_animations/dual_beacon_anim.h b/quantum/rgb_matrix_animations/dual_beacon_anim.h index 00f6e5088..dcb594029 100644 --- a/quantum/rgb_matrix_animations/dual_beacon_anim.h +++ b/quantum/rgb_matrix_animations/dual_beacon_anim.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #ifndef DISABLE_RGB_MATRIX_DUAL_BEACON | 2 | #ifndef DISABLE_RGB_MATRIX_DUAL_BEACON |
3 | 3 | ||
4 | extern rgb_counters_t g_rgb_counters; | 4 | extern rgb_counters_t g_rgb_counters; |
5 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 5 | extern led_config_t g_led_config; |
6 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
7 | 7 | ||
8 | bool rgb_matrix_dual_beacon(effect_params_t* params) { | 8 | bool rgb_matrix_dual_beacon(effect_params_t* params) { |
@@ -14,8 +14,7 @@ bool rgb_matrix_dual_beacon(effect_params_t* params) { | |||
14 | int8_t sin_value = sin8(time) - 128; | 14 | int8_t sin_value = sin8(time) - 128; |
15 | for (uint8_t i = led_min; i < led_max; i++) { | 15 | for (uint8_t i = led_min; i < led_max; i++) { |
16 | RGB_MATRIX_TEST_LED_FLAGS(); | 16 | RGB_MATRIX_TEST_LED_FLAGS(); |
17 | point_t point = g_rgb_leds[i].point; | 17 | hsv.h = ((g_led_config.point[i].y - 32) * cos_value + (g_led_config.point[i].x - 112) * sin_value) / 128 + rgb_matrix_config.hue; |
18 | hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue; | ||
19 | RGB rgb = hsv_to_rgb(hsv); | 18 | RGB rgb = hsv_to_rgb(hsv); |
20 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | 19 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); |
21 | } | 20 | } |
diff --git a/quantum/rgb_matrix_animations/gradient_up_down_anim.h b/quantum/rgb_matrix_animations/gradient_up_down_anim.h index 05117540a..7a6ed1421 100644 --- a/quantum/rgb_matrix_animations/gradient_up_down_anim.h +++ b/quantum/rgb_matrix_animations/gradient_up_down_anim.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #pragma once | 1 | #pragma once |
2 | #ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN | 2 | #ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN |
3 | 3 | ||
4 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 4 | extern led_config_t g_led_config; |
5 | extern rgb_config_t rgb_matrix_config; | 5 | extern rgb_config_t rgb_matrix_config; |
6 | 6 | ||
7 | bool rgb_matrix_gradient_up_down(effect_params_t* params) { | 7 | bool rgb_matrix_gradient_up_down(effect_params_t* params) { |
@@ -11,10 +11,9 @@ bool rgb_matrix_gradient_up_down(effect_params_t* params) { | |||
11 | uint8_t scale = scale8(64, rgb_matrix_config.speed); | 11 | uint8_t scale = scale8(64, rgb_matrix_config.speed); |
12 | for (uint8_t i = led_min; i < led_max; i++) { | 12 | for (uint8_t i = led_min; i < led_max; i++) { |
13 | RGB_MATRIX_TEST_LED_FLAGS(); | 13 | RGB_MATRIX_TEST_LED_FLAGS(); |
14 | point_t point = g_rgb_leds[i].point; | ||
15 | // The y range will be 0..64, map this to 0..4 | 14 | // The y range will be 0..64, map this to 0..4 |
16 | // Relies on hue being 8-bit and wrapping | 15 | // Relies on hue being 8-bit and wrapping |
17 | hsv.h = rgb_matrix_config.hue + scale * (point.y >> 4); | 16 | hsv.h = rgb_matrix_config.hue + scale * (g_led_config.point[i].y >> 4); |
18 | RGB rgb = hsv_to_rgb(hsv); | 17 | RGB rgb = hsv_to_rgb(hsv); |
19 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | 18 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); |
20 | } | 19 | } |
diff --git a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h index dffa53264..5ea971435 100644 --- a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h +++ b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h | |||
@@ -2,11 +2,11 @@ | |||
2 | #ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS | 2 | #ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS |
3 | 3 | ||
4 | extern rgb_counters_t g_rgb_counters; | 4 | extern rgb_counters_t g_rgb_counters; |
5 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 5 | extern led_config_t g_led_config; |
6 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
7 | 7 | ||
8 | static void jellybean_raindrops_set_color(int i, effect_params_t* params) { | 8 | static void jellybean_raindrops_set_color(int i, effect_params_t* params) { |
9 | if (!HAS_ANY_FLAGS(g_rgb_leds[i].flags, params->flags)) return; | 9 | if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; |
10 | HSV hsv = { rand() & 0xFF , rand() & 0xFF, rgb_matrix_config.val }; | 10 | HSV hsv = { rand() & 0xFF , rand() & 0xFF, rgb_matrix_config.val }; |
11 | RGB rgb = hsv_to_rgb(hsv); | 11 | RGB rgb = hsv_to_rgb(hsv); |
12 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | 12 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); |
diff --git a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h index 89f6965c3..d46288073 100644 --- a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON | 2 | #ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON |
3 | 3 | ||
4 | extern rgb_counters_t g_rgb_counters; | 4 | extern rgb_counters_t g_rgb_counters; |
5 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 5 | extern led_config_t g_led_config; |
6 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
7 | 7 | ||
8 | bool rgb_matrix_rainbow_beacon(effect_params_t* params) { | 8 | bool rgb_matrix_rainbow_beacon(effect_params_t* params) { |
@@ -14,8 +14,7 @@ bool rgb_matrix_rainbow_beacon(effect_params_t* params) { | |||
14 | int16_t sin_value = 2 * (sin8(time) - 128); | 14 | int16_t sin_value = 2 * (sin8(time) - 128); |
15 | for (uint8_t i = led_min; i < led_max; i++) { | 15 | for (uint8_t i = led_min; i < led_max; i++) { |
16 | RGB_MATRIX_TEST_LED_FLAGS(); | 16 | RGB_MATRIX_TEST_LED_FLAGS(); |
17 | point_t point = g_rgb_leds[i].point; | 17 | hsv.h = ((g_led_config.point[i].y - 32) * cos_value + (g_led_config.point[i].x - 112) * sin_value) / 128 + rgb_matrix_config.hue; |
18 | hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue; | ||
19 | RGB rgb = hsv_to_rgb(hsv); | 18 | RGB rgb = hsv_to_rgb(hsv); |
20 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | 19 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); |
21 | } | 20 | } |
diff --git a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h index 0d57aef57..3b7d9689f 100644 --- a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON | 2 | #ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON |
3 | 3 | ||
4 | extern rgb_counters_t g_rgb_counters; | 4 | extern rgb_counters_t g_rgb_counters; |
5 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 5 | extern led_config_t g_led_config; |
6 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
7 | 7 | ||
8 | bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) { | 8 | bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) { |
@@ -12,8 +12,7 @@ bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) { | |||
12 | uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); | 12 | uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); |
13 | for (uint8_t i = led_min; i < led_max; i++) { | 13 | for (uint8_t i = led_min; i < led_max; i++) { |
14 | RGB_MATRIX_TEST_LED_FLAGS(); | 14 | RGB_MATRIX_TEST_LED_FLAGS(); |
15 | point_t point = g_rgb_leds[i].point; | 15 | hsv.h = abs8(g_led_config.point[i].y - 32) + (g_led_config.point[i].x - time) + rgb_matrix_config.hue; |
16 | hsv.h = abs8(point.y - 32) + (point.x - time) + rgb_matrix_config.hue; | ||
17 | RGB rgb = hsv_to_rgb(hsv); | 16 | RGB rgb = hsv_to_rgb(hsv); |
18 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | 17 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); |
19 | } | 18 | } |
diff --git a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h index 03652758c..e92f35176 100644 --- a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS | 2 | #ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS |
3 | 3 | ||
4 | extern rgb_counters_t g_rgb_counters; | 4 | extern rgb_counters_t g_rgb_counters; |
5 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 5 | extern led_config_t g_led_config; |
6 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
7 | 7 | ||
8 | bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) { | 8 | bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) { |
@@ -14,8 +14,7 @@ bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) { | |||
14 | int16_t sin_value = 3 * (sin8(time) - 128); | 14 | int16_t sin_value = 3 * (sin8(time) - 128); |
15 | for (uint8_t i = led_min; i < led_max; i++) { | 15 | for (uint8_t i = led_min; i < led_max; i++) { |
16 | RGB_MATRIX_TEST_LED_FLAGS(); | 16 | RGB_MATRIX_TEST_LED_FLAGS(); |
17 | point_t point = g_rgb_leds[i].point; | 17 | hsv.h = ((g_led_config.point[i].y - 32) * cos_value + (56 - abs8(g_led_config.point[i].x - 112)) * sin_value) / 128 + rgb_matrix_config.hue; |
18 | hsv.h = ((point.y - 32) * cos_value + (56 - abs8(point.x - 112)) * sin_value) / 128 + rgb_matrix_config.hue; | ||
19 | RGB rgb = hsv_to_rgb(hsv); | 18 | RGB rgb = hsv_to_rgb(hsv); |
20 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | 19 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); |
21 | } | 20 | } |
diff --git a/quantum/rgb_matrix_animations/raindrops_anim.h b/quantum/rgb_matrix_animations/raindrops_anim.h index 0e3a87864..4ce1d65e5 100644 --- a/quantum/rgb_matrix_animations/raindrops_anim.h +++ b/quantum/rgb_matrix_animations/raindrops_anim.h | |||
@@ -3,10 +3,11 @@ | |||
3 | #include "rgb_matrix_types.h" | 3 | #include "rgb_matrix_types.h" |
4 | 4 | ||
5 | extern rgb_counters_t g_rgb_counters; | 5 | extern rgb_counters_t g_rgb_counters; |
6 | extern led_config_t g_led_config; | ||
6 | extern rgb_config_t rgb_matrix_config; | 7 | extern rgb_config_t rgb_matrix_config; |
7 | 8 | ||
8 | static void raindrops_set_color(int i, effect_params_t* params) { | 9 | static void raindrops_set_color(int i, effect_params_t* params) { |
9 | if (!HAS_ANY_FLAGS(g_rgb_leds[i].flags, params->flags)) return; | 10 | if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; |
10 | HSV hsv = { 0 , rgb_matrix_config.sat, rgb_matrix_config.val }; | 11 | HSV hsv = { 0 , rgb_matrix_config.sat, rgb_matrix_config.val }; |
11 | 12 | ||
12 | // Take the shortest path between hues | 13 | // Take the shortest path between hues |
diff --git a/quantum/rgb_matrix_animations/solid_color_anim.h b/quantum/rgb_matrix_animations/solid_color_anim.h index 033c1f933..ba2cea15e 100644 --- a/quantum/rgb_matrix_animations/solid_color_anim.h +++ b/quantum/rgb_matrix_animations/solid_color_anim.h | |||
@@ -1,5 +1,6 @@ | |||
1 | #pragma once | 1 | #pragma once |
2 | 2 | ||
3 | extern led_config_t g_led_config; | ||
3 | extern rgb_config_t rgb_matrix_config; | 4 | extern rgb_config_t rgb_matrix_config; |
4 | 5 | ||
5 | bool rgb_matrix_solid_color(effect_params_t* params) { | 6 | bool rgb_matrix_solid_color(effect_params_t* params) { |
diff --git a/quantum/rgb_matrix_animations/solid_reactive_anim.h b/quantum/rgb_matrix_animations/solid_reactive_anim.h index 82483653a..c3dba8a5a 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) | 2 | #if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) |
3 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE | 3 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE |
4 | 4 | ||
5 | extern led_config_t g_led_config; | ||
5 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
6 | extern last_hit_t g_last_hit_tracker; | 7 | extern last_hit_t g_last_hit_tracker; |
7 | 8 | ||
diff --git a/quantum/rgb_matrix_animations/solid_reactive_cross.h b/quantum/rgb_matrix_animations/solid_reactive_cross.h index 1dec1886d..8858f71e6 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_cross.h +++ b/quantum/rgb_matrix_animations/solid_reactive_cross.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | 2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED |
3 | #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) | 3 | #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) |
4 | 4 | ||
5 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 5 | extern led_config_t g_led_config; |
6 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
7 | extern last_hit_t g_last_hit_tracker; | 7 | extern last_hit_t g_last_hit_tracker; |
8 | 8 | ||
@@ -13,11 +13,10 @@ static bool rgb_matrix_solid_reactive_multicross_range(uint8_t start, effect_par | |||
13 | uint8_t count = g_last_hit_tracker.count; | 13 | uint8_t count = g_last_hit_tracker.count; |
14 | for (uint8_t i = led_min; i < led_max; i++) { | 14 | for (uint8_t i = led_min; i < led_max; i++) { |
15 | hsv.v = 0; | 15 | hsv.v = 0; |
16 | point_t point = g_rgb_leds[i].point; | ||
17 | for (uint8_t j = start; j < count; j++) { | 16 | for (uint8_t j = start; j < count; j++) { |
18 | RGB_MATRIX_TEST_LED_FLAGS(); | 17 | RGB_MATRIX_TEST_LED_FLAGS(); |
19 | int16_t dx = point.x - g_last_hit_tracker.x[j]; | 18 | int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j]; |
20 | int16_t dy = point.y - g_last_hit_tracker.y[j]; | 19 | int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j]; |
21 | uint8_t dist = sqrt16(dx * dx + dy * dy); | 20 | uint8_t dist = sqrt16(dx * dx + dy * dy); |
22 | int16_t dist2 = 16; | 21 | int16_t dist2 = 16; |
23 | uint8_t dist3; | 22 | uint8_t dist3; |
diff --git a/quantum/rgb_matrix_animations/solid_reactive_nexus.h b/quantum/rgb_matrix_animations/solid_reactive_nexus.h index 8952a1e2b..c0e3c2450 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_nexus.h +++ b/quantum/rgb_matrix_animations/solid_reactive_nexus.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | 2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED |
3 | #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) | 3 | #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) |
4 | 4 | ||
5 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 5 | extern led_config_t g_led_config; |
6 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
7 | extern last_hit_t g_last_hit_tracker; | 7 | extern last_hit_t g_last_hit_tracker; |
8 | 8 | ||
@@ -13,11 +13,10 @@ static bool rgb_matrix_solid_reactive_multinexus_range(uint8_t start, effect_par | |||
13 | uint8_t count = g_last_hit_tracker.count; | 13 | uint8_t count = g_last_hit_tracker.count; |
14 | for (uint8_t i = led_min; i < led_max; i++) { | 14 | for (uint8_t i = led_min; i < led_max; i++) { |
15 | hsv.v = 0; | 15 | hsv.v = 0; |
16 | point_t point = g_rgb_leds[i].point; | ||
17 | for (uint8_t j = start; j < count; j++) { | 16 | for (uint8_t j = start; j < count; j++) { |
18 | RGB_MATRIX_TEST_LED_FLAGS(); | 17 | RGB_MATRIX_TEST_LED_FLAGS(); |
19 | int16_t dx = point.x - g_last_hit_tracker.x[j]; | 18 | int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j]; |
20 | int16_t dy = point.y - g_last_hit_tracker.y[j]; | 19 | int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j]; |
21 | uint8_t dist = sqrt16(dx * dx + dy * dy); | 20 | uint8_t dist = sqrt16(dx * dx + dy * dy); |
22 | int16_t dist2 = 8; | 21 | int16_t dist2 = 8; |
23 | uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist; | 22 | uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist; |
diff --git a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h index 9fc4d527a..abc7e36a8 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | 2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED |
3 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE | 3 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE |
4 | 4 | ||
5 | extern led_config_t g_led_config; | ||
5 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
6 | extern last_hit_t g_last_hit_tracker; | 7 | extern last_hit_t g_last_hit_tracker; |
7 | 8 | ||
diff --git a/quantum/rgb_matrix_animations/solid_reactive_wide.h b/quantum/rgb_matrix_animations/solid_reactive_wide.h index d86cb1284..3d1d38e80 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_wide.h +++ b/quantum/rgb_matrix_animations/solid_reactive_wide.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | 2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED |
3 | #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) | 3 | #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) |
4 | 4 | ||
5 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 5 | extern led_config_t g_led_config; |
6 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
7 | extern last_hit_t g_last_hit_tracker; | 7 | extern last_hit_t g_last_hit_tracker; |
8 | 8 | ||
@@ -13,11 +13,10 @@ static bool rgb_matrix_solid_reactive_multiwide_range(uint8_t start, effect_para | |||
13 | uint8_t count = g_last_hit_tracker.count; | 13 | uint8_t count = g_last_hit_tracker.count; |
14 | for (uint8_t i = led_min; i < led_max; i++) { | 14 | for (uint8_t i = led_min; i < led_max; i++) { |
15 | hsv.v = 0; | 15 | hsv.v = 0; |
16 | point_t point = g_rgb_leds[i].point; | ||
17 | for (uint8_t j = start; j < count; j++) { | 16 | for (uint8_t j = start; j < count; j++) { |
18 | RGB_MATRIX_TEST_LED_FLAGS(); | 17 | RGB_MATRIX_TEST_LED_FLAGS(); |
19 | int16_t dx = point.x - g_last_hit_tracker.x[j]; | 18 | int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j]; |
20 | int16_t dy = point.y - g_last_hit_tracker.y[j]; | 19 | int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j]; |
21 | uint8_t dist = sqrt16(dx * dx + dy * dy); | 20 | uint8_t dist = sqrt16(dx * dx + dy * dy); |
22 | uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) + dist * 5; | 21 | uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) + dist * 5; |
23 | if (effect > 255) | 22 | if (effect > 255) |
diff --git a/quantum/rgb_matrix_animations/solid_splash_anim.h b/quantum/rgb_matrix_animations/solid_splash_anim.h index 14312f33d..4e5565d0d 100644 --- a/quantum/rgb_matrix_animations/solid_splash_anim.h +++ b/quantum/rgb_matrix_animations/solid_splash_anim.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | 2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED |
3 | #if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH) | 3 | #if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH) |
4 | 4 | ||
5 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 5 | extern led_config_t g_led_config; |
6 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
7 | extern last_hit_t g_last_hit_tracker; | 7 | extern last_hit_t g_last_hit_tracker; |
8 | 8 | ||
@@ -14,10 +14,9 @@ static bool rgb_matrix_solid_multisplash_range(uint8_t start, effect_params_t* p | |||
14 | for (uint8_t i = led_min; i < led_max; i++) { | 14 | for (uint8_t i = led_min; i < led_max; i++) { |
15 | RGB_MATRIX_TEST_LED_FLAGS(); | 15 | RGB_MATRIX_TEST_LED_FLAGS(); |
16 | hsv.v = 0; | 16 | hsv.v = 0; |
17 | point_t point = g_rgb_leds[i].point; | ||
18 | for (uint8_t j = start; j < count; j++) { | 17 | for (uint8_t j = start; j < count; j++) { |
19 | int16_t dx = point.x - g_last_hit_tracker.x[j]; | 18 | int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j]; |
20 | int16_t dy = point.y - g_last_hit_tracker.y[j]; | 19 | int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j]; |
21 | uint8_t dist = sqrt16(dx * dx + dy * dy); | 20 | uint8_t dist = sqrt16(dx * dx + dy * dy); |
22 | uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist; | 21 | uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist; |
23 | if (effect > 255) | 22 | if (effect > 255) |
diff --git a/quantum/rgb_matrix_animations/splash_anim.h b/quantum/rgb_matrix_animations/splash_anim.h index 3c96d451e..fbe776111 100644 --- a/quantum/rgb_matrix_animations/splash_anim.h +++ b/quantum/rgb_matrix_animations/splash_anim.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | 2 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED |
3 | #if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH) | 3 | #if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH) |
4 | 4 | ||
5 | extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; | 5 | extern led_config_t g_led_config; |
6 | extern rgb_config_t rgb_matrix_config; | 6 | extern rgb_config_t rgb_matrix_config; |
7 | extern last_hit_t g_last_hit_tracker; | 7 | extern last_hit_t g_last_hit_tracker; |
8 | 8 | ||
@@ -15,10 +15,9 @@ static bool rgb_matrix_multisplash_range(uint8_t start, effect_params_t* params) | |||
15 | RGB_MATRIX_TEST_LED_FLAGS(); | 15 | RGB_MATRIX_TEST_LED_FLAGS(); |
16 | hsv.h = rgb_matrix_config.hue; | 16 | hsv.h = rgb_matrix_config.hue; |
17 | hsv.v = 0; | 17 | hsv.v = 0; |
18 | point_t point = g_rgb_leds[i].point; | ||
19 | for (uint8_t j = start; j < count; j++) { | 18 | for (uint8_t j = start; j < count; j++) { |
20 | int16_t dx = point.x - g_last_hit_tracker.x[j]; | 19 | int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j]; |
21 | int16_t dy = point.y - g_last_hit_tracker.y[j]; | 20 | int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j]; |
22 | uint8_t dist = sqrt16(dx * dx + dy * dy); | 21 | uint8_t dist = sqrt16(dx * dx + dy * dy); |
23 | uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist; | 22 | uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist; |
24 | if (effect > 255) | 23 | if (effect > 255) |
diff --git a/quantum/rgb_matrix_types.h b/quantum/rgb_matrix_types.h index 7a3bc6714..f890edd94 100644 --- a/quantum/rgb_matrix_types.h +++ b/quantum/rgb_matrix_types.h | |||
@@ -59,14 +59,6 @@ typedef struct PACKED { | |||
59 | uint8_t y; | 59 | uint8_t y; |
60 | } point_t; | 60 | } point_t; |
61 | 61 | ||
62 | typedef union { | ||
63 | uint8_t raw; | ||
64 | struct { | ||
65 | uint8_t row:4; // 16 max | ||
66 | uint8_t col:4; // 16 max | ||
67 | }; | ||
68 | } matrix_co_t; | ||
69 | |||
70 | #define HAS_FLAGS(bits, flags) ((bits & flags) == flags) | 62 | #define HAS_FLAGS(bits, flags) ((bits & flags) == flags) |
71 | #define HAS_ANY_FLAGS(bits, flags) ((bits & flags) != 0x00) | 63 | #define HAS_ANY_FLAGS(bits, flags) ((bits & flags) != 0x00) |
72 | 64 | ||
@@ -76,11 +68,13 @@ typedef union { | |||
76 | #define LED_FLAG_UNDERGLOW 0x02 | 68 | #define LED_FLAG_UNDERGLOW 0x02 |
77 | #define LED_FLAG_KEYLIGHT 0x04 | 69 | #define LED_FLAG_KEYLIGHT 0x04 |
78 | 70 | ||
71 | #define NO_LED 255 | ||
72 | |||
79 | typedef struct PACKED { | 73 | typedef struct PACKED { |
80 | matrix_co_t matrix_co; | 74 | uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS]; |
81 | point_t point; | 75 | point_t point[DRIVER_LED_TOTAL]; |
82 | uint8_t flags; | 76 | uint8_t flags[DRIVER_LED_TOTAL]; |
83 | } rgb_led; | 77 | } led_config_t; |
84 | 78 | ||
85 | typedef union { | 79 | typedef union { |
86 | uint32_t raw; | 80 | uint32_t raw; |