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

rgblight.[ch] more configurable #3582

Merged
merged 20 commits into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
42 changes: 27 additions & 15 deletions docs/feature_rgblight.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,40 @@ Your RGB lighting can be configured by placing these `#define`s in your `config.

## Animations

Not only can this lighting be whatever color you want, if `RGBLIGHT_ANIMATIONS` is defined, you also have a number of animation modes at your disposal:

|Mode |Description |
|-----|---------------------|
|1 |Solid color |
|2-5 |Solid color breathing|
|6-8 |Cycling rainbow |
|9-14 |Swirling rainbow |
|15-20|Snake |
|21-23|Knight |
|24 |Christmas |
|25-34|Static gradient |
|35 |RGB Test |
|36 |Alternating |

Not only can this lighting be whatever color you want,
if `RGBLIGHT_EFFECT_xxxx` or `RGBLIGHT_ANIMATIONS` is defined, you also have a number of animation modes at your disposal:

|Mode number symbol |Additional number |Description |
|-----------------------------|-------------------|---------------------------------------|
|`RGBLIGHT_MODE_STATIC_LIGHT` | *None* |Solid color (this mode is always enabled) |
|`RGBLIGHT_MODE_BREATHING` | 0,1,2,3 |Solid color breathing |
|`RGBLIGHT_MODE_RAINBOW_MOOD` | 0,1,2 |Cycling rainbow |
|`RGBLIGHT_MODE_RAINBOW_SWIRL`| 0,1,2,3,4,5 |Swirling rainbow |
|`RGBLIGHT_MODE_SNAKE` | 0,1,2,3,4,5 |Snake |
|`RGBLIGHT_MODE_KNIGHT` | 0,1,2 |Knight |
|`RGBLIGHT_MODE_CHRISTMAS` | *None* |Christmas |
|`RGBLIGHT_MODE_STATIC_GRADIENT`| 0,1,..,9 |Static gradient |
|`RGBLIGHT_MODE_RGB_TEST` | *None* |RGB Test |
|`RGBLIGHT_MODE_ALTERNATING` | *None* |Alternating |


Check out [this video](https://youtube.com/watch?v=VKrpPAHlisY) for a demonstration.

The following options can be used to tweak the various animations:
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be worth at least noting in the documentation that while most of the modes can now be disabled at compile time, it is not possible to disable the static solid color mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added '(this mode always enable)' to static color mode.
How about this?


|Define |Default |Description |
|------------------------------------|-------------|-------------------------------------------------------------------------------------|
|`RGBLIGHT_ANIMATIONS` |*Not defined*|If defined, enables additional animation modes |
|`RGBLIGHT_EFFECT_BREATHING` |*Not defined*|If defined, enable breathing animation mode. |
|`RGBLIGHT_EFFECT_RAINBOW_MOOD` |*Not defined*|If defined, enable rainbow mood animation mode. |
|`RGBLIGHT_EFFECT_RAINBOW_SWIRL` |*Not defined*|If defined, enable rainbow swirl animation mode. |
|`RGBLIGHT_EFFECT_SNAKE` |*Not defined*|If defined, enable snake animation mode. |
|`RGBLIGHT_EFFECT_KNIGHT` |*Not defined*|If defined, enable knight animation mode. |
|`RGBLIGHT_EFFECT_CHRISTMAS` |*Not defined*|If defined, enable christmas animation mode. |
|`RGBLIGHT_EFFECT_STATIC_GRADIENT` |*Not defined*|If defined, enable static gradient mode. |
|`RGBLIGHT_EFFECT_RGB_TEST` |*Not defined*|If defined, enable RGB test animation mode. |
|`RGBLIGHT_EFFECT_ALTERNATING` |*Not defined*|If defined, enable alternating animation mode. |
|`RGBLIGHT_ANIMATIONS` |*Not defined*|If defined, enables all additional animation modes |
|`RGBLIGHT_EFFECT_BREATHE_CENTER` |`1.85` |Used to calculate the curve for the breathing animation. Valid values are 1.0 to 2.7 |
|`RGBLIGHT_EFFECT_BREATHE_MAX` |`255` |The maximum brightness for the breathing mode. Valid values are 1 to 255 |
|`RGBLIGHT_EFFECT_SNAKE_LENGTH` |`4` |The number of LEDs to light up for the "Snake" animation |
Expand Down
52 changes: 37 additions & 15 deletions quantum/quantum.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,75 +445,97 @@ bool process_record_quantum(keyrecord_t *record) {
return false;
case RGB_MODE_PLAIN:
if (record->event.pressed) {
rgblight_mode(1);
rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
#ifdef SPLIT_KEYBOARD
RGB_DIRTY = true;
#endif
}
return false;
case RGB_MODE_BREATHE:
#ifdef RGBLIGHT_EFFECT_BREATHING
if (record->event.pressed) {
if ((2 <= rgblight_get_mode()) && (rgblight_get_mode() < 5)) {
if ((RGBLIGHT_MODE_BREATHING <= rgblight_get_mode()) &&
(rgblight_get_mode() < RGBLIGHT_MODE_BREATHING_end)) {
rgblight_step();
} else {
rgblight_mode(2);
rgblight_mode(RGBLIGHT_MODE_BREATHING);
}
}
#endif
return false;
case RGB_MODE_RAINBOW:
#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
if (record->event.pressed) {
if ((6 <= rgblight_get_mode()) && (rgblight_get_mode() < 8)) {
if ((RGBLIGHT_MODE_RAINBOW_MOOD <= rgblight_get_mode()) &&
(rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_MOOD_end)) {
rgblight_step();
} else {
rgblight_mode(6);
rgblight_mode(RGBLIGHT_MODE_RAINBOW_MOOD);
}
}
#endif
return false;
case RGB_MODE_SWIRL:
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
if (record->event.pressed) {
if ((9 <= rgblight_get_mode()) && (rgblight_get_mode() < 14)) {
if ((RGBLIGHT_MODE_RAINBOW_SWIRL <= rgblight_get_mode()) &&
(rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_SWIRL_end)) {
rgblight_step();
} else {
rgblight_mode(9);
rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL);
}
}
#endif
return false;
case RGB_MODE_SNAKE:
#ifdef RGBLIGHT_EFFECT_SNAKE
if (record->event.pressed) {
if ((15 <= rgblight_get_mode()) && (rgblight_get_mode() < 20)) {
if ((RGBLIGHT_MODE_SNAKE <= rgblight_get_mode()) &&
(rgblight_get_mode() < RGBLIGHT_MODE_SNAKE_end)) {
rgblight_step();
} else {
rgblight_mode(15);
rgblight_mode(RGBLIGHT_MODE_SNAKE);
}
}
#endif
return false;
case RGB_MODE_KNIGHT:
#ifdef RGBLIGHT_EFFECT_KNIGHT
if (record->event.pressed) {
if ((21 <= rgblight_get_mode()) && (rgblight_get_mode() < 23)) {
if ((RGBLIGHT_MODE_KNIGHT <= rgblight_get_mode()) &&
(rgblight_get_mode() < RGBLIGHT_MODE_KNIGHT_end)) {
rgblight_step();
} else {
rgblight_mode(21);
rgblight_mode(RGBLIGHT_MODE_KNIGHT);
}
}
#endif
return false;
case RGB_MODE_XMAS:
#ifdef RGBLIGHT_EFFECT_CHRISTMAS
if (record->event.pressed) {
rgblight_mode(24);
rgblight_mode(RGBLIGHT_MODE_CHRISTMAS);
}
#endif
return false;
case RGB_MODE_GRADIENT:
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
if (record->event.pressed) {
if ((25 <= rgblight_get_mode()) && (rgblight_get_mode() < 34)) {
if ((RGBLIGHT_MODE_STATIC_GRADIENT <= rgblight_get_mode()) &&
(rgblight_get_mode() < RGBLIGHT_MODE_STATIC_GRADIENT_end)) {
rgblight_step();
} else {
rgblight_mode(25);
rgblight_mode(RGBLIGHT_MODE_STATIC_GRADIENT);
}
}
#endif
return false;
case RGB_MODE_RGBTEST:
#ifdef RGBLIGHT_EFFECT_RGB_TEST
if (record->event.pressed) {
rgblight_mode(35);
rgblight_mode(RGBLIGHT_MODE_RGB_TEST);
}
#endif
return false;
#endif // defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
#ifdef PROTOCOL_LUFA
Expand Down
6 changes: 6 additions & 0 deletions quantum/quantum.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
#endif
#ifdef RGBLIGHT_ENABLE
#include "rgblight.h"
#else
#ifdef RGB_MATRIX_ENABLE
/* dummy define RGBLIGHT_MODE_xxxx */
#define RGBLIGHT_H_DUMMY_DEFINE
#include "rgblight.h"
#endif
#endif

#ifdef SPLIT_KEYBOARD
Expand Down
Loading