-
Notifications
You must be signed in to change notification settings - Fork 5
/
rgb_matrix_user.inc
150 lines (120 loc) · 4.34 KB
/
rgb_matrix_user.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
RGB_MATRIX_EFFECT(outrun_sunset)
RGB_MATRIX_EFFECT(game_fps)
RGB_MATRIX_EFFECT(game_moba)
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#ifndef LED_FLAG_KEYS
#define LED_FLAG_KEYS (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER)
#endif
static bool outrun_sunset(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
// Blank out the colors on initialization.
if (params->init) {
rgb_matrix_set_color_all(0, 0, 0);
}
// Define border gradient colors. Colors are packed in GRB order.
HSV border_start_hsv = { 253, 250, 252 };
HSV border_end_hsv = { 177, 250, 255 };
// RGB border_start_color = { 10, 252, 26 };
// RGB border_end_color = { 5, 104, 242 };
for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS();
HSV hsv = rgb_matrix_config.hsv;
if (i >= 19 && i < 23) {
hsv.h = 34;
hsv.s = 0.98f * hsv.s; //166;
hsv.v = 1.0f * hsv.v;
} else if (i >= 33 && i < 39) {
hsv.h = 13;
hsv.s = 0.9f * hsv.s; //145;
hsv.v = 0.98f * hsv.v; //245;
} else if (i >= 46 && i < 53) {
hsv.h = 247;
hsv.s = 0.87f * hsv.s; //163;
hsv.v = 0.95f * hsv.v; //237;
} else if (i >= 60 && i < 63) {
hsv.h = 239;
hsv.s = 0.92f * hsv.s; //199;
hsv.v = 0.89f * hsv.v; //227;
} else {
hsv.h = 187;
hsv.s = 0.67f * hsv.s; //130;
hsv.v = 0.27f * hsv.v; //69;
}
RGB rgb;
if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) {
border_start_hsv.v = 0.98f * rgb_matrix_config.hsv.v;
border_end_hsv.v = 1.0f * rgb_matrix_config.hsv.v;
RGB border_start_color = hsv_to_rgb(border_start_hsv);
RGB border_end_color = hsv_to_rgb(border_end_hsv);
// Calculate border gradient color at current height.
uint8_t frac = 255.0f * (g_led_config.point[i].y / 64.0f);
rgb.r = blend8(border_start_color.r, border_end_color.r, frac);
rgb.g = blend8(border_start_color.g, border_end_color.g, frac);
rgb.b = blend8(border_start_color.b, border_end_color.b, frac);
} else {
// Otherwise convert HSV to RGB.
rgb = hsv_to_rgb(hsv);
}
// Finally set the color.
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
return rgb_matrix_check_finished_leds(led_max);
}
// First-person shooter mode. Lights up WASD keys
static bool game_fps(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
HSV bg_hsv = rgb_matrix_config.hsv;
HSV wasd_hsv = rgb_matrix_config.hsv;
wasd_hsv.h += rgb_matrix_config.speed;
RGB wasd_rgb = hsv_to_rgb(wasd_hsv);
// Blank out the colors on initialization.
if (params->init) {
rgb_matrix_set_color_all(0, 0, 0);
}
for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS();
// Dim background by 50% to make WASD keys stand out more
if (HAS_ANY_FLAGS(g_led_config.flags[i], LED_FLAG_KEYS)) {
bg_hsv.v = rgb_matrix_config.hsv.v / 2;
} else {
bg_hsv.v = rgb_matrix_config.hsv.v;
}
RGB bg_rgb = hsv_to_rgb(bg_hsv);
rgb_matrix_set_color(i, bg_rgb.r, bg_rgb.g, bg_rgb.b);
// Indices: 17, 31, 32, 33 = W, A, S, D on Drop ALT
// See: config_led.c
if (i == 17 || (i >= 31 && i < 34)) {
rgb_matrix_set_color(i, wasd_rgb.r, wasd_rgb.g, wasd_rgb.b);
}
}
return rgb_matrix_check_finished_leds(led_max);
}
// MOBA mode (LoL, HotS). Lights up QWERDF keys.
static bool game_moba(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
HSV bg_hsv = rgb_matrix_config.hsv;
HSV ability_hsv = rgb_matrix_config.hsv;
ability_hsv.h += rgb_matrix_config.speed;
RGB ability_rgb = hsv_to_rgb(ability_hsv);
// Blank out the colors on initialization.
if (params->init) {
rgb_matrix_set_color_all(0, 0, 0);
}
for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS();
// Dim background by 50% to make the action keys stand out more
if (HAS_ANY_FLAGS(g_led_config.flags[i], LED_FLAG_KEYS)) {
bg_hsv.v = rgb_matrix_config.hsv.v / 2;
} else {
bg_hsv.v = rgb_matrix_config.hsv.v;
}
RGB bg_rgb = hsv_to_rgb(bg_hsv);
rgb_matrix_set_color(i, bg_rgb.r, bg_rgb.g, bg_rgb.b);
// QWERDF keys
if ((i >= 16 && i < 20) || (i >= 33 && i < 35)) {
rgb_matrix_set_color(i, ability_rgb.r, ability_rgb.g, ability_rgb.b);
}
}
return rgb_matrix_check_finished_leds(led_max);
}
#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS