From af89752bffbaf5dcea30ea16be66b4d682701bc4 Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Tue, 7 May 2019 18:22:46 -0500 Subject: 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 --- quantum/rgb_matrix.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'quantum/rgb_matrix.c') diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 5528a08347..edbcee9cd1 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -105,6 +105,7 @@ bool g_suspend_state = false; +extern led_config_t g_led_config; rgb_config_t rgb_matrix_config; 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 } 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); - for (uint8_t i = 0; i < DRIVER_LED_TOTAL && led_count < LED_HITS_TO_REMEMBER; i++) { - matrix_co_t matrix_co = g_rgb_leds[i].matrix_co; - if (row == matrix_co.row && column == matrix_co.col) { - led_i[led_count] = i; - led_count++; - } + uint8_t led_index = g_led_config.matrix_co[row][column]; + if (led_index != NO_LED) { + led_i[led_count] = led_index; + 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++) { uint8_t index = last_hit_buffer.count; - last_hit_buffer.x[index] = g_rgb_leds[led[i]].point.x; - last_hit_buffer.y[index] = g_rgb_leds[led[i]].point.y; + last_hit_buffer.x[index] = g_led_config.point[led[i]].x; + last_hit_buffer.y[index] = g_led_config.point[led[i]].y; last_hit_buffer.index[index] = led[i]; last_hit_buffer.tick[index] = 0; last_hit_buffer.count++; -- cgit v1.2.3