Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows disabling rgb effects in userspace #4422

Merged
merged 5 commits into from
Nov 18, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/feature_rgb_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ These are the effects that are currently available:
#endif
RGB_MATRIX_EFFECT_MAX
};

You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`:

```
// to disable alphas mods
#define DISABLE_RGB_MATRIX_ALPHAS_MODS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last thing.... if you could list all of the modes?

Not necessarily in this block, but add a table that lists ALL of them, for reference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure @drashna , added a table that lists all the defines

```

## Custom layer effects

Expand Down
138 changes: 89 additions & 49 deletions quantum/rgb_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ rgb_config_t rgb_matrix_config;
#define RGB_DIGITAL_RAIN_DROPS 24
#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;

// Global tick at 20 Hz
Expand All @@ -79,7 +83,12 @@ void eeconfig_update_rgb_matrix(uint32_t val) {
void eeconfig_update_rgb_matrix_default(void) {
dprintf("eeconfig_update_rgb_matrix_default\n");
rgb_matrix_config.enable = 1;
#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
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.sat = 255;
rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
Expand Down Expand Up @@ -499,7 +508,7 @@ void rgb_matrix_digital_rain( const bool initialize ) {
map_row_column_to_led(row, col, &led, &led_count);

if (map[col][row] > pure_green_intensity) {
const uint8_t boost = (uint8_t) ((uint16_t) max_brightness_boost
const uint8_t boost = (uint8_t) ((uint16_t) max_brightness_boost
* (map[col][row] - pure_green_intensity) / (max_intensity - pure_green_intensity));
rgb_matrix_set_color(led, boost, max_intensity, boost);
}
Expand Down Expand Up @@ -618,12 +627,16 @@ void rgb_matrix_custom(void) {
}

void rgb_matrix_task(void) {
static uint8_t toggle_enable_last = 255;
#ifdef TRACK_PREVIOUS_EFFECT
static uint8_t toggle_enable_last = 255;
#endif
if (!rgb_matrix_config.enable) {
rgb_matrix_all_off();
rgb_matrix_indicators();
toggle_enable_last = rgb_matrix_config.enable;
return;
rgb_matrix_all_off();
rgb_matrix_indicators();
#ifdef TRACK_PREVIOUS_EFFECT
toggle_enable_last = rgb_matrix_config.enable;
#endif
return;
}
// delay 1 second before driving LEDs or doing anything else
static uint8_t startup_tick = 0;
Expand Down Expand Up @@ -658,13 +671,16 @@ void rgb_matrix_task(void) {
(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;

// Keep track of the effect used last time,
// detect change in effect, so each effect can
// have an optional initialization.
static uint8_t effect_last = 255;
bool initialize = (effect != effect_last) || (rgb_matrix_config.enable != toggle_enable_last);
effect_last = effect;
toggle_enable_last = rgb_matrix_config.enable;
#ifdef TRACK_PREVIOUS_EFFECT
// Keep track of the effect used last time,
// detect change in effect, so each effect can
// have an optional initialization.

static uint8_t effect_last = 255;
bool initialize = (effect != effect_last) || (rgb_matrix_config.enable != toggle_enable_last);
effect_last = effect;
toggle_enable_last = rgb_matrix_config.enable;
#endif

// this gets ticked at 20 Hz.
// each effect can opt to do calculations
Expand All @@ -673,42 +689,66 @@ void rgb_matrix_task(void) {
case RGB_MATRIX_SOLID_COLOR:
rgb_matrix_solid_color();
break;
case RGB_MATRIX_ALPHAS_MODS:
rgb_matrix_alphas_mods();
break;
case RGB_MATRIX_DUAL_BEACON:
rgb_matrix_dual_beacon();
break;
case RGB_MATRIX_GRADIENT_UP_DOWN:
rgb_matrix_gradient_up_down();
break;
case RGB_MATRIX_RAINDROPS:
rgb_matrix_raindrops( initialize );
break;
case RGB_MATRIX_CYCLE_ALL:
rgb_matrix_cycle_all();
break;
case RGB_MATRIX_CYCLE_LEFT_RIGHT:
rgb_matrix_cycle_left_right();
break;
case RGB_MATRIX_CYCLE_UP_DOWN:
rgb_matrix_cycle_up_down();
break;
case RGB_MATRIX_RAINBOW_BEACON:
rgb_matrix_rainbow_beacon();
break;
case RGB_MATRIX_RAINBOW_PINWHEELS:
rgb_matrix_rainbow_pinwheels();
break;
case RGB_MATRIX_RAINBOW_MOVING_CHEVRON:
rgb_matrix_rainbow_moving_chevron();
break;
case RGB_MATRIX_JELLYBEAN_RAINDROPS:
rgb_matrix_jellybean_raindrops( initialize );
break;
case RGB_MATRIX_DIGITAL_RAIN:
rgb_matrix_digital_rain( initialize );
break;
#ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS
case RGB_MATRIX_ALPHAS_MODS:
rgb_matrix_alphas_mods();
break;
#endif
#ifndef DISABLE_RGB_MATRIX_DUAL_BEACON
case RGB_MATRIX_DUAL_BEACON:
rgb_matrix_dual_beacon();
break;
#endif
#ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
case RGB_MATRIX_GRADIENT_UP_DOWN:
rgb_matrix_gradient_up_down();
break;
#endif
#ifndef DISABLE_RGB_MATRIX_RAINDROPS
case RGB_MATRIX_RAINDROPS:
rgb_matrix_raindrops( initialize );
break;
#endif
#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
case RGB_MATRIX_CYCLE_ALL:
rgb_matrix_cycle_all();
break;
#endif
#ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
case RGB_MATRIX_CYCLE_LEFT_RIGHT:
rgb_matrix_cycle_left_right();
break;
#endif
#ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
case RGB_MATRIX_CYCLE_UP_DOWN:
rgb_matrix_cycle_up_down();
break;
#endif
#ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON
case RGB_MATRIX_RAINBOW_BEACON:
rgb_matrix_rainbow_beacon();
break;
#endif
#ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
case RGB_MATRIX_RAINBOW_PINWHEELS:
rgb_matrix_rainbow_pinwheels();
break;
#endif
#ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
case RGB_MATRIX_RAINBOW_MOVING_CHEVRON:
rgb_matrix_rainbow_moving_chevron();
break;
#endif
#ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
case RGB_MATRIX_JELLYBEAN_RAINDROPS:
rgb_matrix_jellybean_raindrops( initialize );
break;
#endif
#ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN
case RGB_MATRIX_DIGITAL_RAIN:
rgb_matrix_digital_rain( initialize );
break;
#endif
#ifdef RGB_MATRIX_KEYPRESSES
case RGB_MATRIX_SOLID_REACTIVE:
rgb_matrix_solid_reactive();
Expand Down
24 changes: 24 additions & 0 deletions quantum/rgb_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,42 @@ typedef union {

enum rgb_matrix_effects {
RGB_MATRIX_SOLID_COLOR = 1,
#ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS
RGB_MATRIX_ALPHAS_MODS,
#endif
#ifndef DISABLE_RGB_MATRIX_DUAL_BEACON
RGB_MATRIX_DUAL_BEACON,
#endif
#ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
RGB_MATRIX_GRADIENT_UP_DOWN,
#endif
#ifndef DISABLE_RGB_MATRIX_RAINDROPS
RGB_MATRIX_RAINDROPS,
#endif
#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
RGB_MATRIX_CYCLE_ALL,
#endif
#ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
RGB_MATRIX_CYCLE_LEFT_RIGHT,
#endif
#ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
RGB_MATRIX_CYCLE_UP_DOWN,
#endif
#ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON
RGB_MATRIX_RAINBOW_BEACON,
#endif
#ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
RGB_MATRIX_RAINBOW_PINWHEELS,
#endif
#ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
RGB_MATRIX_RAINBOW_MOVING_CHEVRON,
#endif
#ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
RGB_MATRIX_JELLYBEAN_RAINDROPS,
#endif
#ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN
RGB_MATRIX_DIGITAL_RAIN,
#endif
#ifdef RGB_MATRIX_KEYPRESSES
drashna marked this conversation as resolved.
Show resolved Hide resolved
RGB_MATRIX_SOLID_REACTIVE,
RGB_MATRIX_SPLASH,
Expand Down