rgblight.[ch] more configurable (#3582)

* add temporary test code rgblight-macro-test1.[ch]

* rgblight.h : mode auto numberring and auto generate mode name symbol

No change in build result.

* rgblight.c use RGBLIGHT_MODE_xxx symbols

No change in build result.

* quantum.c use RGBLIGHT_MODE_xxx symbols

No change in build result.

* fix build break. when RGB_MATRIX_ENABLE defined

* add temporary test code rgblight-macro-test2.[ch]

* modify rgblight_mode_eeprom_helper() and rgblight_sethsv_eeprom_helper()

* modify rgblight_task()

* configurable each effect compile on/off in config.h

* update docs/feature_rgblight.md

* fix conflict. docs/feature_rgblight.md

* remove temporary test code rgblight-macro-test*.[ch]

* fix comment typo.

* remove old mode number from comment

* update docs/feature_rgblight.md about effect mode

* Revert "update docs/feature_rgblight.md about effect mode"

This reverts commit 43890663fcc9dda1899df7a37d382fc38b1a6d6d.

* some change docs/feature_rgblight.md

* fix typo

* docs/feature_rgblight.md update: revise mode number table
This commit is contained in:
Takeshi ISHII
2018-09-14 02:24:10 +09:00
committed by skullydazed
parent ce122c4981
commit 6d6d91c834
8 changed files with 345 additions and 115 deletions

View File

@ -79,20 +79,23 @@ 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.
@ -100,7 +103,16 @@ The following options can be used to tweak the various animations:
|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 |

View File

@ -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

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -16,11 +16,23 @@
#ifndef RGBLIGHT_H
#define RGBLIGHT_H
#ifdef RGBLIGHT_ANIMATIONS
#define RGBLIGHT_MODES 36
#else
#define RGBLIGHT_MODES 1
#endif
#include "rgblight_reconfig.h"
#define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_ ## sym,
#define _RGBM_SINGLE_DYNAMIC(sym) RGBLIGHT_MODE_ ## sym,
#define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_ ## sym,
#define _RGBM_MULTI_DYNAMIC(sym) RGBLIGHT_MODE_ ## sym,
#define _RGBM_TMP_STATIC(sym) RGBLIGHT_MODE_ ## sym,
#define _RGBM_TMP_DYNAMIC(sym) RGBLIGHT_MODE_ ## sym,
enum RGBLIGHT_EFFECT_MODE {
RGBLIGHT_MODE_zero = 0,
#include "rgblight.h"
RGBLIGHT_MODE_last
};
#ifndef RGBLIGHT_H_DUMMY_DEFINE
#define RGBLIGHT_MODES (RGBLIGHT_MODE_last-1)
#ifndef RGBLIGHT_EFFECT_BREATHE_CENTER
#define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1-2.7
@ -168,4 +180,69 @@ void rgblight_effect_christmas(void);
void rgblight_effect_rgbtest(void);
void rgblight_effect_alternating(void);
#endif // #ifndef RGBLIGHT_H_DUMMY_DEFINE
#endif // RGBLIGHT_H
#ifdef _RGBM_SINGLE_STATIC
_RGBM_SINGLE_STATIC( STATIC_LIGHT )
#ifdef RGBLIGHT_EFFECT_BREATHING
_RGBM_MULTI_DYNAMIC( BREATHING )
_RGBM_TMP_DYNAMIC( breathing_3 )
_RGBM_TMP_DYNAMIC( breathing_4 )
_RGBM_TMP_DYNAMIC( BREATHING_end )
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
_RGBM_MULTI_DYNAMIC( RAINBOW_MOOD )
_RGBM_TMP_DYNAMIC( rainbow_mood_7 )
_RGBM_TMP_DYNAMIC( RAINBOW_MOOD_end )
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
_RGBM_MULTI_DYNAMIC( RAINBOW_SWIRL )
_RGBM_TMP_DYNAMIC( rainbow_swirl_10 )
_RGBM_TMP_DYNAMIC( rainbow_swirl_11 )
_RGBM_TMP_DYNAMIC( rainbow_swirl_12 )
_RGBM_TMP_DYNAMIC( rainbow_swirl_13 )
_RGBM_TMP_DYNAMIC( RAINBOW_SWIRL_end )
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
_RGBM_MULTI_DYNAMIC( SNAKE )
_RGBM_TMP_DYNAMIC( snake_16 )
_RGBM_TMP_DYNAMIC( snake_17 )
_RGBM_TMP_DYNAMIC( snake_18 )
_RGBM_TMP_DYNAMIC( snake_19 )
_RGBM_TMP_DYNAMIC( SNAKE_end )
#endif
#ifdef RGBLIGHT_EFFECT_KNIGHT
_RGBM_MULTI_DYNAMIC( KNIGHT )
_RGBM_TMP_DYNAMIC( knight_22 )
_RGBM_TMP_DYNAMIC( KNIGHT_end )
#endif
#ifdef RGBLIGHT_EFFECT_CHRISTMAS
_RGBM_SINGLE_DYNAMIC( CHRISTMAS )
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
_RGBM_MULTI_STATIC( STATIC_GRADIENT )
_RGBM_TMP_STATIC( static_gradient_26 )
_RGBM_TMP_STATIC( static_gradient_27 )
_RGBM_TMP_STATIC( static_gradient_28 )
_RGBM_TMP_STATIC( static_gradient_29 )
_RGBM_TMP_STATIC( static_gradient_30 )
_RGBM_TMP_STATIC( static_gradient_31 )
_RGBM_TMP_STATIC( static_gradient_32 )
_RGBM_TMP_STATIC( static_gradient_33 )
_RGBM_TMP_STATIC( STATIC_GRADIENT_end )
#endif
#ifdef RGBLIGHT_EFFECT_RGB_TEST
_RGBM_SINGLE_DYNAMIC( RGB_TEST )
#endif
#ifdef RGBLIGHT_EFFECT_ALTERNATING
_RGBM_SINGLE_DYNAMIC( ALTERNATING )
#endif
#endif
#undef _RGBM_SINGLE_STATIC
#undef _RGBM_SINGLE_DYNAMIC
#undef _RGBM_MULTI_STATIC
#undef _RGBM_MULTI_DYNAMIC
#undef _RGBM_TMP_STATIC
#undef _RGBM_TMP_DYNAMIC

View File

@ -0,0 +1,36 @@
#ifndef RGBLIGHT_RECONFIG_H
#define RGBLIGHT_RECONFIG_H
#ifdef RGBLIGHT_ANIMATIONS
// for backward compatibility
#define RGBLIGHT_EFFECT_BREATHING
#define RGBLIGHT_EFFECT_RAINBOW_MOOD
#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
#define RGBLIGHT_EFFECT_SNAKE
#define RGBLIGHT_EFFECT_KNIGHT
#define RGBLIGHT_EFFECT_CHRISTMAS
#define RGBLIGHT_EFFECT_STATIC_GRADIENT
#define RGBLIGHT_EFFECT_RGB_TEST
#define RGBLIGHT_EFFECT_ALTERNATING
#endif
#ifdef RGBLIGHT_STATIC_PATTERNS
#define RGBLIGHT_EFFECT_STATIC_GRADIENT
#endif
// check dynamic animation effects chose ?
#if defined(RGBLIGHT_EFFECT_BREATHING) || \
defined(RGBLIGHT_EFFECT_RAINBOW_MOOD) || \
defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL) || \
defined(RGBLIGHT_EFFECT_SNAKE) || \
defined(RGBLIGHT_EFFECT_KNIGHT) || \
defined(RGBLIGHT_EFFECT_CHRISTMAS) || \
defined(RGBLIGHT_EFFECT_RGB_TEST) || \
defined(RGBLIGHT_EFFECT_ALTERNATING)
#define RGBLIGHT_USE_TIMER
#ifndef RGBLIGHT_ANIMATIONS
#define RGBLIGHT_ANIMATIONS // for backward compatibility
#endif
#endif
#endif // RGBLIGHT_RECONFIG_H

View File

@ -10,6 +10,7 @@
#include "timer.h"
#include "led.h"
#include "host.h"
#include "rgblight_reconfig.h"
#ifdef PROTOCOL_LUFA
#include "lufa.h"

View File

@ -54,6 +54,7 @@
#include "quantum.h"
#include <util/atomic.h>
#include "outputselect.h"
#include "rgblight_reconfig.h"
#ifdef NKRO_ENABLE
#include "keycode_config.h"