Allows disabling rgb effects in userspace (#4422)

* Allows disabling animations in user space

* Describe disabling effects in the docs

* Allows disabling individual reactive modes

* Adds the list ode defines
pull/4452/head
Florian Didron 6 years ago committed by Drashna Jaelre
parent de173e344e
commit 504bf11769

@ -151,6 +151,30 @@ These are the effects that are currently available:
RGB_MATRIX_EFFECT_MAX RGB_MATRIX_EFFECT_MAX
}; };
You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`:
|Define |Description |
|---------------------------------------------------|--------------------------------------------|
|`#define DISABLE_RGB_MATRIX_ALPHAS_MODS` |Disables `RGB_MATRIX_ALPHAS_MODS` |
|`#define DISABLE_RGB_MATRIX_DUAL_BEACON` |Disables `RGB_MATRIX_DUAL_BEACON` |
|`#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN` |Disables `RGB_MATRIX_GRADIENT_UP_DOWN` |
|`#define DISABLE_RGB_MATRIX_RAINDROPS` |Disables `RGB_MATRIX_RAINDROPS` |
|`#define DISABLE_RGB_MATRIX_CYCLE_ALL` |Disables `RGB_MATRIX_CYCLE_ALL` |
|`#define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT` |Disables `RGB_MATRIX_CYCLE_LEFT_RIGHT` |
|`#define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN` |Disables `RGB_MATRIX_CYCLE_UP_DOWN` |
|`#define DISABLE_RGB_MATRIX_RAINBOW_BEACON` |Disables `RGB_MATRIX_RAINBOW_BEACON` |
|`#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS` |Disables `RGB_MATRIX_RAINBOW_PINWHEELS` |
|`#define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON`|Disables `RGB_MATRIX_RAINBOW_MOVING_CHEVRON`|
|`#define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS` |Disables `RGB_MATRIX_JELLYBEAN_RAINDROPS` |
|`#define DISABLE_RGB_MATRIX_DIGITAL_RAIN` |Disables `RGB_MATRIX_DIGITAL_RAIN` |
|`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE` |Disables `RGB_MATRIX_SOLID_REACTIVE` |
|`#define DISABLE_RGB_MATRIX_SPLASH` |Disables `RGB_MATRIX_SPLASH` |
|`#define DISABLE_RGB_MATRIX_MULTISPLASH` |Disables `RGB_MATRIX_MULTISPLASH` |
|`#define DISABLE_RGB_MATRIX_SOLID_SPLASH` |Disables `RGB_MATRIX_SOLID_SPLASH` |
|`#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH` |Disables `RGB_MATRIX_SOLID_MULTISPLASH` |
## Custom layer effects ## Custom layer effects
Custom layer effects can be done by defining this in your `<keyboard>.c`: Custom layer effects can be done by defining this in your `<keyboard>.c`:

@ -55,6 +55,10 @@ rgb_config_t rgb_matrix_config;
#define RGB_DIGITAL_RAIN_DROPS 24 #define RGB_DIGITAL_RAIN_DROPS 24
#endif #endif
#if !defined(DISABLE_RGB_MATRIX_RAINDROPS) || !defined(DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS) || !defined(DISABLE_RGB_MATRIX_DIGITAL_RAIN)
#define TRACK_PREVIOUS_EFFECT
#endif
bool g_suspend_state = false; bool g_suspend_state = false;
// Global tick at 20 Hz // Global tick at 20 Hz
@ -79,7 +83,12 @@ void eeconfig_update_rgb_matrix(uint32_t val) {
void eeconfig_update_rgb_matrix_default(void) { void eeconfig_update_rgb_matrix_default(void) {
dprintf("eeconfig_update_rgb_matrix_default\n"); dprintf("eeconfig_update_rgb_matrix_default\n");
rgb_matrix_config.enable = 1; rgb_matrix_config.enable = 1;
#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
rgb_matrix_config.mode = RGB_MATRIX_CYCLE_LEFT_RIGHT; rgb_matrix_config.mode = RGB_MATRIX_CYCLE_LEFT_RIGHT;
#else
// fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace
rgb_matrix_config.mode = RGB_MATRIX_SOLID_COLOR;
#endif
rgb_matrix_config.hue = 0; rgb_matrix_config.hue = 0;
rgb_matrix_config.sat = 255; rgb_matrix_config.sat = 255;
rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS; rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
@ -618,11 +627,15 @@ void rgb_matrix_custom(void) {
} }
void rgb_matrix_task(void) { void rgb_matrix_task(void) {
#ifdef TRACK_PREVIOUS_EFFECT
static uint8_t toggle_enable_last = 255; static uint8_t toggle_enable_last = 255;
#endif
if (!rgb_matrix_config.enable) { if (!rgb_matrix_config.enable) {
rgb_matrix_all_off(); rgb_matrix_all_off();
rgb_matrix_indicators(); rgb_matrix_indicators();
#ifdef TRACK_PREVIOUS_EFFECT
toggle_enable_last = rgb_matrix_config.enable; toggle_enable_last = rgb_matrix_config.enable;
#endif
return; return;
} }
// delay 1 second before driving LEDs or doing anything else // delay 1 second before driving LEDs or doing anything else
@ -658,13 +671,16 @@ void rgb_matrix_task(void) {
(RGB_DISABLE_AFTER_TIMEOUT > 0 && g_any_key_hit > RGB_DISABLE_AFTER_TIMEOUT * 60 * 20)); (RGB_DISABLE_AFTER_TIMEOUT > 0 && g_any_key_hit > RGB_DISABLE_AFTER_TIMEOUT * 60 * 20));
uint8_t effect = suspend_backlight ? 0 : rgb_matrix_config.mode; uint8_t effect = suspend_backlight ? 0 : rgb_matrix_config.mode;
#ifdef TRACK_PREVIOUS_EFFECT
// Keep track of the effect used last time, // Keep track of the effect used last time,
// detect change in effect, so each effect can // detect change in effect, so each effect can
// have an optional initialization. // have an optional initialization.
static uint8_t effect_last = 255; static uint8_t effect_last = 255;
bool initialize = (effect != effect_last) || (rgb_matrix_config.enable != toggle_enable_last); bool initialize = (effect != effect_last) || (rgb_matrix_config.enable != toggle_enable_last);
effect_last = effect; effect_last = effect;
toggle_enable_last = rgb_matrix_config.enable; toggle_enable_last = rgb_matrix_config.enable;
#endif
// this gets ticked at 20 Hz. // this gets ticked at 20 Hz.
// each effect can opt to do calculations // each effect can opt to do calculations
@ -673,59 +689,93 @@ void rgb_matrix_task(void) {
case RGB_MATRIX_SOLID_COLOR: case RGB_MATRIX_SOLID_COLOR:
rgb_matrix_solid_color(); rgb_matrix_solid_color();
break; break;
#ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS
case RGB_MATRIX_ALPHAS_MODS: case RGB_MATRIX_ALPHAS_MODS:
rgb_matrix_alphas_mods(); rgb_matrix_alphas_mods();
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_DUAL_BEACON
case RGB_MATRIX_DUAL_BEACON: case RGB_MATRIX_DUAL_BEACON:
rgb_matrix_dual_beacon(); rgb_matrix_dual_beacon();
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
case RGB_MATRIX_GRADIENT_UP_DOWN: case RGB_MATRIX_GRADIENT_UP_DOWN:
rgb_matrix_gradient_up_down(); rgb_matrix_gradient_up_down();
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_RAINDROPS
case RGB_MATRIX_RAINDROPS: case RGB_MATRIX_RAINDROPS:
rgb_matrix_raindrops( initialize ); rgb_matrix_raindrops( initialize );
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
case RGB_MATRIX_CYCLE_ALL: case RGB_MATRIX_CYCLE_ALL:
rgb_matrix_cycle_all(); rgb_matrix_cycle_all();
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
case RGB_MATRIX_CYCLE_LEFT_RIGHT: case RGB_MATRIX_CYCLE_LEFT_RIGHT:
rgb_matrix_cycle_left_right(); rgb_matrix_cycle_left_right();
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
case RGB_MATRIX_CYCLE_UP_DOWN: case RGB_MATRIX_CYCLE_UP_DOWN:
rgb_matrix_cycle_up_down(); rgb_matrix_cycle_up_down();
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON
case RGB_MATRIX_RAINBOW_BEACON: case RGB_MATRIX_RAINBOW_BEACON:
rgb_matrix_rainbow_beacon(); rgb_matrix_rainbow_beacon();
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
case RGB_MATRIX_RAINBOW_PINWHEELS: case RGB_MATRIX_RAINBOW_PINWHEELS:
rgb_matrix_rainbow_pinwheels(); rgb_matrix_rainbow_pinwheels();
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
case RGB_MATRIX_RAINBOW_MOVING_CHEVRON: case RGB_MATRIX_RAINBOW_MOVING_CHEVRON:
rgb_matrix_rainbow_moving_chevron(); rgb_matrix_rainbow_moving_chevron();
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
case RGB_MATRIX_JELLYBEAN_RAINDROPS: case RGB_MATRIX_JELLYBEAN_RAINDROPS:
rgb_matrix_jellybean_raindrops( initialize ); rgb_matrix_jellybean_raindrops( initialize );
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN
case RGB_MATRIX_DIGITAL_RAIN: case RGB_MATRIX_DIGITAL_RAIN:
rgb_matrix_digital_rain( initialize ); rgb_matrix_digital_rain( initialize );
break; break;
#endif
#ifdef RGB_MATRIX_KEYPRESSES #ifdef RGB_MATRIX_KEYPRESSES
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE
case RGB_MATRIX_SOLID_REACTIVE: case RGB_MATRIX_SOLID_REACTIVE:
rgb_matrix_solid_reactive(); rgb_matrix_solid_reactive();
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_SPLASH
case RGB_MATRIX_SPLASH: case RGB_MATRIX_SPLASH:
rgb_matrix_splash(); rgb_matrix_splash();
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_MULTISPLASH
case RGB_MATRIX_MULTISPLASH: case RGB_MATRIX_MULTISPLASH:
rgb_matrix_multisplash(); rgb_matrix_multisplash();
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH
case RGB_MATRIX_SOLID_SPLASH: case RGB_MATRIX_SOLID_SPLASH:
rgb_matrix_solid_splash(); rgb_matrix_solid_splash();
break; break;
#endif
#ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
case RGB_MATRIX_SOLID_MULTISPLASH: case RGB_MATRIX_SOLID_MULTISPLASH:
rgb_matrix_solid_multisplash(); rgb_matrix_solid_multisplash();
break; break;
#endif #endif
#endif
default: default:
rgb_matrix_custom(); rgb_matrix_custom();
break; break;

@ -70,24 +70,58 @@ typedef union {
enum rgb_matrix_effects { enum rgb_matrix_effects {
RGB_MATRIX_SOLID_COLOR = 1, RGB_MATRIX_SOLID_COLOR = 1,
#ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS
RGB_MATRIX_ALPHAS_MODS, RGB_MATRIX_ALPHAS_MODS,
#endif
#ifndef DISABLE_RGB_MATRIX_DUAL_BEACON
RGB_MATRIX_DUAL_BEACON, RGB_MATRIX_DUAL_BEACON,
#endif
#ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
RGB_MATRIX_GRADIENT_UP_DOWN, RGB_MATRIX_GRADIENT_UP_DOWN,
#endif
#ifndef DISABLE_RGB_MATRIX_RAINDROPS
RGB_MATRIX_RAINDROPS, RGB_MATRIX_RAINDROPS,
#endif
#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
RGB_MATRIX_CYCLE_ALL, RGB_MATRIX_CYCLE_ALL,
#endif
#ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
RGB_MATRIX_CYCLE_LEFT_RIGHT, RGB_MATRIX_CYCLE_LEFT_RIGHT,
#endif
#ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
RGB_MATRIX_CYCLE_UP_DOWN, RGB_MATRIX_CYCLE_UP_DOWN,
#endif
#ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON
RGB_MATRIX_RAINBOW_BEACON, RGB_MATRIX_RAINBOW_BEACON,
#endif
#ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
RGB_MATRIX_RAINBOW_PINWHEELS, RGB_MATRIX_RAINBOW_PINWHEELS,
#endif
#ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
RGB_MATRIX_RAINBOW_MOVING_CHEVRON, RGB_MATRIX_RAINBOW_MOVING_CHEVRON,
#endif
#ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
RGB_MATRIX_JELLYBEAN_RAINDROPS, RGB_MATRIX_JELLYBEAN_RAINDROPS,
#endif
#ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN
RGB_MATRIX_DIGITAL_RAIN, RGB_MATRIX_DIGITAL_RAIN,
#endif
#ifdef RGB_MATRIX_KEYPRESSES #ifdef RGB_MATRIX_KEYPRESSES
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE
RGB_MATRIX_SOLID_REACTIVE, RGB_MATRIX_SOLID_REACTIVE,
#endif
#ifndef DISABLE_RGB_MATRIX_SPLASH
RGB_MATRIX_SPLASH, RGB_MATRIX_SPLASH,
#endif
#ifndef DISABLE_RGB_MATRIX_MULTISPLASH
RGB_MATRIX_MULTISPLASH, RGB_MATRIX_MULTISPLASH,
#endif
#ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH
RGB_MATRIX_SOLID_SPLASH, RGB_MATRIX_SOLID_SPLASH,
#endif
#ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
RGB_MATRIX_SOLID_MULTISPLASH, RGB_MATRIX_SOLID_MULTISPLASH,
#endif
#endif #endif
RGB_MATRIX_EFFECT_MAX RGB_MATRIX_EFFECT_MAX
}; };

Loading…
Cancel
Save