Skip to content

Commit

Permalink
rgb_led struct conversion (aka: Per led (key) type rgb matrix effects…
Browse files Browse the repository at this point in the history
… - part 2) (qmk#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
  • Loading branch information
XScorpion2 authored and mechmerlin committed May 7, 2019
1 parent 09b2b53 commit 81728e7
Show file tree
Hide file tree
Showing 26 changed files with 81 additions and 96 deletions.
32 changes: 18 additions & 14 deletions docs/feature_rgb_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,25 @@ Configure the hardware via your `config.h`:
---
From this point forward the configuration is the same for all the drivers. The struct rgb_led array tells the system for each led, what key electrical matrix it represents, what the physical position is on the board, and if the led is for a modifier key or not. Here is a brief example:
From this point forward the configuration is the same for all the drivers. The `led_config_t` struct provides a key electrical matrix to led index lookup table, what the physical position of each LED is on the board, and what type of key or usage the LED if the LED represents. Here is a brief example:
```C
rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
/* {row | col << 4}
* | {x=0..224, y=0..64}
* | | flags
* | | | */
{{0|(0<<4)}, {20.36*0, 21.33*0}, 1},
{{0|(1<<4)}, {20.36*1, 21.33*0}, 4},
....
}
const led_config_t g_led_config = { {
// Key Matrix to LED Index
{ 5, NO_LED, NO_LED, 0 },
{ NO_LED, NO_LED, NO_LED, NO_LED },
{ 4, NO_LED, NO_LED, 1 },
{ 3, NO_LED, NO_LED, 2 }
}, {
// LED Index to Physical Position
{ 188, 16 }, { 187, 48 }, { 149, 64 }, { 112, 64 }, { 37, 48 }, { 38, 16 }
}, {
// LED Index to Flag
1, 4, 4, 4, 4, 1
} };
```

The first part, `{row | col << 4}`, tells the system what key this LED represents by using the key's electrical matrix row & col. The second part, `{x=0..224, y=0..64}` represents the LED's physical position on the keyboard. The `x` is between (inclusive) 0-224, and `y` is between (inclusive) 0-64 as the effects are based on this range. The easiest way to calculate these positions is imagine your keyboard is a grid, and the top left of the keyboard represents x, y coordinate 0, 0 and the bottom right of your keyboard represents 224, 64. Using this as a basis, you can use the following formula to calculate the physical position:
The first part, `// Key Matrix to LED Index`, tells the system what key this LED represents by using the key's electrical matrix row & col. The second part, `// LED Index to Physical Position` represents the LED's physical position on the keyboard. The first value, `x`, is between 0-224 (inclusive), and the second value, `y`, is between 0-64 (inclusive). This range is due to effect that calculate the center or halves for their animations. The easiest way to calculate these positions is imagine your keyboard is a grid, and the top left of the keyboard represents x, y coordinate 0, 0 and the bottom right of your keyboard represents 224, 64. Using this as a basis, you can use the following formula to calculate the physical position:

```C
x = 224 / (NUMBER_OF_COLS - 1) * COL_POSITION
Expand All @@ -147,16 +151,16 @@ y = 64 / (NUMBER_OF_ROWS - 1) * ROW_POSITION

Where NUMBER_OF_COLS, NUMBER_OF_ROWS, COL_POSITION, & ROW_POSITION are all based on the physical layout of your keyboard, not the electrical layout.

`flags` is a bitmask, whether or not a certain LEDs is of a certain type. It is recommended that LEDs are set to only 1 type.
`// LED Index to Flag` is a bitmask, whether or not a certain LEDs is of a certain type. It is recommended that LEDs are set to only 1 type.

## Flags

|Define |Description |
|------------------------------------|-------------------------------------------|
|`#define HAS_FLAGS(bits, flags)` |Returns true if `bits` has all `flags` set.|
|`#define HAS_ANY_FLAGS(bits, flags)`|Returns true if `bits` has any `flags` set.|
|`#define LED_FLAG_NONE 0x00` |If thes LED has no flags. |
|`#define LED_FLAG_ALL 0xFF` |If thes LED has all flags. |
|`#define LED_FLAG_NONE 0x00` |If this LED has no flags. |
|`#define LED_FLAG_ALL 0xFF` |If this LED has all flags. |
|`#define LED_FLAG_MODIFIER 0x01` |If the Key for this LED is a modifier. |
|`#define LED_FLAG_UNDERGLOW 0x02` |If the LED is for underglow. |
|`#define LED_FLAG_KEYLIGHT 0x04` |If the LED is for key backlight. |
Expand Down
7 changes: 3 additions & 4 deletions layouts/community/ergodox/drashna/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,10 @@ void suspend_wakeup_init_keymap(void) {
rgb_matrix_set_suspend_state(false);
}

void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue) {
rgb_led led;
extern led_config_t g_led_config;
void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, bool default_layer) {
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
led = g_rgb_leds[i];
if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) {
if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) {
rgb_matrix_set_color( i, red, green, blue );
}
}
Expand Down
5 changes: 2 additions & 3 deletions layouts/community/ortho_4x12/drashna/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,10 @@ void suspend_wakeup_init_keymap(void) {
rgb_matrix_set_suspend_state(false);
}

extern led_config_t g_led_config;
void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue) {
rgb_led led;
for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
led = g_rgb_leds[i];
if (HAS_FLAGS(led.flags, LED_FLAG_MODIFIER)) {
if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) {
rgb_matrix_set_color( i, red, green, blue );
}
}
Expand Down
16 changes: 7 additions & 9 deletions quantum/rgb_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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++;
Expand Down
4 changes: 1 addition & 3 deletions quantum/rgb_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@
uint8_t max = DRIVER_LED_TOTAL;
#endif

#define RGB_MATRIX_TEST_LED_FLAGS() if (!HAS_ANY_FLAGS(g_rgb_leds[i].flags, params->flags)) continue

extern rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
#define RGB_MATRIX_TEST_LED_FLAGS() if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) continue

typedef struct
{
Expand Down
4 changes: 2 additions & 2 deletions quantum/rgb_matrix_animations/alpha_mods_anim.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#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;

// alphas = color1, mods = color2
Expand All @@ -15,7 +15,7 @@ bool rgb_matrix_alphas_mods(effect_params_t* params) {

for (uint8_t i = led_min; i < led_max; i++) {
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);
} else {
rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b);
Expand Down
2 changes: 1 addition & 1 deletion quantum/rgb_matrix_animations/cycle_all_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL

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;

bool rgb_matrix_cycle_all(effect_params_t* params) {
Expand Down
5 changes: 2 additions & 3 deletions quantum/rgb_matrix_animations/cycle_left_right_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT

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;

bool rgb_matrix_cycle_left_right(effect_params_t* params) {
Expand All @@ -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);
for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS();
point_t point = g_rgb_leds[i].point;
hsv.h = point.x - time;
hsv.h = g_led_config.point[i].x - time;
RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
Expand Down
5 changes: 2 additions & 3 deletions quantum/rgb_matrix_animations/cycle_up_down_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN

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;

bool rgb_matrix_cycle_up_down(effect_params_t* params) {
Expand All @@ -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);
for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS();
point_t point = g_rgb_leds[i].point;
hsv.h = point.y - time;
hsv.h = g_led_config.point[i].y - time;
RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
Expand Down
5 changes: 2 additions & 3 deletions quantum/rgb_matrix_animations/dual_beacon_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef DISABLE_RGB_MATRIX_DUAL_BEACON

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;

bool rgb_matrix_dual_beacon(effect_params_t* params) {
Expand All @@ -14,8 +14,7 @@ bool rgb_matrix_dual_beacon(effect_params_t* params) {
int8_t sin_value = sin8(time) - 128;
for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS();
point_t point = g_rgb_leds[i].point;
hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue;
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;
RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
Expand Down
5 changes: 2 additions & 3 deletions quantum/rgb_matrix_animations/gradient_up_down_anim.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#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;

bool rgb_matrix_gradient_up_down(effect_params_t* params) {
Expand All @@ -11,10 +11,9 @@ bool rgb_matrix_gradient_up_down(effect_params_t* params) {
uint8_t scale = scale8(64, rgb_matrix_config.speed);
for (uint8_t i = led_min; i < led_max; i++) {
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
// 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_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
Expand Down
4 changes: 2 additions & 2 deletions quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS

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;

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 };
RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
Expand Down
5 changes: 2 additions & 3 deletions quantum/rgb_matrix_animations/rainbow_beacon_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON

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;

bool rgb_matrix_rainbow_beacon(effect_params_t* params) {
Expand All @@ -14,8 +14,7 @@ bool rgb_matrix_rainbow_beacon(effect_params_t* params) {
int16_t sin_value = 2 * (sin8(time) - 128);
for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS();
point_t point = g_rgb_leds[i].point;
hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue;
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;
RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
Expand Down
5 changes: 2 additions & 3 deletions quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON

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;

bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) {
Expand All @@ -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);
for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS();
point_t point = g_rgb_leds[i].point;
hsv.h = abs8(point.y - 32) + (point.x - time) + rgb_matrix_config.hue;
hsv.h = abs8(g_led_config.point[i].y - 32) + (g_led_config.point[i].x - time) + rgb_matrix_config.hue;
RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
Expand Down
5 changes: 2 additions & 3 deletions quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS

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;

bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) {
Expand All @@ -14,8 +14,7 @@ bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) {
int16_t sin_value = 3 * (sin8(time) - 128);
for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS();
point_t point = g_rgb_leds[i].point;
hsv.h = ((point.y - 32) * cos_value + (56 - abs8(point.x - 112)) * sin_value) / 128 + rgb_matrix_config.hue;
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;
RGB rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
Expand Down
3 changes: 2 additions & 1 deletion quantum/rgb_matrix_animations/raindrops_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#include "rgb_matrix_types.h"

extern rgb_counters_t g_rgb_counters;
extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config;

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 };

// Take the shortest path between hues
Expand Down
1 change: 1 addition & 0 deletions quantum/rgb_matrix_animations/solid_color_anim.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config;

bool rgb_matrix_solid_color(effect_params_t* params) {
Expand Down
1 change: 1 addition & 0 deletions quantum/rgb_matrix_animations/solid_reactive_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED)
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE

extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config;
extern last_hit_t g_last_hit_tracker;

Expand Down
7 changes: 3 additions & 4 deletions quantum/rgb_matrix_animations/solid_reactive_cross.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#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 last_hit_t g_last_hit_tracker;

Expand All @@ -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;
for (uint8_t i = led_min; i < led_max; i++) {
hsv.v = 0;
point_t point = g_rgb_leds[i].point;
for (uint8_t j = start; j < count; j++) {
RGB_MATRIX_TEST_LED_FLAGS();
int16_t dx = point.x - g_last_hit_tracker.x[j];
int16_t dy = point.y - g_last_hit_tracker.y[j];
int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
uint8_t dist = sqrt16(dx * dx + dy * dy);
int16_t dist2 = 16;
uint8_t dist3;
Expand Down
7 changes: 3 additions & 4 deletions quantum/rgb_matrix_animations/solid_reactive_nexus.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#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 last_hit_t g_last_hit_tracker;

Expand All @@ -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;
for (uint8_t i = led_min; i < led_max; i++) {
hsv.v = 0;
point_t point = g_rgb_leds[i].point;
for (uint8_t j = start; j < count; j++) {
RGB_MATRIX_TEST_LED_FLAGS();
int16_t dx = point.x - g_last_hit_tracker.x[j];
int16_t dy = point.y - g_last_hit_tracker.y[j];
int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j];
int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j];
uint8_t dist = sqrt16(dx * dx + dy * dy);
int16_t dist2 = 8;
uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist;
Expand Down
1 change: 1 addition & 0 deletions quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE

extern led_config_t g_led_config;
extern rgb_config_t rgb_matrix_config;
extern last_hit_t g_last_hit_tracker;

Expand Down
Loading

0 comments on commit 81728e7

Please sign in to comment.