diff options
| author | Ryan <fauxpark@gmail.com> | 2021-02-17 02:51:28 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-16 10:51:28 -0500 |
| commit | 53b96f685d3399e1281747b11a1194178089706c (patch) | |
| tree | bac3e0e884e5778b2fbab893fab2d31e17ab5aaa | |
| parent | 02b5bb9b17f90d0b741b3b7128e61ac747ab4d6c (diff) | |
| download | qmk_firmware-53b96f685d3399e1281747b11a1194178089706c.tar.gz qmk_firmware-53b96f685d3399e1281747b11a1194178089706c.zip | |
RGBLight: Allow configurable default settings (#11912)
* RGBLight: Allow configurable default settings
* Docs
| -rw-r--r-- | docs/feature_rgblight.md | 23 | ||||
| -rw-r--r-- | quantum/rgblight.c | 30 |
2 files changed, 39 insertions, 14 deletions
diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md index b5a2b179d..d2612a6d1 100644 --- a/docs/feature_rgblight.md +++ b/docs/feature_rgblight.md | |||
| @@ -82,15 +82,20 @@ Changing the **Value** sets the overall brightness.<br> | |||
| 82 | 82 | ||
| 83 | Your RGB lighting can be configured by placing these `#define`s in your `config.h`: | 83 | Your RGB lighting can be configured by placing these `#define`s in your `config.h`: |
| 84 | 84 | ||
| 85 | |Define |Default |Description | | 85 | |Define |Default |Description | |
| 86 | |---------------------|-------------|-----------------------------------------------------------------------------| | 86 | |---------------------------|----------------------------|---------------------------------------------------------------------------------------------------------------------------| |
| 87 | |`RGBLIGHT_HUE_STEP` |`10` |The number of steps to cycle through the hue by | | 87 | |`RGBLIGHT_HUE_STEP` |`10` |The number of steps to cycle through the hue by | |
| 88 | |`RGBLIGHT_SAT_STEP` |`17` |The number of steps to increment the saturation by | | 88 | |`RGBLIGHT_SAT_STEP` |`17` |The number of steps to increment the saturation by | |
| 89 | |`RGBLIGHT_VAL_STEP` |`17` |The number of steps to increment the brightness by | | 89 | |`RGBLIGHT_VAL_STEP` |`17` |The number of steps to increment the brightness by | |
| 90 | |`RGBLIGHT_LIMIT_VAL` |`255` |The maximum brightness level | | 90 | |`RGBLIGHT_LIMIT_VAL` |`255` |The maximum brightness level | |
| 91 | |`RGBLIGHT_SLEEP` |*Not defined*|If defined, the RGB lighting will be switched off when the host goes to sleep| | 91 | |`RGBLIGHT_SLEEP` |*Not defined* |If defined, the RGB lighting will be switched off when the host goes to sleep | |
| 92 | |`RGBLIGHT_SPLIT` |*Not defined*|If defined, synchronization functionality for split keyboards is added| | 92 | |`RGBLIGHT_SPLIT` |*Not defined* |If defined, synchronization functionality for split keyboards is added | |
| 93 | |`RGBLIGHT_DISABLE_KEYCODES`|*not defined*|If defined, disables the ability to control RGB Light from the keycodes. You must use code functions to control the feature| | 93 | |`RGBLIGHT_DISABLE_KEYCODES`|*Not defined* |If defined, disables the ability to control RGB Light from the keycodes. You must use code functions to control the feature| |
| 94 | |`RGBLIGHT_DEFAULT_MODE` |`RGBLIGHT_MODE_STATIC_LIGHT`|The default mode to use upon clearing the EEPROM | | ||
| 95 | |`RGBLIGHT_DEFAULT_HUE` |`0` (red) |The default hue to use upon clearing the EEPROM | | ||
| 96 | |`RGBLIGHT_DEFAULT_SAT` |`UINT8_MAX` (255) |The default saturation to use upon clearing the EEPROM | | ||
| 97 | |`RGBLIGHT_DEFAULT_VAL` |`RGBLIGHT_LIMIT_VAL` |The default value (brightness) to use upon clearing the EEPROM | | ||
| 98 | |`RGBLIGHT_DEFAULT_SPD` |`0` |The default speed to use upon clearing the EEPROM | | ||
| 94 | 99 | ||
| 95 | ## Effects and Animations | 100 | ## Effects and Animations |
| 96 | 101 | ||
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 7d7d015ba..904c02d6c 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -84,6 +84,26 @@ static uint8_t mode_base_table[] = { | |||
| 84 | #include "rgblight_modes.h" | 84 | #include "rgblight_modes.h" |
| 85 | }; | 85 | }; |
| 86 | 86 | ||
| 87 | #if !defined(RGBLIGHT_DEFAULT_MODE) | ||
| 88 | # define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_LIGHT | ||
| 89 | #endif | ||
| 90 | |||
| 91 | #if !defined(RGBLIGHT_DEFAULT_HUE) | ||
| 92 | # define RGBLIGHT_DEFAULT_HUE 0 | ||
| 93 | #endif | ||
| 94 | |||
| 95 | #if !defined(RGBLIGHT_DEFAULT_SAT) | ||
| 96 | # define RGBLIGHT_DEFAULT_SAT UINT8_MAX | ||
| 97 | #endif | ||
| 98 | |||
| 99 | #if !defined(RGBLIGHT_DEFAULT_VAL) | ||
| 100 | # define RGBLIGHT_DEFAULT_VAL RGBLIGHT_LIMIT_VAL | ||
| 101 | #endif | ||
| 102 | |||
| 103 | #if !defined(RGBLIGHT_DEFAULT_SPD) | ||
| 104 | # define RGBLIGHT_DEFAULT_SPD 0 | ||
| 105 | #endif | ||
| 106 | |||
| 87 | static inline int is_static_effect(uint8_t mode) { return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL; } | 107 | static inline int is_static_effect(uint8_t mode) { return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL; } |
| 88 | 108 | ||
| 89 | #ifdef RGBLIGHT_LED_MAP | 109 | #ifdef RGBLIGHT_LED_MAP |
| @@ -183,11 +203,11 @@ void eeconfig_update_rgblight_current(void) { eeconfig_update_rgblight(rgblight_ | |||
| 183 | 203 | ||
| 184 | void eeconfig_update_rgblight_default(void) { | 204 | void eeconfig_update_rgblight_default(void) { |
| 185 | rgblight_config.enable = 1; | 205 | rgblight_config.enable = 1; |
| 186 | rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT; | 206 | rgblight_config.mode = RGBLIGHT_DEFAULT_MODE; |
| 187 | rgblight_config.hue = 0; | 207 | rgblight_config.hue = RGBLIGHT_DEFAULT_HUE; |
| 188 | rgblight_config.sat = UINT8_MAX; | 208 | rgblight_config.sat = RGBLIGHT_DEFAULT_SAT; |
| 189 | rgblight_config.val = RGBLIGHT_LIMIT_VAL; | 209 | rgblight_config.val = RGBLIGHT_DEFAULT_VAL; |
| 190 | rgblight_config.speed = 0; | 210 | rgblight_config.speed = RGBLIGHT_DEFAULT_SPD; |
| 191 | RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; | 211 | RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; |
| 192 | eeconfig_update_rgblight(rgblight_config.raw); | 212 | eeconfig_update_rgblight(rgblight_config.raw); |
| 193 | } | 213 | } |
