Add {rgb|led}_matrix_get_mode_name(). (#25344)

This commit is contained in:
Nick Brassel 2025-06-07 22:56:58 +10:00 committed by GitHub
parent e3c8c23d91
commit 7808f8f56b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 164 additions and 96 deletions

View file

@ -214,9 +214,30 @@ led_matrix_mode(LED_MATRIX_CUSTOM_my_cool_effect);
For inspiration and examples, check out the built-in effects under `quantum/led_matrix/animations/`.
## Naming
If you wish to be able to use the name of an effect in your code -- say for a display indicator -- then you can enable the function `led_matrix_get_mode_name` in the following manner:
In your keymap's `config.h`:
```c
#define LED_MATRIX_MODE_NAME_ENABLE
```
In your `keymap.c`
```c
const char* effect_name = led_matrix_get_mode_name(led_matrix_get_mode());
// do something with `effect_name`, like `oled_write_ln(effect_name, false);`
```
::: info
`led_matrix_get_mode_name()` is not enabled by default as it increases the amount of flash memory used by the firmware based on the number of effects enabled.
:::
## Additional `config.h` Options {#additional-configh-options}
```c
#define LED_MATRIX_MODE_NAME_ENABLE // enables led_matrix_get_mode_name()
#define LED_MATRIX_KEYRELEASES // reactive effects respond to keyreleases (instead of keypresses)
#define LED_MATRIX_TIMEOUT 0 // number of milliseconds to wait until led automatically turns off
#define LED_MATRIX_SLEEP // turn off effects when suspended

View file

@ -365,9 +365,30 @@ These are shorthands to popular colors. The `RGB` ones can be passed to the `set
These are defined in [`color.h`](https://github.com/qmk/qmk_firmware/blob/master/quantum/color.h). Feel free to add to this list!
## Naming
If you wish to be able to use the name of an effect in your code -- say for a display indicator -- then you can enable the function `rgb_matrix_get_mode_name` in the following manner:
In your keymap's `config.h`:
```c
#define RGB_MATRIX_MODE_NAME_ENABLE
```
In your `keymap.c`
```c
const char* effect_name = rgb_matrix_get_mode_name(rgb_matrix_get_mode());
// do something with `effect_name`, like `oled_write_ln(effect_name, false);`
```
::: info
`rgb_matrix_get_mode_name()` is not enabled by default as it increases the amount of flash memory used by the firmware based on the number of effects enabled.
:::
## Additional `config.h` Options {#additional-configh-options}
```c
#define RGB_MATRIX_MODE_NAME_ENABLE // enables rgb_matrix_get_mode_name()
#define RGB_MATRIX_KEYRELEASES // reactive effects respond to keyreleases (instead of keypresses)
#define RGB_MATRIX_TIMEOUT 0 // number of milliseconds to wait until rgb automatically turns off
#define RGB_MATRIX_SLEEP // turn off effects when suspended