diff options
Diffstat (limited to 'docs/feature_rgb_matrix.md')
-rw-r--r-- | docs/feature_rgb_matrix.md | 57 |
1 files changed, 50 insertions, 7 deletions
diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md index f2168ab16..4ce9d15f0 100644 --- a/docs/feature_rgb_matrix.md +++ b/docs/feature_rgb_matrix.md | |||
@@ -177,7 +177,7 @@ enum rgb_matrix_effects { | |||
177 | RGB_MATRIX_GRADIENT_UP_DOWN, // Static gradient top to bottom, speed controls how much gradient changes | 177 | RGB_MATRIX_GRADIENT_UP_DOWN, // Static gradient top to bottom, speed controls how much gradient changes |
178 | RGB_MATRIX_BREATHING, // Single hue brightness cycling animation | 178 | RGB_MATRIX_BREATHING, // Single hue brightness cycling animation |
179 | RGB_MATRIX_CYCLE_ALL, // Full keyboard solid hue cycling through full gradient | 179 | RGB_MATRIX_CYCLE_ALL, // Full keyboard solid hue cycling through full gradient |
180 | RGB_MATRIX_CYCLE_LEFT_RIGHT, // Full gradient scrolling left to right | 180 | RGB_MATRIX_CYCLE_LEFT_RIGHT, // Full gradient scrolling left to right |
181 | RGB_MATRIX_CYCLE_UP_DOWN, // Full gradient scrolling top to bottom | 181 | RGB_MATRIX_CYCLE_UP_DOWN, // Full gradient scrolling top to bottom |
182 | RGB_MATRIX_RAINBOW_MOVING_CHEVRON, // Full gradent Chevron shapped scrolling left to right | 182 | RGB_MATRIX_RAINBOW_MOVING_CHEVRON, // Full gradent Chevron shapped scrolling left to right |
183 | RGB_MATRIX_DUAL_BEACON, // Full gradient spinning around center of keyboard | 183 | RGB_MATRIX_DUAL_BEACON, // Full gradient spinning around center of keyboard |
@@ -203,7 +203,7 @@ enum rgb_matrix_effects { | |||
203 | RGB_MATRIX_EFFECT_MAX | 203 | RGB_MATRIX_EFFECT_MAX |
204 | }; | 204 | }; |
205 | ``` | 205 | ``` |
206 | 206 | ||
207 | You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`: | 207 | You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`: |
208 | 208 | ||
209 | 209 | ||
@@ -236,17 +236,60 @@ You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `con | |||
236 | |`#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH` |Disables `RGB_MATRIX_SOLID_MULTISPLASH` | | 236 | |`#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH` |Disables `RGB_MATRIX_SOLID_MULTISPLASH` | |
237 | 237 | ||
238 | 238 | ||
239 | ## Custom layer effects | 239 | ## Custom RGB Matrix Effects |
240 | |||
241 | By setting `RGB_MATRIX_CUSTOM_USER` (and/or `RGB_MATRIX_CUSTOM_KB`) in `rule.mk`, new effects can be defined directly from userspace, without having to edit any QMK core files. | ||
242 | |||
243 | To declare new effects, create a new `rgb_matrix_user/kb.inc` that looks something like this: | ||
240 | 244 | ||
241 | Custom layer effects can be done by defining this in your `<keyboard>.c`: | 245 | `rgb_matrix_user.inc` should go in the root of the keymap directory. |
246 | `rgb_matrix_kb.inc` should go in the root of the keyboard directory. | ||
242 | 247 | ||
243 | ```C | 248 | ```C |
244 | void rgb_matrix_indicators_kb(void) { | 249 | // !!! DO NOT ADD #pragma once !!! // |
245 | rgb_matrix_set_color(index, red, green, blue); | 250 | |
251 | // Step 1. | ||
252 | // Declare custom effects using the RGB_MATRIX_EFFECT macro | ||
253 | // (note the lack of semicolon after the macro!) | ||
254 | RGB_MATRIX_EFFECT(my_cool_effect) | ||
255 | RGB_MATRIX_EFFECT(my_cool_effect2) | ||
256 | |||
257 | // Step 2. | ||
258 | // Define effects inside the `RGB_MATRIX_CUSTOM_EFFECT_IMPLS` ifdef block | ||
259 | #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
260 | |||
261 | // e.g: A simple effect, self-contained within a single method | ||
262 | static bool my_cool_effect(effect_params_t* params) { | ||
263 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
264 | for (uint8_t i = led_min; i < led_max; i++) { | ||
265 | rgb_matrix_set_color(i, 0xff, 0xff, 0x00); | ||
266 | } | ||
267 | return led_max < DRIVER_LED_TOTAL; | ||
268 | } | ||
269 | |||
270 | // e.g: A more complex effect, relying on external methods and state, with | ||
271 | // dedicated init and run methods | ||
272 | static uint8_t some_global_state; | ||
273 | static void my_cool_effect2_complex_init(effect_params_t* params) { | ||
274 | some_global_state = 1; | ||
246 | } | 275 | } |
276 | static bool my_cool_effect2_complex_run(effect_params_t* params) { | ||
277 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
278 | for (uint8_t i = led_min; i < led_max; i++) { | ||
279 | rgb_matrix_set_color(i, 0xff, some_global_state++, 0xff); | ||
280 | } | ||
281 | |||
282 | return led_max < DRIVER_LED_TOTAL; | ||
283 | } | ||
284 | static bool my_cool_effect2(effect_params_t* params) { | ||
285 | if (params->init) my_cool_effect2_complex_init(params); | ||
286 | return my_cool_effect2_complex_run(params); | ||
287 | } | ||
288 | |||
289 | #endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | ||
247 | ``` | 290 | ``` |
248 | 291 | ||
249 | A similar function works in the keymap as `rgb_matrix_indicators_user`. | 292 | For inspiration and examples, check out the built-in effects under `quantum/rgb_matrix_animation/` |
250 | 293 | ||
251 | 294 | ||
252 | ## Colors | 295 | ## Colors |