Skip to content

Commit

Permalink
RGBLight: Allow configurable default settings (#11912)
Browse files Browse the repository at this point in the history
* RGBLight: Allow configurable default settings

* Docs
  • Loading branch information
fauxpark committed Feb 16, 2021
1 parent 02b5bb9 commit 53b96f6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
23 changes: 14 additions & 9 deletions docs/feature_rgblight.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,20 @@ Changing the **Value** sets the overall brightness.<br>

Your RGB lighting can be configured by placing these `#define`s in your `config.h`:

|Define |Default |Description |
|---------------------|-------------|-----------------------------------------------------------------------------|
|`RGBLIGHT_HUE_STEP` |`10` |The number of steps to cycle through the hue by |
|`RGBLIGHT_SAT_STEP` |`17` |The number of steps to increment the saturation by |
|`RGBLIGHT_VAL_STEP` |`17` |The number of steps to increment the brightness by |
|`RGBLIGHT_LIMIT_VAL` |`255` |The maximum brightness level |
|`RGBLIGHT_SLEEP` |*Not defined*|If defined, the RGB lighting will be switched off when the host goes to sleep|
|`RGBLIGHT_SPLIT` |*Not defined*|If defined, synchronization functionality for split keyboards is added|
|`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|
|Define |Default |Description |
|---------------------------|----------------------------|---------------------------------------------------------------------------------------------------------------------------|
|`RGBLIGHT_HUE_STEP` |`10` |The number of steps to cycle through the hue by |
|`RGBLIGHT_SAT_STEP` |`17` |The number of steps to increment the saturation by |
|`RGBLIGHT_VAL_STEP` |`17` |The number of steps to increment the brightness by |
|`RGBLIGHT_LIMIT_VAL` |`255` |The maximum brightness level |
|`RGBLIGHT_SLEEP` |*Not defined* |If defined, the RGB lighting will be switched off when the host goes to sleep |
|`RGBLIGHT_SPLIT` |*Not defined* |If defined, synchronization functionality for split keyboards is added |
|`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|
|`RGBLIGHT_DEFAULT_MODE` |`RGBLIGHT_MODE_STATIC_LIGHT`|The default mode to use upon clearing the EEPROM |
|`RGBLIGHT_DEFAULT_HUE` |`0` (red) |The default hue to use upon clearing the EEPROM |
|`RGBLIGHT_DEFAULT_SAT` |`UINT8_MAX` (255) |The default saturation to use upon clearing the EEPROM |
|`RGBLIGHT_DEFAULT_VAL` |`RGBLIGHT_LIMIT_VAL` |The default value (brightness) to use upon clearing the EEPROM |
|`RGBLIGHT_DEFAULT_SPD` |`0` |The default speed to use upon clearing the EEPROM |

## Effects and Animations

Expand Down
30 changes: 25 additions & 5 deletions quantum/rgblight.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@ static uint8_t mode_base_table[] = {
#include "rgblight_modes.h"
};

#if !defined(RGBLIGHT_DEFAULT_MODE)
# define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_LIGHT
#endif

#if !defined(RGBLIGHT_DEFAULT_HUE)
# define RGBLIGHT_DEFAULT_HUE 0
#endif

#if !defined(RGBLIGHT_DEFAULT_SAT)
# define RGBLIGHT_DEFAULT_SAT UINT8_MAX
#endif

#if !defined(RGBLIGHT_DEFAULT_VAL)
# define RGBLIGHT_DEFAULT_VAL RGBLIGHT_LIMIT_VAL
#endif

#if !defined(RGBLIGHT_DEFAULT_SPD)
# define RGBLIGHT_DEFAULT_SPD 0
#endif

static inline int is_static_effect(uint8_t mode) { return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL; }

#ifdef RGBLIGHT_LED_MAP
Expand Down Expand Up @@ -183,11 +203,11 @@ void eeconfig_update_rgblight_current(void) { eeconfig_update_rgblight(rgblight_

void eeconfig_update_rgblight_default(void) {
rgblight_config.enable = 1;
rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT;
rgblight_config.hue = 0;
rgblight_config.sat = UINT8_MAX;
rgblight_config.val = RGBLIGHT_LIMIT_VAL;
rgblight_config.speed = 0;
rgblight_config.mode = RGBLIGHT_DEFAULT_MODE;
rgblight_config.hue = RGBLIGHT_DEFAULT_HUE;
rgblight_config.sat = RGBLIGHT_DEFAULT_SAT;
rgblight_config.val = RGBLIGHT_DEFAULT_VAL;
rgblight_config.speed = RGBLIGHT_DEFAULT_SPD;
RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS;
eeconfig_update_rgblight(rgblight_config.raw);
}
Expand Down

0 comments on commit 53b96f6

Please sign in to comment.