rgb_led struct conversion (aka: Per led (key) type rgb matrix effects - part 2) (#5783)

* Initial conversion of the rgb_led struct

* Converting last keyboard & updating effects to take advantage of the new structure

* New struct should not be const

* Updated docs

* Changing define ___ for no led to NO_LED

* Missed converting some keymap usages of the old struct layout
pull/5990/head
XScorpion2 6 years ago committed by Drashna Jaelre
parent 6364fe4efb
commit 4d57a049b5
No known key found for this signature in database
GPG Key ID: 4C4221222CD5F9F0

@ -269,68 +269,39 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
}; };
rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { led_config_t g_led_config = { {
{ NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED },
/*{row | col << 4} { 28, 33, 38, 43, 47, NO_LED },
| {x=0..224, y=0..64} { 27, 32, 37, 42, 46, NO_LED },
| | flags { 26, 31, 36, 41, 45, NO_LED },
| | | */ { 25, 30, 35, 40, 44, NO_LED },
{{ 8|(0<<4)}, {17.2* 8, 12.8*0}, 4}, // LED 1 on right > Key 6 { 24, 29, 34, 39, NO_LED, NO_LED },
{{ 9|(0<<4)}, {17.2* 9, 12.8*0}, 4}, // LED 2 > Key 7 { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED },
{{10|(0<<4)}, {17.2*10, 12.8*0}, 4}, // LED 3 > Key 8 { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED },
{{11|(0<<4)}, {17.2*11, 12.8*0}, 4}, // LED 4 > Key 9 { 0, 5, 10, 15, NO_LED, NO_LED },
{{12|(0<<4)}, {17.2*12, 12.8*0}, 4}, // LED 5 > Key 0 { 1, 6, 11, 16, 20, NO_LED },
{ 2, 7, 12, 17, 21, NO_LED },
{{ 8|(1<<4)}, {17.2* 8, 12.8*1}, 4}, // LED 6 { 3, 8, 13, 18, 22, NO_LED },
{{ 9|(1<<4)}, {17.2* 9, 12.8*1}, 4}, // LED 7 { 4, 9, 14, 19, 23, NO_LED },
{{10|(1<<4)}, {17.2*10, 12.8*1}, 4}, // LED 8 { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED }
{{11|(1<<4)}, {17.2*11, 12.8*1}, 4}, // LED 9 }, {
{{12|(1<<4)}, {17.2*12, 12.8*1}, 4}, // LED 10 { 137, 0 }, { 154, 0 }, { 172, 0 }, { 189, 0 }, { 206, 0 }, { 137, 12 },
{ 154, 12 }, { 172, 12 }, { 189, 12 }, { 206, 12 }, { 137, 25 }, { 154, 25 },
{{ 8|(2<<4)}, {17.2* 8, 12.8*2}, 4}, // LED 11 { 172, 25 }, { 189, 25 }, { 206, 25 }, { 137, 38 }, { 154, 38 }, { 172, 38 },
{{ 9|(2<<4)}, {17.2* 9, 12.8*2}, 4}, // LED 12 { 189, 38 }, { 206, 38 }, { 154, 51 }, { 172, 51 }, { 189, 51 }, { 206, 51 },
{{10|(2<<4)}, {17.2*10, 12.8*2}, 4}, // LED 13 { 86, 0 }, { 68, 0 }, { 51, 0 }, { 34, 0 }, { 17, 0 }, { 86, 12 },
{{11|(2<<4)}, {17.2*11, 12.8*2}, 4}, // LED 14 { 68, 12 }, { 51, 12 }, { 34, 12 }, { 17, 12 }, { 86, 25 }, { 68, 25 },
{{12|(2<<4)}, {17.2*12, 12.8*2}, 4}, // LED 15 { 51, 25 }, { 34, 25 }, { 17, 25 }, { 86, 38 }, { 68, 38 }, { 51, 38 },
{ 34, 38 }, { 17, 38 }, { 68, 51 }, { 51, 51 }, { 34, 51 }, { 17, 51 }
{{ 8|(3<<4)}, {17.2* 8, 12.8*3}, 4}, // LED 16 }, {
{{ 9|(3<<4)}, {17.2* 9, 12.8*3}, 4}, // LED 17 4, 4, 4, 4, 4, 4,
{{10|(3<<4)}, {17.2*10, 12.8*3}, 4}, // LED 18 4, 4, 4, 4, 4, 4,
{{11|(3<<4)}, {17.2*11, 12.8*3}, 4}, // LED 19 4, 4, 4, 4, 4, 4,
{{12|(3<<4)}, {17.2*12, 12.8*3}, 4}, // LED 20 4, 4, 1, 1, 1, 1,
4, 4, 4, 4, 4, 4,
{{ 9|(4<<4)}, {17.2* 9, 12.8*4}, 1}, // LED 21 4, 4, 4, 4, 4, 4,
{{10|(4<<4)}, {17.2*10, 12.8*4}, 1}, // LED 22 4, 4, 4, 4, 4, 4,
{{11|(4<<4)}, {17.2*11, 12.8*4}, 1}, // LED 23 4, 4, 1, 1, 1, 1
{{12|(4<<4)}, {17.2*12, 12.8*4}, 1}, // LED 24 } };
{{ 5|(0<<4)}, {17.2* 5, 12.8*0}, 4}, // LED 1 on left > Key 5
{{ 4|(0<<4)}, {17.2* 4, 12.8*0}, 4}, // LED 2 > Key 4
{{ 3|(0<<4)}, {17.2* 3, 12.8*0}, 4}, // LED 3 > Key 3
{{ 2|(0<<4)}, {17.2* 2, 12.8*0}, 4}, // LED 4 > Key 2
{{ 1|(0<<4)}, {17.2* 1, 12.8*0}, 4}, // LED 5 > Key 1
{{ 5|(1<<4)}, {17.2* 5, 12.8*1}, 4}, // LED 6
{{ 4|(1<<4)}, {17.2* 4, 12.8*1}, 4}, // LED 7
{{ 3|(1<<4)}, {17.2* 3, 12.8*1}, 4}, // LED 8
{{ 2|(1<<4)}, {17.2* 2, 12.8*1}, 4}, // LED 9
{{ 1|(1<<4)}, {17.2* 1, 12.8*1}, 4}, // LED 10
{{ 5|(2<<4)}, {17.2* 5, 12.8*2}, 4}, // LED 11
{{ 4|(2<<4)}, {17.2* 4, 12.8*2}, 4}, // LED 12
{{ 3|(2<<4)}, {17.2* 3, 12.8*2}, 4}, // LED 13
{{ 2|(2<<4)}, {17.2* 2, 12.8*2}, 4}, // LED 14
{{ 1|(2<<4)}, {17.2* 1, 12.8*2}, 4}, // LED 15
{{ 5|(3<<4)}, {17.2* 5, 12.8*3}, 4}, // LED 16
{{ 4|(3<<4)}, {17.2* 4, 12.8*3}, 4}, // LED 17
{{ 3|(3<<4)}, {17.2* 3, 12.8*3}, 4}, // LED 18
{{ 2|(3<<4)}, {17.2* 2, 12.8*3}, 4}, // LED 19
{{ 1|(3<<4)}, {17.2* 1, 12.8*3}, 4}, // LED 20
{{ 4|(4<<4)}, {17.2* 4, 12.8*4}, 1}, // LED 21
{{ 3|(4<<4)}, {17.2* 3, 12.8*4}, 1}, // LED 22
{{ 2|(4<<4)}, {17.2* 2, 12.8*4}, 1}, // LED 23
{{ 1|(4<<4)}, {17.2* 1, 12.8*4}, 1}, // LED 24 > Key Hack
};
#endif #endif

@ -79,63 +79,27 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
}; };
rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { led_config_t g_led_config = { {
{ 0, 1, 2, 3, 4, 5 },
/*{row | col << 4} { 12, 13, 14, 15, 16, 17 },
| {x=0..224, y=0..64} { 24, 25, 26, 27, 28, 29 },
| | flags { 36, 37, 38, 45, 46, NO_LED },
| | | */ { 6, 7, 8, 9, 10, 11 },
{{0|(0<<4)}, {20.36*0, 21.33*0}, 1}, { 18, 19, 20, 21, 22, 23 },
{{0|(1<<4)}, {20.36*1, 21.33*0}, 4}, { 30, 31, 32, 33, 34, 35 },
{{0|(2<<4)}, {20.36*2, 21.33*0}, 4}, { 42, 43, 44, 39, 40, 41 }
{{0|(3<<4)}, {20.36*3, 21.33*0}, 4}, }, {
{{0|(4<<4)}, {20.36*4, 21.33*0}, 4}, { 0, 0 }, { 20, 0 }, { 40, 0 }, { 61, 0 }, { 81, 0 }, { 101, 0 }, { 122, 0 }, { 142, 0 }, { 162, 0 }, { 183, 0 }, { 203, 0 }, { 223, 0 },
{{0|(5<<4)}, {20.36*5, 21.33*0}, 4}, { 0, 21 }, { 20, 21 }, { 40, 21 }, { 61, 21 }, { 81, 21 }, { 101, 21 }, { 122, 21 }, { 142, 21 }, { 162, 21 }, { 183, 21 }, { 203, 21 }, { 223, 21 },
{{4|(0<<4)}, {20.36*6, 21.33*0}, 4}, { 0, 42 }, { 20, 42 }, { 40, 42 }, { 61, 42 }, { 81, 42 }, { 101, 42 }, { 122, 42 }, { 142, 42 }, { 162, 42 }, { 183, 42 }, { 203, 42 }, { 223, 42 },
{{4|(1<<4)}, {20.36*7, 21.33*0}, 4}, { 0, 63 }, { 20, 63 }, { 40, 63 }, { 61, 63 }, { 81, 63 }, { 111, 63 }, { 142, 63 }, { 162, 63 }, { 183, 63 }, { 203, 63 }, { 223, 63 }
{{4|(2<<4)}, {20.36*8, 21.33*0}, 4}, }, {
{{4|(3<<4)}, {20.36*9, 21.33*0}, 4}, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
{{4|(4<<4)}, {20.36*10,21.33*0}, 4}, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
{{4|(5<<4)}, {20.36*11,21.33*0}, 1}, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1
{{1|(0<<4)}, {20.36*0, 21.33*1}, 1}, } };
{{1|(1<<4)}, {20.36*1, 21.33*1}, 4},
{{1|(2<<4)}, {20.36*2, 21.33*1}, 4},
{{1|(3<<4)}, {20.36*3, 21.33*1}, 4},
{{1|(4<<4)}, {20.36*4, 21.33*1}, 4},
{{1|(5<<4)}, {20.36*5, 21.33*1}, 4},
{{5|(0<<4)}, {20.36*6, 21.33*1}, 4},
{{5|(1<<4)}, {20.36*7, 21.33*1}, 4},
{{5|(2<<4)}, {20.36*8, 21.33*1}, 4},
{{5|(3<<4)}, {20.36*9, 21.33*1}, 4},
{{5|(4<<4)}, {20.36*10,21.33*1}, 4},
{{5|(5<<4)}, {20.36*11,21.33*1}, 1},
{{2|(0<<4)}, {20.36*0, 21.33*2}, 1},
{{2|(1<<4)}, {20.36*1, 21.33*2}, 4},
{{2|(2<<4)}, {20.36*2, 21.33*2}, 4},
{{2|(3<<4)}, {20.36*3, 21.33*2}, 4},
{{2|(4<<4)}, {20.36*4, 21.33*2}, 4},
{{2|(5<<4)}, {20.36*5, 21.33*2}, 4},
{{6|(0<<4)}, {20.36*6, 21.33*2}, 4},
{{6|(1<<4)}, {20.36*7, 21.33*2}, 4},
{{6|(2<<4)}, {20.36*8, 21.33*2}, 4},
{{6|(3<<4)}, {20.36*9, 21.33*2}, 4},
{{6|(4<<4)}, {20.36*10,21.33*2}, 4},
{{6|(5<<4)}, {20.36*11,21.33*2}, 1},
{{3|(0<<4)}, {20.36*0, 21.33*3}, 1},
{{3|(1<<4)}, {20.36*1, 21.33*3}, 1},
{{3|(2<<4)}, {20.36*2, 21.33*3}, 1},
{{7|(3<<4)}, {20.36*3, 21.33*3}, 1},
{{7|(4<<4)}, {20.36*4, 21.33*3}, 1},
{{7|(5<<4)}, {20.36*5.5,21.33*3}, 4},
{{7|(0<<4)}, {20.36*7, 21.33*3}, 1},
{{7|(1<<4)}, {20.36*8, 21.33*3}, 1},
{{7|(2<<4)}, {20.36*9, 21.33*3}, 1},
{{3|(3<<4)}, {20.36*10,21.33*3}, 1},
{{3|(4<<4)}, {20.36*11,21.33*3}, 1}
};
void matrix_init_kb(void) { void matrix_init_kb(void) {
matrix_init_user(); matrix_init_user();

@ -105,6 +105,7 @@
bool g_suspend_state = false; bool g_suspend_state = false;
extern led_config_t g_led_config;
rgb_config_t rgb_matrix_config; rgb_config_t rgb_matrix_config;
rgb_counters_t g_rgb_counters; rgb_counters_t g_rgb_counters;
@ -150,15 +151,12 @@ uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t
} }
uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) {
// TODO: This is kinda expensive, fix this soonish
uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i); uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i);
for (uint8_t i = 0; i < DRIVER_LED_TOTAL && led_count < LED_HITS_TO_REMEMBER; i++) { uint8_t led_index = g_led_config.matrix_co[row][column];
matrix_co_t matrix_co = g_rgb_leds[i].matrix_co; if (led_index != NO_LED) {
if (row == matrix_co.row && column == matrix_co.col) { led_i[led_count] = led_index;
led_i[led_count] = i;
led_count++; led_count++;
} }
}
return led_count; return led_count;
} }
@ -201,8 +199,8 @@ bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
for(uint8_t i = 0; i < led_count; i++) { for(uint8_t i = 0; i < led_count; i++) {
uint8_t index = last_hit_buffer.count; uint8_t index = last_hit_buffer.count;
last_hit_buffer.x[index] = g_rgb_leds[led[i]].point.x; last_hit_buffer.x[index] = g_led_config.point[led[i]].x;
last_hit_buffer.y[index] = g_rgb_leds[led[i]].point.y; last_hit_buffer.y[index] = g_led_config.point[led[i]].y;
last_hit_buffer.index[index] = led[i]; last_hit_buffer.index[index] = led[i];
last_hit_buffer.tick[index] = 0; last_hit_buffer.tick[index] = 0;
last_hit_buffer.count++; last_hit_buffer.count++;

@ -54,9 +54,7 @@
uint8_t max = DRIVER_LED_TOTAL; uint8_t max = DRIVER_LED_TOTAL;
#endif #endif
#define RGB_MATRIX_TEST_LED_FLAGS() if (!HAS_ANY_FLAGS(g_rgb_leds[i].flags, params->flags)) continue #define RGB_MATRIX_TEST_LED_FLAGS() if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) continue
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
typedef struct typedef struct
{ {

@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS #ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
// alphas = color1, mods = color2 // alphas = color1, mods = color2
@ -15,7 +15,7 @@ bool rgb_matrix_alphas_mods(effect_params_t* params) {
for (uint8_t i = led_min; i < led_max; i++) { for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS(); RGB_MATRIX_TEST_LED_FLAGS();
if (HAS_FLAGS(g_rgb_leds[i].flags, LED_FLAG_MODIFIER)) { if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) {
rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b); rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b);
} else { } else {
rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b); rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b);

@ -2,7 +2,7 @@
#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
extern rgb_counters_t g_rgb_counters; extern rgb_counters_t g_rgb_counters;
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
bool rgb_matrix_cycle_all(effect_params_t* params) { bool rgb_matrix_cycle_all(effect_params_t* params) {

@ -2,7 +2,7 @@
#ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT #ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
extern rgb_counters_t g_rgb_counters; extern rgb_counters_t g_rgb_counters;
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
bool rgb_matrix_cycle_left_right(effect_params_t* params) { bool rgb_matrix_cycle_left_right(effect_params_t* params) {
@ -12,8 +12,7 @@ bool rgb_matrix_cycle_left_right(effect_params_t* params) {
uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
for (uint8_t i = led_min; i < led_max; i++) { for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS(); RGB_MATRIX_TEST_LED_FLAGS();
point_t point = g_rgb_leds[i].point; hsv.h = g_led_config.point[i].x - time;
hsv.h = point.x - time;
RGB rgb = hsv_to_rgb(hsv); RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
} }

@ -2,7 +2,7 @@
#ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN #ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
extern rgb_counters_t g_rgb_counters; extern rgb_counters_t g_rgb_counters;
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
bool rgb_matrix_cycle_up_down(effect_params_t* params) { bool rgb_matrix_cycle_up_down(effect_params_t* params) {
@ -12,8 +12,7 @@ bool rgb_matrix_cycle_up_down(effect_params_t* params) {
uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
for (uint8_t i = led_min; i < led_max; i++) { for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS(); RGB_MATRIX_TEST_LED_FLAGS();
point_t point = g_rgb_leds[i].point; hsv.h = g_led_config.point[i].y - time;
hsv.h = point.y - time;
RGB rgb = hsv_to_rgb(hsv); RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
} }

@ -2,7 +2,7 @@
#ifndef DISABLE_RGB_MATRIX_DUAL_BEACON #ifndef DISABLE_RGB_MATRIX_DUAL_BEACON
extern rgb_counters_t g_rgb_counters; extern rgb_counters_t g_rgb_counters;
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
bool rgb_matrix_dual_beacon(effect_params_t* params) { bool rgb_matrix_dual_beacon(effect_params_t* params) {
@ -14,8 +14,7 @@ bool rgb_matrix_dual_beacon(effect_params_t* params) {
int8_t sin_value = sin8(time) - 128; int8_t sin_value = sin8(time) - 128;
for (uint8_t i = led_min; i < led_max; i++) { for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS(); RGB_MATRIX_TEST_LED_FLAGS();
point_t point = g_rgb_leds[i].point; 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;
hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue;
RGB rgb = hsv_to_rgb(hsv); RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
} }

@ -1,7 +1,7 @@
#pragma once #pragma once
#ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN #ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
bool rgb_matrix_gradient_up_down(effect_params_t* params) { bool rgb_matrix_gradient_up_down(effect_params_t* params) {
@ -11,10 +11,9 @@ bool rgb_matrix_gradient_up_down(effect_params_t* params) {
uint8_t scale = scale8(64, rgb_matrix_config.speed); uint8_t scale = scale8(64, rgb_matrix_config.speed);
for (uint8_t i = led_min; i < led_max; i++) { for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS(); RGB_MATRIX_TEST_LED_FLAGS();
point_t point = g_rgb_leds[i].point;
// The y range will be 0..64, map this to 0..4 // The y range will be 0..64, map this to 0..4
// Relies on hue being 8-bit and wrapping // Relies on hue being 8-bit and wrapping
hsv.h = rgb_matrix_config.hue + scale * (point.y >> 4); hsv.h = rgb_matrix_config.hue + scale * (g_led_config.point[i].y >> 4);
RGB rgb = hsv_to_rgb(hsv); RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
} }

@ -2,11 +2,11 @@
#ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS #ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
extern rgb_counters_t g_rgb_counters; extern rgb_counters_t g_rgb_counters;
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
static void jellybean_raindrops_set_color(int i, effect_params_t* params) { static void jellybean_raindrops_set_color(int i, effect_params_t* params) {
if (!HAS_ANY_FLAGS(g_rgb_leds[i].flags, params->flags)) return; if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
HSV hsv = { rand() & 0xFF , rand() & 0xFF, rgb_matrix_config.val }; HSV hsv = { rand() & 0xFF , rand() & 0xFF, rgb_matrix_config.val };
RGB rgb = hsv_to_rgb(hsv); RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);

@ -2,7 +2,7 @@
#ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON #ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON
extern rgb_counters_t g_rgb_counters; extern rgb_counters_t g_rgb_counters;
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
bool rgb_matrix_rainbow_beacon(effect_params_t* params) { bool rgb_matrix_rainbow_beacon(effect_params_t* params) {
@ -14,8 +14,7 @@ bool rgb_matrix_rainbow_beacon(effect_params_t* params) {
int16_t sin_value = 2 * (sin8(time) - 128); int16_t sin_value = 2 * (sin8(time) - 128);
for (uint8_t i = led_min; i < led_max; i++) { for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS(); RGB_MATRIX_TEST_LED_FLAGS();
point_t point = g_rgb_leds[i].point; 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;
hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue;
RGB rgb = hsv_to_rgb(hsv); RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
} }

@ -2,7 +2,7 @@
#ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON #ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
extern rgb_counters_t g_rgb_counters; extern rgb_counters_t g_rgb_counters;
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) { bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) {
@ -12,8 +12,7 @@ bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) {
uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4); uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
for (uint8_t i = led_min; i < led_max; i++) { for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS(); RGB_MATRIX_TEST_LED_FLAGS();
point_t point = g_rgb_leds[i].point; hsv.h = abs8(g_led_config.point[i].y - 32) + (g_led_config.point[i].x - time) + rgb_matrix_config.hue;
hsv.h = abs8(point.y - 32) + (point.x - time) + rgb_matrix_config.hue;
RGB rgb = hsv_to_rgb(hsv); RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
} }

@ -2,7 +2,7 @@
#ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS #ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
extern rgb_counters_t g_rgb_counters; extern rgb_counters_t g_rgb_counters;
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) { bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) {
@ -14,8 +14,7 @@ bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) {
int16_t sin_value = 3 * (sin8(time) - 128); int16_t sin_value = 3 * (sin8(time) - 128);
for (uint8_t i = led_min; i < led_max; i++) { for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS(); RGB_MATRIX_TEST_LED_FLAGS();
point_t point = g_rgb_leds[i].point; 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;
hsv.h = ((point.y - 32) * cos_value + (56 - abs8(point.x - 112)) * sin_value) / 128 + rgb_matrix_config.hue;
RGB rgb = hsv_to_rgb(hsv); RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
} }

@ -3,10 +3,11 @@
#include "rgb_matrix_types.h" #include "rgb_matrix_types.h"
extern rgb_counters_t g_rgb_counters; extern rgb_counters_t g_rgb_counters;
extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
static void raindrops_set_color(int i, effect_params_t* params) { static void raindrops_set_color(int i, effect_params_t* params) {
if (!HAS_ANY_FLAGS(g_rgb_leds[i].flags, params->flags)) return; if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
HSV hsv = { 0 , rgb_matrix_config.sat, rgb_matrix_config.val }; HSV hsv = { 0 , rgb_matrix_config.sat, rgb_matrix_config.val };
// Take the shortest path between hues // Take the shortest path between hues

@ -1,5 +1,6 @@
#pragma once #pragma once
extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
bool rgb_matrix_solid_color(effect_params_t* params) { bool rgb_matrix_solid_color(effect_params_t* params) {

@ -2,6 +2,7 @@
#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) #if defined(RGB_MATRIX_KEYREACTIVE_ENABLED)
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE
extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
extern last_hit_t g_last_hit_tracker; extern last_hit_t g_last_hit_tracker;

@ -2,7 +2,7 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS)
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
extern last_hit_t g_last_hit_tracker; extern last_hit_t g_last_hit_tracker;
@ -13,11 +13,10 @@ static bool rgb_matrix_solid_reactive_multicross_range(uint8_t start, effect_par
uint8_t count = g_last_hit_tracker.count; uint8_t count = g_last_hit_tracker.count;
for (uint8_t i = led_min; i < led_max; i++) { for (uint8_t i = led_min; i < led_max; i++) {
hsv.v = 0; hsv.v = 0;
point_t point = g_rgb_leds[i].point;
for (uint8_t j = start; j < count; j++) { for (uint8_t j = start; j < count; j++) {
RGB_MATRIX_TEST_LED_FLAGS(); RGB_MATRIX_TEST_LED_FLAGS();
int16_t dx = point.x - g_last_hit_tracker.x[j]; int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
int16_t dy = point.y - g_last_hit_tracker.y[j]; int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
uint8_t dist = sqrt16(dx * dx + dy * dy); uint8_t dist = sqrt16(dx * dx + dy * dy);
int16_t dist2 = 16; int16_t dist2 = 16;
uint8_t dist3; uint8_t dist3;

@ -2,7 +2,7 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS)
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
extern last_hit_t g_last_hit_tracker; extern last_hit_t g_last_hit_tracker;
@ -13,11 +13,10 @@ static bool rgb_matrix_solid_reactive_multinexus_range(uint8_t start, effect_par
uint8_t count = g_last_hit_tracker.count; uint8_t count = g_last_hit_tracker.count;
for (uint8_t i = led_min; i < led_max; i++) { for (uint8_t i = led_min; i < led_max; i++) {
hsv.v = 0; hsv.v = 0;
point_t point = g_rgb_leds[i].point;
for (uint8_t j = start; j < count; j++) { for (uint8_t j = start; j < count; j++) {
RGB_MATRIX_TEST_LED_FLAGS(); RGB_MATRIX_TEST_LED_FLAGS();
int16_t dx = point.x - g_last_hit_tracker.x[j]; int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
int16_t dy = point.y - g_last_hit_tracker.y[j]; int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
uint8_t dist = sqrt16(dx * dx + dy * dy); uint8_t dist = sqrt16(dx * dx + dy * dy);
int16_t dist2 = 8; int16_t dist2 = 8;
uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist; uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist;

@ -2,6 +2,7 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
extern last_hit_t g_last_hit_tracker; extern last_hit_t g_last_hit_tracker;

@ -2,7 +2,7 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) #if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE)
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
extern last_hit_t g_last_hit_tracker; extern last_hit_t g_last_hit_tracker;
@ -13,11 +13,10 @@ static bool rgb_matrix_solid_reactive_multiwide_range(uint8_t start, effect_para
uint8_t count = g_last_hit_tracker.count; uint8_t count = g_last_hit_tracker.count;
for (uint8_t i = led_min; i < led_max; i++) { for (uint8_t i = led_min; i < led_max; i++) {
hsv.v = 0; hsv.v = 0;
point_t point = g_rgb_leds[i].point;
for (uint8_t j = start; j < count; j++) { for (uint8_t j = start; j < count; j++) {
RGB_MATRIX_TEST_LED_FLAGS(); RGB_MATRIX_TEST_LED_FLAGS();
int16_t dx = point.x - g_last_hit_tracker.x[j]; int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
int16_t dy = point.y - g_last_hit_tracker.y[j]; int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
uint8_t dist = sqrt16(dx * dx + dy * dy); uint8_t dist = sqrt16(dx * dx + dy * dy);
uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) + dist * 5; uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) + dist * 5;
if (effect > 255) if (effect > 255)

@ -2,7 +2,7 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH) #if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH)
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
extern last_hit_t g_last_hit_tracker; extern last_hit_t g_last_hit_tracker;
@ -14,10 +14,9 @@ static bool rgb_matrix_solid_multisplash_range(uint8_t start, effect_params_t* p
for (uint8_t i = led_min; i < led_max; i++) { for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS(); RGB_MATRIX_TEST_LED_FLAGS();
hsv.v = 0; hsv.v = 0;
point_t point = g_rgb_leds[i].point;
for (uint8_t j = start; j < count; j++) { for (uint8_t j = start; j < count; j++) {
int16_t dx = point.x - g_last_hit_tracker.x[j]; int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
int16_t dy = point.y - g_last_hit_tracker.y[j]; int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
uint8_t dist = sqrt16(dx * dx + dy * dy); uint8_t dist = sqrt16(dx * dx + dy * dy);
uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist; uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist;
if (effect > 255) if (effect > 255)

@ -2,7 +2,7 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH) #if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
extern last_hit_t g_last_hit_tracker; extern last_hit_t g_last_hit_tracker;
@ -15,10 +15,9 @@ static bool rgb_matrix_multisplash_range(uint8_t start, effect_params_t* params)
RGB_MATRIX_TEST_LED_FLAGS(); RGB_MATRIX_TEST_LED_FLAGS();
hsv.h = rgb_matrix_config.hue; hsv.h = rgb_matrix_config.hue;
hsv.v = 0; hsv.v = 0;
point_t point = g_rgb_leds[i].point;
for (uint8_t j = start; j < count; j++) { for (uint8_t j = start; j < count; j++) {
int16_t dx = point.x - g_last_hit_tracker.x[j]; int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
int16_t dy = point.y - g_last_hit_tracker.y[j]; int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
uint8_t dist = sqrt16(dx * dx + dy * dy); uint8_t dist = sqrt16(dx * dx + dy * dy);
uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist; uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist;
if (effect > 255) if (effect > 255)

@ -59,14 +59,6 @@ typedef struct PACKED {
uint8_t y; uint8_t y;
} point_t; } point_t;
typedef union {
uint8_t raw;
struct {
uint8_t row:4; // 16 max
uint8_t col:4; // 16 max
};
} matrix_co_t;
#define HAS_FLAGS(bits, flags) ((bits & flags) == flags) #define HAS_FLAGS(bits, flags) ((bits & flags) == flags)
#define HAS_ANY_FLAGS(bits, flags) ((bits & flags) != 0x00) #define HAS_ANY_FLAGS(bits, flags) ((bits & flags) != 0x00)
@ -76,11 +68,13 @@ typedef union {
#define LED_FLAG_UNDERGLOW 0x02 #define LED_FLAG_UNDERGLOW 0x02
#define LED_FLAG_KEYLIGHT 0x04 #define LED_FLAG_KEYLIGHT 0x04
#define NO_LED 255
typedef struct PACKED { typedef struct PACKED {
matrix_co_t matrix_co; uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS];
point_t point; point_t point[DRIVER_LED_TOTAL];
uint8_t flags; uint8_t flags[DRIVER_LED_TOTAL];
} rgb_led; } led_config_t;
typedef union { typedef union {
uint32_t raw; uint32_t raw;

@ -431,6 +431,7 @@ static void led_run_pattern(led_setup_t *f, float* ro, float* go, float* bo, flo
} }
} }
extern led_config_t g_led_config;
static void led_matrix_massdrop_config_override(int i) static void led_matrix_massdrop_config_override(int i)
{ {
float ro = 0; float ro = 0;
@ -438,14 +439,14 @@ static void led_matrix_massdrop_config_override(int i)
float bo = 0; float bo = 0;
float po = (led_animation_orientation) float po = (led_animation_orientation)
? (float)g_rgb_leds[i].point.y / 64.f * 100 ? (float)g_led_config.point[i].y / 64.f * 100
: (float)g_rgb_leds[i].point.x / 224.f * 100; : (float)g_led_config.point[i].x / 224.f * 100;
uint8_t highest_active_layer = biton32(layer_state); uint8_t highest_active_layer = biton32(layer_state);
if (led_lighting_mode == LED_MODE_KEYS_ONLY && HAS_FLAGS(g_rgb_leds[i].flags, LED_FLAG_UNDERGLOW)) { if (led_lighting_mode == LED_MODE_KEYS_ONLY && HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) {
//Do not act on this LED //Do not act on this LED
} else if (led_lighting_mode == LED_MODE_NON_KEYS_ONLY && !HAS_FLAGS(g_rgb_leds[i].flags, LED_FLAG_UNDERGLOW)) { } else if (led_lighting_mode == LED_MODE_NON_KEYS_ONLY && !HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) {
//Do not act on this LED //Do not act on this LED
} else if (led_lighting_mode == LED_MODE_INDICATORS_ONLY) { } else if (led_lighting_mode == LED_MODE_INDICATORS_ONLY) {
//Do not act on this LED (Only show indicators) //Do not act on this LED (Only show indicators)

Loading…
Cancel
Save