mirror of
https://github.com/qmk/qmk_userspace.git
synced 2025-09-19 10:21:31 -04:00
Improve RGB color setting logic
This commit is contained in:
parent
9437da0d5b
commit
386e7085f2
1 changed files with 19 additions and 27 deletions
|
@ -47,39 +47,31 @@ const rgb_t colors[] = {
|
|||
{0x00, 0xb2, 0xff}
|
||||
};
|
||||
|
||||
#define NUM_COLORS (sizeof(colors) / sizeof(colors[0]))
|
||||
static uint8_t current_color_index = 0;
|
||||
|
||||
// This is a side lights only configuration where the color is set to a static gradient.
|
||||
static bool HOLOGRAPHICS_UNDERGLOW(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
if (HAS_FLAGS(g_led_config.flags[i], 0x02)) { // 0x02 == LED_FLAG_UNDERGLOW
|
||||
// RIGHT-HAND SIDE LEDS || LEFT-HAND SIDE LEDS
|
||||
if (i == 67 || i == 77) {
|
||||
rgb_matrix_set_color(i, colors[0].r, colors[0].g, colors[0].b);
|
||||
} else if (i == 68 || i == 78) {
|
||||
rgb_matrix_set_color(i, colors[1].r, colors[1].g, colors[1].b);
|
||||
} else if (i == 69 || i == 79) {
|
||||
rgb_matrix_set_color(i, colors[2].r, colors[2].g, colors[2].b);
|
||||
} else if (i == 70 || i == 80) {
|
||||
rgb_matrix_set_color(i, colors[3].r, colors[3].g, colors[3].b);
|
||||
} else if (i == 71 || i == 81) {
|
||||
rgb_matrix_set_color(i, colors[4].r, colors[4].g, colors[4].b);
|
||||
} else if (i == 72 || i == 82) {
|
||||
rgb_matrix_set_color(i, colors[5].r, colors[5].g, colors[5].b);
|
||||
} else if (i == 73 || i == 83) {
|
||||
rgb_matrix_set_color(i, colors[6].r, colors[6].g, colors[6].b);
|
||||
} else if (i == 74 || i == 84) {
|
||||
rgb_matrix_set_color(i, colors[7].r, colors[7].g, colors[7].b);
|
||||
} else if (i == 75 || i == 85) {
|
||||
rgb_matrix_set_color(i, colors[8].r, colors[8].g, colors[8].b);
|
||||
} else if (i == 76 || i == 86) {
|
||||
rgb_matrix_set_color(i, colors[9].r, colors[9].g, colors[9].b);
|
||||
}
|
||||
}
|
||||
else {
|
||||
rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
|
||||
}
|
||||
rgb_matrix_set_color(i, 0x00, 0x00, 0x00);
|
||||
}
|
||||
|
||||
for (uint8_t i = 67; i <= 76; i++) {
|
||||
rgb_matrix_set_color(i,
|
||||
colors[(current_color_index + (i - 67)) % NUM_COLORS].r,
|
||||
colors[(current_color_index + (i - 67)) % NUM_COLORS].g,
|
||||
colors[(current_color_index + (i - 67)) % NUM_COLORS].b);
|
||||
}
|
||||
|
||||
for (uint8_t i = 77; i <= 86; i++) {
|
||||
rgb_matrix_set_color(i,
|
||||
colors[(current_color_index + (i - 77)) % NUM_COLORS].r,
|
||||
colors[(current_color_index + (i - 77)) % NUM_COLORS].g,
|
||||
colors[(current_color_index + (i - 77)) % NUM_COLORS].b);
|
||||
}
|
||||
|
||||
return rgb_matrix_check_finished_leds(led_max);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue