diff options
| -rw-r--r-- | docs/feature_rgblight.md | 42 | ||||
| -rw-r--r-- | quantum/quantum.c | 52 | ||||
| -rw-r--r-- | quantum/quantum.h | 6 | ||||
| -rw-r--r-- | quantum/rgblight.c | 237 | ||||
| -rw-r--r-- | quantum/rgblight.h | 87 | ||||
| -rw-r--r-- | quantum/rgblight_reconfig.h | 36 | ||||
| -rw-r--r-- | tmk_core/common/avr/suspend.c | 1 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 1 |
8 files changed, 346 insertions, 116 deletions
diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md index d48941a04..925dca724 100644 --- a/docs/feature_rgblight.md +++ b/docs/feature_rgblight.md | |||
| @@ -79,20 +79,23 @@ Your RGB lighting can be configured by placing these `#define`s in your `config. | |||
| 79 | 79 | ||
| 80 | ## Animations | 80 | ## Animations |
| 81 | 81 | ||
| 82 | 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: | 82 | |
| 83 | 83 | Not only can this lighting be whatever color you want, | |
| 84 | |Mode |Description | | 84 | if `RGBLIGHT_EFFECT_xxxx` or `RGBLIGHT_ANIMATIONS` is defined, you also have a number of animation modes at your disposal: |
| 85 | |-----|---------------------| | 85 | |
| 86 | |1 |Solid color | | 86 | |Mode number symbol |Additional number |Description | |
| 87 | |2-5 |Solid color breathing| | 87 | |-----------------------------|-------------------|---------------------------------------| |
| 88 | |6-8 |Cycling rainbow | | 88 | |`RGBLIGHT_MODE_STATIC_LIGHT` | *None* |Solid color (this mode is always enabled) | |
| 89 | |9-14 |Swirling rainbow | | 89 | |`RGBLIGHT_MODE_BREATHING` | 0,1,2,3 |Solid color breathing | |
| 90 | |15-20|Snake | | 90 | |`RGBLIGHT_MODE_RAINBOW_MOOD` | 0,1,2 |Cycling rainbow | |
| 91 | |21-23|Knight | | 91 | |`RGBLIGHT_MODE_RAINBOW_SWIRL`| 0,1,2,3,4,5 |Swirling rainbow | |
| 92 | |24 |Christmas | | 92 | |`RGBLIGHT_MODE_SNAKE` | 0,1,2,3,4,5 |Snake | |
| 93 | |25-34|Static gradient | | 93 | |`RGBLIGHT_MODE_KNIGHT` | 0,1,2 |Knight | |
| 94 | |35 |RGB Test | | 94 | |`RGBLIGHT_MODE_CHRISTMAS` | *None* |Christmas | |
| 95 | |36 |Alternating | | 95 | |`RGBLIGHT_MODE_STATIC_GRADIENT`| 0,1,..,9 |Static gradient | |
| 96 | |`RGBLIGHT_MODE_RGB_TEST` | *None* |RGB Test | | ||
| 97 | |`RGBLIGHT_MODE_ALTERNATING` | *None* |Alternating | | ||
| 98 | |||
| 96 | 99 | ||
| 97 | Check out [this video](https://youtube.com/watch?v=VKrpPAHlisY) for a demonstration. | 100 | Check out [this video](https://youtube.com/watch?v=VKrpPAHlisY) for a demonstration. |
| 98 | 101 | ||
| @@ -100,7 +103,16 @@ The following options can be used to tweak the various animations: | |||
| 100 | 103 | ||
| 101 | |Define |Default |Description | | 104 | |Define |Default |Description | |
| 102 | |------------------------------------|-------------|-------------------------------------------------------------------------------------| | 105 | |------------------------------------|-------------|-------------------------------------------------------------------------------------| |
| 103 | |`RGBLIGHT_ANIMATIONS` |*Not defined*|If defined, enables additional animation modes | | 106 | |`RGBLIGHT_EFFECT_BREATHING` |*Not defined*|If defined, enable breathing animation mode. | |
| 107 | |`RGBLIGHT_EFFECT_RAINBOW_MOOD` |*Not defined*|If defined, enable rainbow mood animation mode. | | ||
| 108 | |`RGBLIGHT_EFFECT_RAINBOW_SWIRL` |*Not defined*|If defined, enable rainbow swirl animation mode. | | ||
| 109 | |`RGBLIGHT_EFFECT_SNAKE` |*Not defined*|If defined, enable snake animation mode. | | ||
| 110 | |`RGBLIGHT_EFFECT_KNIGHT` |*Not defined*|If defined, enable knight animation mode. | | ||
| 111 | |`RGBLIGHT_EFFECT_CHRISTMAS` |*Not defined*|If defined, enable christmas animation mode. | | ||
| 112 | |`RGBLIGHT_EFFECT_STATIC_GRADIENT` |*Not defined*|If defined, enable static gradient mode. | | ||
| 113 | |`RGBLIGHT_EFFECT_RGB_TEST` |*Not defined*|If defined, enable RGB test animation mode. | | ||
| 114 | |`RGBLIGHT_EFFECT_ALTERNATING` |*Not defined*|If defined, enable alternating animation mode. | | ||
| 115 | |`RGBLIGHT_ANIMATIONS` |*Not defined*|If defined, enables all additional animation modes | | ||
| 104 | |`RGBLIGHT_EFFECT_BREATHE_CENTER` |`1.85` |Used to calculate the curve for the breathing animation. Valid values are 1.0 to 2.7 | | 116 | |`RGBLIGHT_EFFECT_BREATHE_CENTER` |`1.85` |Used to calculate the curve for the breathing animation. Valid values are 1.0 to 2.7 | |
| 105 | |`RGBLIGHT_EFFECT_BREATHE_MAX` |`255` |The maximum brightness for the breathing mode. Valid values are 1 to 255 | | 117 | |`RGBLIGHT_EFFECT_BREATHE_MAX` |`255` |The maximum brightness for the breathing mode. Valid values are 1 to 255 | |
| 106 | |`RGBLIGHT_EFFECT_SNAKE_LENGTH` |`4` |The number of LEDs to light up for the "Snake" animation | | 118 | |`RGBLIGHT_EFFECT_SNAKE_LENGTH` |`4` |The number of LEDs to light up for the "Snake" animation | |
diff --git a/quantum/quantum.c b/quantum/quantum.c index ab47fa48f..9d352a94c 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -445,75 +445,97 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 445 | return false; | 445 | return false; |
| 446 | case RGB_MODE_PLAIN: | 446 | case RGB_MODE_PLAIN: |
| 447 | if (record->event.pressed) { | 447 | if (record->event.pressed) { |
| 448 | rgblight_mode(1); | 448 | rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); |
| 449 | #ifdef SPLIT_KEYBOARD | 449 | #ifdef SPLIT_KEYBOARD |
| 450 | RGB_DIRTY = true; | 450 | RGB_DIRTY = true; |
| 451 | #endif | 451 | #endif |
| 452 | } | 452 | } |
| 453 | return false; | 453 | return false; |
| 454 | case RGB_MODE_BREATHE: | 454 | case RGB_MODE_BREATHE: |
| 455 | #ifdef RGBLIGHT_EFFECT_BREATHING | ||
| 455 | if (record->event.pressed) { | 456 | if (record->event.pressed) { |
| 456 | if ((2 <= rgblight_get_mode()) && (rgblight_get_mode() < 5)) { | 457 | if ((RGBLIGHT_MODE_BREATHING <= rgblight_get_mode()) && |
| 458 | (rgblight_get_mode() < RGBLIGHT_MODE_BREATHING_end)) { | ||
| 457 | rgblight_step(); | 459 | rgblight_step(); |
| 458 | } else { | 460 | } else { |
| 459 | rgblight_mode(2); | 461 | rgblight_mode(RGBLIGHT_MODE_BREATHING); |
| 460 | } | 462 | } |
| 461 | } | 463 | } |
| 464 | #endif | ||
| 462 | return false; | 465 | return false; |
| 463 | case RGB_MODE_RAINBOW: | 466 | case RGB_MODE_RAINBOW: |
| 467 | #ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD | ||
| 464 | if (record->event.pressed) { | 468 | if (record->event.pressed) { |
| 465 | if ((6 <= rgblight_get_mode()) && (rgblight_get_mode() < 8)) { | 469 | if ((RGBLIGHT_MODE_RAINBOW_MOOD <= rgblight_get_mode()) && |
| 470 | (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_MOOD_end)) { | ||
| 466 | rgblight_step(); | 471 | rgblight_step(); |
| 467 | } else { | 472 | } else { |
| 468 | rgblight_mode(6); | 473 | rgblight_mode(RGBLIGHT_MODE_RAINBOW_MOOD); |
| 469 | } | 474 | } |
| 470 | } | 475 | } |
| 476 | #endif | ||
| 471 | return false; | 477 | return false; |
| 472 | case RGB_MODE_SWIRL: | 478 | case RGB_MODE_SWIRL: |
| 479 | #ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL | ||
| 473 | if (record->event.pressed) { | 480 | if (record->event.pressed) { |
| 474 | if ((9 <= rgblight_get_mode()) && (rgblight_get_mode() < 14)) { | 481 | if ((RGBLIGHT_MODE_RAINBOW_SWIRL <= rgblight_get_mode()) && |
| 482 | (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_SWIRL_end)) { | ||
| 475 | rgblight_step(); | 483 | rgblight_step(); |
| 476 | } else { | 484 | } else { |
| 477 | rgblight_mode(9); | 485 | rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL); |
| 478 | } | 486 | } |
| 479 | } | 487 | } |
| 488 | #endif | ||
| 480 | return false; | 489 | return false; |
| 481 | case RGB_MODE_SNAKE: | 490 | case RGB_MODE_SNAKE: |
| 491 | #ifdef RGBLIGHT_EFFECT_SNAKE | ||
| 482 | if (record->event.pressed) { | 492 | if (record->event.pressed) { |
| 483 | if ((15 <= rgblight_get_mode()) && (rgblight_get_mode() < 20)) { | 493 | if ((RGBLIGHT_MODE_SNAKE <= rgblight_get_mode()) && |
| 494 | (rgblight_get_mode() < RGBLIGHT_MODE_SNAKE_end)) { | ||
| 484 | rgblight_step(); | 495 | rgblight_step(); |
| 485 | } else { | 496 | } else { |
| 486 | rgblight_mode(15); | 497 | rgblight_mode(RGBLIGHT_MODE_SNAKE); |
| 487 | } | 498 | } |
| 488 | } | 499 | } |
| 500 | #endif | ||
| 489 | return false; | 501 | return false; |
| 490 | case RGB_MODE_KNIGHT: | 502 | case RGB_MODE_KNIGHT: |
| 503 | #ifdef RGBLIGHT_EFFECT_KNIGHT | ||
| 491 | if (record->event.pressed) { | 504 | if (record->event.pressed) { |
| 492 | if ((21 <= rgblight_get_mode()) && (rgblight_get_mode() < 23)) { | 505 | if ((RGBLIGHT_MODE_KNIGHT <= rgblight_get_mode()) && |
| 506 | (rgblight_get_mode() < RGBLIGHT_MODE_KNIGHT_end)) { | ||
| 493 | rgblight_step(); | 507 | rgblight_step(); |
| 494 | } else { | 508 | } else { |
| 495 | rgblight_mode(21); | 509 | rgblight_mode(RGBLIGHT_MODE_KNIGHT); |
| 496 | } | 510 | } |
| 497 | } | 511 | } |
| 512 | #endif | ||
| 498 | return false; | 513 | return false; |
| 499 | case RGB_MODE_XMAS: | 514 | case RGB_MODE_XMAS: |
| 515 | #ifdef RGBLIGHT_EFFECT_CHRISTMAS | ||
| 500 | if (record->event.pressed) { | 516 | if (record->event.pressed) { |
| 501 | rgblight_mode(24); | 517 | rgblight_mode(RGBLIGHT_MODE_CHRISTMAS); |
| 502 | } | 518 | } |
| 519 | #endif | ||
| 503 | return false; | 520 | return false; |
| 504 | case RGB_MODE_GRADIENT: | 521 | case RGB_MODE_GRADIENT: |
| 522 | #ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT | ||
| 505 | if (record->event.pressed) { | 523 | if (record->event.pressed) { |
| 506 | if ((25 <= rgblight_get_mode()) && (rgblight_get_mode() < 34)) { | 524 | if ((RGBLIGHT_MODE_STATIC_GRADIENT <= rgblight_get_mode()) && |
| 525 | (rgblight_get_mode() < RGBLIGHT_MODE_STATIC_GRADIENT_end)) { | ||
| 507 | rgblight_step(); | 526 | rgblight_step(); |
| 508 | } else { | 527 | } else { |
| 509 | rgblight_mode(25); | 528 | rgblight_mode(RGBLIGHT_MODE_STATIC_GRADIENT); |
| 510 | } | 529 | } |
| 511 | } | 530 | } |
| 531 | #endif | ||
| 512 | return false; | 532 | return false; |
| 513 | case RGB_MODE_RGBTEST: | 533 | case RGB_MODE_RGBTEST: |
| 534 | #ifdef RGBLIGHT_EFFECT_RGB_TEST | ||
| 514 | if (record->event.pressed) { | 535 | if (record->event.pressed) { |
| 515 | rgblight_mode(35); | 536 | rgblight_mode(RGBLIGHT_MODE_RGB_TEST); |
| 516 | } | 537 | } |
| 538 | #endif | ||
| 517 | return false; | 539 | return false; |
| 518 | #endif // defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) | 540 | #endif // defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) |
| 519 | #ifdef PROTOCOL_LUFA | 541 | #ifdef PROTOCOL_LUFA |
diff --git a/quantum/quantum.h b/quantum/quantum.h index b4e4de174..d1f761f17 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -32,6 +32,12 @@ | |||
| 32 | #endif | 32 | #endif |
| 33 | #ifdef RGBLIGHT_ENABLE | 33 | #ifdef RGBLIGHT_ENABLE |
| 34 | #include "rgblight.h" | 34 | #include "rgblight.h" |
| 35 | #else | ||
| 36 | #ifdef RGB_MATRIX_ENABLE | ||
| 37 | /* dummy define RGBLIGHT_MODE_xxxx */ | ||
| 38 | #define RGBLIGHT_H_DUMMY_DEFINE | ||
| 39 | #include "rgblight.h" | ||
| 40 | #endif | ||
| 35 | #endif | 41 | #endif |
| 36 | 42 | ||
| 37 | #ifdef SPLIT_KEYBOARD | 43 | #ifdef SPLIT_KEYBOARD |
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 4919ae4ab..03f77cc80 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #include <math.h> | 16 | #include <math.h> |
| 17 | #include <string.h> | ||
| 17 | #ifdef __AVR__ | 18 | #ifdef __AVR__ |
| 18 | #include <avr/eeprom.h> | 19 | #include <avr/eeprom.h> |
| 19 | #include <avr/interrupt.h> | 20 | #include <avr/interrupt.h> |
| @@ -29,23 +30,27 @@ | |||
| 29 | #define RGBLIGHT_LIMIT_VAL 255 | 30 | #define RGBLIGHT_LIMIT_VAL 255 |
| 30 | #endif | 31 | #endif |
| 31 | 32 | ||
| 33 | #define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_ ## sym, | ||
| 34 | #define _RGBM_SINGLE_DYNAMIC(sym) | ||
| 35 | #define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_ ## sym, | ||
| 36 | #define _RGBM_MULTI_DYNAMIC(sym) | ||
| 37 | #define _RGBM_TMP_STATIC(sym) RGBLIGHT_MODE_ ## sym, | ||
| 38 | #define _RGBM_TMP_DYNAMIC(sym) | ||
| 39 | static uint8_t static_effect_table [] = { | ||
| 40 | #include "rgblight.h" | ||
| 41 | }; | ||
| 42 | |||
| 43 | static inline int is_static_effect(uint8_t mode) { | ||
| 44 | return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL; | ||
| 45 | } | ||
| 46 | |||
| 32 | #define MIN(a,b) (((a)<(b))?(a):(b)) | 47 | #define MIN(a,b) (((a)<(b))?(a):(b)) |
| 33 | #define MAX(a,b) (((a)>(b))?(a):(b)) | 48 | #define MAX(a,b) (((a)>(b))?(a):(b)) |
| 34 | 49 | ||
| 35 | __attribute__ ((weak)) | 50 | #ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT |
| 36 | const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; | ||
| 37 | __attribute__ ((weak)) | ||
| 38 | const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {120, 60, 30}; | ||
| 39 | __attribute__ ((weak)) | ||
| 40 | const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20}; | ||
| 41 | __attribute__ ((weak)) | ||
| 42 | const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; | ||
| 43 | __attribute__ ((weak)) | ||
| 44 | const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31}; | ||
| 45 | __attribute__ ((weak)) | 51 | __attribute__ ((weak)) |
| 46 | const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; | 52 | const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; |
| 47 | __attribute__ ((weak)) | 53 | #endif |
| 48 | const uint16_t RGBLED_RGBTEST_INTERVALS[] PROGMEM = {1024}; | ||
| 49 | 54 | ||
| 50 | rgblight_config_t rgblight_config; | 55 | rgblight_config_t rgblight_config; |
| 51 | 56 | ||
| @@ -129,7 +134,7 @@ void eeconfig_update_rgblight(uint32_t val) { | |||
| 129 | void eeconfig_update_rgblight_default(void) { | 134 | void eeconfig_update_rgblight_default(void) { |
| 130 | //dprintf("eeconfig_update_rgblight_default\n"); | 135 | //dprintf("eeconfig_update_rgblight_default\n"); |
| 131 | rgblight_config.enable = 1; | 136 | rgblight_config.enable = 1; |
| 132 | rgblight_config.mode = 1; | 137 | rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT; |
| 133 | rgblight_config.hue = 0; | 138 | rgblight_config.hue = 0; |
| 134 | rgblight_config.sat = 255; | 139 | rgblight_config.sat = 255; |
| 135 | rgblight_config.val = RGBLIGHT_LIMIT_VAL; | 140 | rgblight_config.val = RGBLIGHT_LIMIT_VAL; |
| @@ -163,9 +168,9 @@ void rgblight_init(void) { | |||
| 163 | } | 168 | } |
| 164 | eeconfig_debug_rgblight(); // display current eeprom values | 169 | eeconfig_debug_rgblight(); // display current eeprom values |
| 165 | 170 | ||
| 166 | #ifdef RGBLIGHT_ANIMATIONS | 171 | #ifdef RGBLIGHT_USE_TIMER |
| 167 | rgblight_timer_init(); // setup the timer | 172 | rgblight_timer_init(); // setup the timer |
| 168 | #endif | 173 | #endif |
| 169 | 174 | ||
| 170 | if (rgblight_config.enable) { | 175 | if (rgblight_config.enable) { |
| 171 | rgblight_mode_noeeprom(rgblight_config.mode); | 176 | rgblight_mode_noeeprom(rgblight_config.mode); |
| @@ -178,9 +183,9 @@ void rgblight_update_dword(uint32_t dword) { | |||
| 178 | if (rgblight_config.enable) | 183 | if (rgblight_config.enable) |
| 179 | rgblight_mode(rgblight_config.mode); | 184 | rgblight_mode(rgblight_config.mode); |
| 180 | else { | 185 | else { |
| 181 | #ifdef RGBLIGHT_ANIMATIONS | 186 | #ifdef RGBLIGHT_USE_TIMER |
| 182 | rgblight_timer_disable(); | 187 | rgblight_timer_disable(); |
| 183 | #endif | 188 | #endif |
| 184 | rgblight_set(); | 189 | rgblight_set(); |
| 185 | } | 190 | } |
| 186 | } | 191 | } |
| @@ -195,7 +200,7 @@ void rgblight_increase(void) { | |||
| 195 | void rgblight_decrease(void) { | 200 | void rgblight_decrease(void) { |
| 196 | uint8_t mode = 0; | 201 | uint8_t mode = 0; |
| 197 | // Mode will never be < 1. If it ever is, eeprom needs to be initialized. | 202 | // Mode will never be < 1. If it ever is, eeprom needs to be initialized. |
| 198 | if (rgblight_config.mode > 1) { | 203 | if (rgblight_config.mode > RGBLIGHT_MODE_STATIC_LIGHT) { |
| 199 | mode = rgblight_config.mode - 1; | 204 | mode = rgblight_config.mode - 1; |
| 200 | } | 205 | } |
| 201 | rgblight_mode(mode); | 206 | rgblight_mode(mode); |
| @@ -229,8 +234,8 @@ void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { | |||
| 229 | if (!rgblight_config.enable) { | 234 | if (!rgblight_config.enable) { |
| 230 | return; | 235 | return; |
| 231 | } | 236 | } |
| 232 | if (mode < 1) { | 237 | if (mode < RGBLIGHT_MODE_STATIC_LIGHT) { |
| 233 | rgblight_config.mode = 1; | 238 | rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT; |
| 234 | } else if (mode > RGBLIGHT_MODES) { | 239 | } else if (mode > RGBLIGHT_MODES) { |
| 235 | rgblight_config.mode = RGBLIGHT_MODES; | 240 | rgblight_config.mode = RGBLIGHT_MODES; |
| 236 | } else { | 241 | } else { |
| @@ -242,30 +247,14 @@ void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { | |||
| 242 | } else { | 247 | } else { |
| 243 | xprintf("rgblight mode [NOEEPROM]: %u\n", rgblight_config.mode); | 248 | xprintf("rgblight mode [NOEEPROM]: %u\n", rgblight_config.mode); |
| 244 | } | 249 | } |
| 245 | if (rgblight_config.mode == 1) { | 250 | if( is_static_effect(rgblight_config.mode) ) { |
| 246 | #ifdef RGBLIGHT_ANIMATIONS | 251 | #ifdef RGBLIGHT_USE_TIMER |
| 247 | rgblight_timer_disable(); | 252 | rgblight_timer_disable(); |
| 248 | #endif | 253 | #endif |
| 249 | } else if ((rgblight_config.mode >= 2 && rgblight_config.mode <= 24) || | 254 | } else { |
| 250 | rgblight_config.mode == 35 || rgblight_config.mode == 36) { | 255 | #ifdef RGBLIGHT_USE_TIMER |
| 251 | // MODE 2-5, breathing | ||
| 252 | // MODE 6-8, rainbow mood | ||
| 253 | // MODE 9-14, rainbow swirl | ||
| 254 | // MODE 15-20, snake | ||
| 255 | // MODE 21-23, knight | ||
| 256 | // MODE 24, xmas | ||
| 257 | // MODE 35 RGB test | ||
| 258 | // MODE 36, alterating | ||
| 259 | |||
| 260 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 261 | rgblight_timer_enable(); | 256 | rgblight_timer_enable(); |
| 262 | #endif | 257 | #endif |
| 263 | } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) { | ||
| 264 | // MODE 25-34, static gradient | ||
| 265 | |||
| 266 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 267 | rgblight_timer_disable(); | ||
| 268 | #endif | ||
| 269 | } | 258 | } |
| 270 | rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | 259 | rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); |
| 271 | } | 260 | } |
| @@ -317,9 +306,9 @@ void rgblight_disable(void) { | |||
| 317 | rgblight_config.enable = 0; | 306 | rgblight_config.enable = 0; |
| 318 | eeconfig_update_rgblight(rgblight_config.raw); | 307 | eeconfig_update_rgblight(rgblight_config.raw); |
| 319 | xprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); | 308 | xprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); |
| 320 | #ifdef RGBLIGHT_ANIMATIONS | 309 | #ifdef RGBLIGHT_USE_TIMER |
| 321 | rgblight_timer_disable(); | 310 | rgblight_timer_disable(); |
| 322 | #endif | 311 | #endif |
| 323 | wait_ms(50); | 312 | wait_ms(50); |
| 324 | rgblight_set(); | 313 | rgblight_set(); |
| 325 | } | 314 | } |
| @@ -327,9 +316,9 @@ void rgblight_disable(void) { | |||
| 327 | void rgblight_disable_noeeprom(void) { | 316 | void rgblight_disable_noeeprom(void) { |
| 328 | rgblight_config.enable = 0; | 317 | rgblight_config.enable = 0; |
| 329 | xprintf("rgblight disable [noEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); | 318 | xprintf("rgblight disable [noEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); |
| 330 | #ifdef RGBLIGHT_ANIMATIONS | 319 | #ifdef RGBLIGHT_USE_TIMER |
| 331 | rgblight_timer_disable(); | 320 | rgblight_timer_disable(); |
| 332 | #endif | 321 | #endif |
| 333 | _delay_ms(50); | 322 | _delay_ms(50); |
| 334 | rgblight_set(); | 323 | rgblight_set(); |
| 335 | } | 324 | } |
| @@ -419,24 +408,43 @@ void rgblight_sethsv_noeeprom_old(uint16_t hue, uint8_t sat, uint8_t val) { | |||
| 419 | 408 | ||
| 420 | void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { | 409 | void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { |
| 421 | if (rgblight_config.enable) { | 410 | if (rgblight_config.enable) { |
| 422 | if (rgblight_config.mode == 1) { | 411 | if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) { |
| 423 | // same static color | 412 | // same static color |
| 424 | LED_TYPE tmp_led; | 413 | LED_TYPE tmp_led; |
| 425 | sethsv(hue, sat, val, &tmp_led); | 414 | sethsv(hue, sat, val, &tmp_led); |
| 426 | rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); | 415 | rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); |
| 427 | } else { | 416 | } else { |
| 428 | // all LEDs in same color | 417 | // all LEDs in same color |
| 429 | if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) { | 418 | if ( 1 == 0 ) { //dummy |
| 419 | } | ||
| 420 | #ifdef RGBLIGHT_EFFECT_BREATHING | ||
| 421 | else if (rgblight_config.mode >= RGBLIGHT_MODE_BREATHING && | ||
| 422 | rgblight_config.mode <= RGBLIGHT_MODE_BREATHING_end) { | ||
| 430 | // breathing mode, ignore the change of val, use in memory value instead | 423 | // breathing mode, ignore the change of val, use in memory value instead |
| 431 | val = rgblight_config.val; | 424 | val = rgblight_config.val; |
| 432 | } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) { | 425 | } |
| 433 | // rainbow mood and rainbow swirl, ignore the change of hue | 426 | #endif |
| 427 | #ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD | ||
| 428 | else if (rgblight_config.mode >= RGBLIGHT_MODE_RAINBOW_MOOD && | ||
| 429 | rgblight_config.mode <= RGBLIGHT_MODE_RAINBOW_MOOD_end) { | ||
| 430 | // rainbow mood, ignore the change of hue | ||
| 431 | hue = rgblight_config.hue; | ||
| 432 | } | ||
| 433 | #endif | ||
| 434 | #ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL | ||
| 435 | else if (rgblight_config.mode >= RGBLIGHT_MODE_RAINBOW_SWIRL && | ||
| 436 | rgblight_config.mode <= RGBLIGHT_MODE_RAINBOW_SWIRL_end) { | ||
| 437 | // rainbow swirl, ignore the change of hue | ||
| 434 | hue = rgblight_config.hue; | 438 | hue = rgblight_config.hue; |
| 435 | } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) { | 439 | } |
| 440 | #endif | ||
| 441 | #ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT | ||
| 442 | else if (rgblight_config.mode >= RGBLIGHT_MODE_STATIC_GRADIENT && | ||
| 443 | rgblight_config.mode <= RGBLIGHT_MODE_STATIC_GRADIENT_end) { | ||
| 436 | // static gradient | 444 | // static gradient |
| 437 | uint16_t _hue; | 445 | uint16_t _hue; |
| 438 | int8_t direction = ((rgblight_config.mode - 25) % 2) ? -1 : 1; | 446 | int8_t direction = ((rgblight_config.mode - RGBLIGHT_MODE_STATIC_GRADIENT) % 2) ? -1 : 1; |
| 439 | uint16_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[(rgblight_config.mode - 25) / 2]); | 447 | uint16_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[(rgblight_config.mode - RGBLIGHT_MODE_STATIC_GRADIENT) / 2]); |
| 440 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | 448 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { |
| 441 | _hue = (range / RGBLED_NUM * i * direction + hue + 360) % 360; | 449 | _hue = (range / RGBLED_NUM * i * direction + hue + 360) % 360; |
| 442 | dprintf("rgblight rainbow set hsv: %u,%u,%d,%u\n", i, _hue, direction, range); | 450 | dprintf("rgblight rainbow set hsv: %u,%u,%d,%u\n", i, _hue, direction, range); |
| @@ -444,6 +452,7 @@ void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool | |||
| 444 | } | 452 | } |
| 445 | rgblight_set(); | 453 | rgblight_set(); |
| 446 | } | 454 | } |
| 455 | #endif | ||
| 447 | } | 456 | } |
| 448 | rgblight_config.hue = hue; | 457 | rgblight_config.hue = hue; |
| 449 | rgblight_config.sat = sat; | 458 | rgblight_config.sat = sat; |
| @@ -528,7 +537,7 @@ void rgblight_set(void) { | |||
| 528 | } | 537 | } |
| 529 | #endif | 538 | #endif |
| 530 | 539 | ||
| 531 | #ifdef RGBLIGHT_ANIMATIONS | 540 | #ifdef RGBLIGHT_USE_TIMER |
| 532 | 541 | ||
| 533 | // Animation timer -- AVR Timer3 | 542 | // Animation timer -- AVR Timer3 |
| 534 | void rgblight_timer_init(void) { | 543 | void rgblight_timer_init(void) { |
| @@ -564,41 +573,77 @@ void rgblight_timer_toggle(void) { | |||
| 564 | 573 | ||
| 565 | void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b) { | 574 | void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b) { |
| 566 | rgblight_enable(); | 575 | rgblight_enable(); |
| 567 | rgblight_mode(1); | 576 | rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); |
| 568 | rgblight_setrgb(r, g, b); | 577 | rgblight_setrgb(r, g, b); |
| 569 | } | 578 | } |
| 570 | 579 | ||
| 571 | void rgblight_task(void) { | 580 | void rgblight_task(void) { |
| 572 | if (rgblight_timer_enabled) { | 581 | if (rgblight_timer_enabled) { |
| 573 | // mode = 1, static light, do nothing here | 582 | // static light mode, do nothing here |
| 574 | if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) { | 583 | if ( 1 == 0 ) { //dummy |
| 575 | // mode = 2 to 5, breathing mode | 584 | } |
| 576 | rgblight_effect_breathing(rgblight_config.mode - 2); | 585 | #ifdef RGBLIGHT_EFFECT_BREATHING |
| 577 | } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 8) { | 586 | else if (rgblight_config.mode >= RGBLIGHT_MODE_BREATHING && |
| 578 | // mode = 6 to 8, rainbow mood mod | 587 | rgblight_config.mode <= RGBLIGHT_MODE_BREATHING_end) { |
| 579 | rgblight_effect_rainbow_mood(rgblight_config.mode - 6); | 588 | // breathing mode |
| 580 | } else if (rgblight_config.mode >= 9 && rgblight_config.mode <= 14) { | 589 | rgblight_effect_breathing(rgblight_config.mode - RGBLIGHT_MODE_BREATHING ); |
| 581 | // mode = 9 to 14, rainbow swirl mode | 590 | } |
| 582 | rgblight_effect_rainbow_swirl(rgblight_config.mode - 9); | 591 | #endif |
| 583 | } else if (rgblight_config.mode >= 15 && rgblight_config.mode <= 20) { | 592 | #ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD |
| 584 | // mode = 15 to 20, snake mode | 593 | else if (rgblight_config.mode >= RGBLIGHT_MODE_RAINBOW_MOOD && |
| 585 | rgblight_effect_snake(rgblight_config.mode - 15); | 594 | rgblight_config.mode <= RGBLIGHT_MODE_RAINBOW_MOOD_end) { |
| 586 | } else if (rgblight_config.mode >= 21 && rgblight_config.mode <= 23) { | 595 | // rainbow mood mode |
| 587 | // mode = 21 to 23, knight mode | 596 | rgblight_effect_rainbow_mood(rgblight_config.mode - RGBLIGHT_MODE_RAINBOW_MOOD); |
| 588 | rgblight_effect_knight(rgblight_config.mode - 21); | 597 | } |
| 589 | } else if (rgblight_config.mode == 24) { | 598 | #endif |
| 590 | // mode = 24, christmas mode | 599 | #ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL |
| 600 | else if (rgblight_config.mode >= RGBLIGHT_MODE_RAINBOW_SWIRL && | ||
| 601 | rgblight_config.mode <= RGBLIGHT_MODE_RAINBOW_SWIRL_end) { | ||
| 602 | // rainbow swirl mode | ||
| 603 | rgblight_effect_rainbow_swirl(rgblight_config.mode - RGBLIGHT_MODE_RAINBOW_SWIRL); | ||
| 604 | } | ||
| 605 | #endif | ||
| 606 | #ifdef RGBLIGHT_EFFECT_SNAKE | ||
| 607 | else if (rgblight_config.mode >= RGBLIGHT_MODE_SNAKE && | ||
| 608 | rgblight_config.mode <= RGBLIGHT_MODE_SNAKE_end) { | ||
| 609 | // snake mode | ||
| 610 | rgblight_effect_snake(rgblight_config.mode - RGBLIGHT_MODE_SNAKE); | ||
| 611 | } | ||
| 612 | #endif | ||
| 613 | #ifdef RGBLIGHT_EFFECT_KNIGHT | ||
| 614 | else if (rgblight_config.mode >= RGBLIGHT_MODE_KNIGHT && | ||
| 615 | rgblight_config.mode <= RGBLIGHT_MODE_KNIGHT_end) { | ||
| 616 | // knight mode | ||
| 617 | rgblight_effect_knight(rgblight_config.mode - RGBLIGHT_MODE_KNIGHT); | ||
| 618 | } | ||
| 619 | #endif | ||
| 620 | #ifdef RGBLIGHT_EFFECT_CHRISTMAS | ||
| 621 | else if (rgblight_config.mode == RGBLIGHT_MODE_CHRISTMAS) { | ||
| 622 | // christmas mode | ||
| 591 | rgblight_effect_christmas(); | 623 | rgblight_effect_christmas(); |
| 592 | } else if (rgblight_config.mode == 35) { | 624 | } |
| 593 | // mode = 35, RGB test | 625 | #endif |
| 626 | #ifdef RGBLIGHT_EFFECT_RGB_TEST | ||
| 627 | else if (rgblight_config.mode == RGBLIGHT_MODE_RGB_TEST) { | ||
| 628 | // RGB test mode | ||
| 594 | rgblight_effect_rgbtest(); | 629 | rgblight_effect_rgbtest(); |
| 595 | } else if (rgblight_config.mode == 36){ | 630 | } |
| 631 | #endif | ||
| 632 | #ifdef RGBLIGHT_EFFECT_ALTERNATING | ||
| 633 | else if (rgblight_config.mode == RGBLIGHT_MODE_ALTERNATING){ | ||
| 596 | rgblight_effect_alternating(); | 634 | rgblight_effect_alternating(); |
| 597 | } | 635 | } |
| 636 | #endif | ||
| 598 | } | 637 | } |
| 599 | } | 638 | } |
| 600 | 639 | ||
| 640 | #endif /* RGBLIGHT_USE_TIMER */ | ||
| 641 | |||
| 601 | // Effects | 642 | // Effects |
| 643 | #ifdef RGBLIGHT_EFFECT_BREATHING | ||
| 644 | __attribute__ ((weak)) | ||
| 645 | const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; | ||
| 646 | |||
| 602 | void rgblight_effect_breathing(uint8_t interval) { | 647 | void rgblight_effect_breathing(uint8_t interval) { |
| 603 | static uint8_t pos = 0; | 648 | static uint8_t pos = 0; |
| 604 | static uint16_t last_timer = 0; | 649 | static uint16_t last_timer = 0; |
| @@ -609,12 +654,17 @@ void rgblight_effect_breathing(uint8_t interval) { | |||
| 609 | } | 654 | } |
| 610 | last_timer = timer_read(); | 655 | last_timer = timer_read(); |
| 611 | 656 | ||
| 612 | |||
| 613 | // http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ | 657 | // http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ |
| 614 | val = (exp(sin((pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E)); | 658 | val = (exp(sin((pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E)); |
| 615 | rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val); | 659 | rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val); |
| 616 | pos = (pos + 1) % 256; | 660 | pos = (pos + 1) % 256; |
| 617 | } | 661 | } |
| 662 | #endif | ||
| 663 | |||
| 664 | #ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD | ||
| 665 | __attribute__ ((weak)) | ||
| 666 | const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {120, 60, 30}; | ||
| 667 | |||
| 618 | void rgblight_effect_rainbow_mood(uint8_t interval) { | 668 | void rgblight_effect_rainbow_mood(uint8_t interval) { |
| 619 | static uint16_t current_hue = 0; | 669 | static uint16_t current_hue = 0; |
| 620 | static uint16_t last_timer = 0; | 670 | static uint16_t last_timer = 0; |
| @@ -626,6 +676,12 @@ void rgblight_effect_rainbow_mood(uint8_t interval) { | |||
| 626 | rgblight_sethsv_noeeprom_old(current_hue, rgblight_config.sat, rgblight_config.val); | 676 | rgblight_sethsv_noeeprom_old(current_hue, rgblight_config.sat, rgblight_config.val); |
| 627 | current_hue = (current_hue + 1) % 360; | 677 | current_hue = (current_hue + 1) % 360; |
| 628 | } | 678 | } |
| 679 | #endif | ||
| 680 | |||
| 681 | #ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL | ||
| 682 | __attribute__ ((weak)) | ||
| 683 | const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20}; | ||
| 684 | |||
| 629 | void rgblight_effect_rainbow_swirl(uint8_t interval) { | 685 | void rgblight_effect_rainbow_swirl(uint8_t interval) { |
| 630 | static uint16_t current_hue = 0; | 686 | static uint16_t current_hue = 0; |
| 631 | static uint16_t last_timer = 0; | 687 | static uint16_t last_timer = 0; |
| @@ -651,6 +707,12 @@ void rgblight_effect_rainbow_swirl(uint8_t interval) { | |||
| 651 | } | 707 | } |
| 652 | } | 708 | } |
| 653 | } | 709 | } |
| 710 | #endif | ||
| 711 | |||
| 712 | #ifdef RGBLIGHT_EFFECT_SNAKE | ||
| 713 | __attribute__ ((weak)) | ||
| 714 | const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; | ||
| 715 | |||
| 654 | void rgblight_effect_snake(uint8_t interval) { | 716 | void rgblight_effect_snake(uint8_t interval) { |
| 655 | static uint8_t pos = 0; | 717 | static uint8_t pos = 0; |
| 656 | static uint16_t last_timer = 0; | 718 | static uint16_t last_timer = 0; |
| @@ -689,6 +751,12 @@ void rgblight_effect_snake(uint8_t interval) { | |||
| 689 | pos = (pos + 1) % RGBLED_NUM; | 751 | pos = (pos + 1) % RGBLED_NUM; |
| 690 | } | 752 | } |
| 691 | } | 753 | } |
| 754 | #endif | ||
| 755 | |||
| 756 | #ifdef RGBLIGHT_EFFECT_KNIGHT | ||
| 757 | __attribute__ ((weak)) | ||
| 758 | const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31}; | ||
| 759 | |||
| 692 | void rgblight_effect_knight(uint8_t interval) { | 760 | void rgblight_effect_knight(uint8_t interval) { |
| 693 | static uint16_t last_timer = 0; | 761 | static uint16_t last_timer = 0; |
| 694 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_KNIGHT_INTERVALS[interval])) { | 762 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_KNIGHT_INTERVALS[interval])) { |
| @@ -730,8 +798,9 @@ void rgblight_effect_knight(uint8_t interval) { | |||
| 730 | increment = -increment; | 798 | increment = -increment; |
| 731 | } | 799 | } |
| 732 | } | 800 | } |
| 801 | #endif | ||
| 733 | 802 | ||
| 734 | 803 | #ifdef RGBLIGHT_EFFECT_CHRISTMAS | |
| 735 | void rgblight_effect_christmas(void) { | 804 | void rgblight_effect_christmas(void) { |
| 736 | static uint16_t current_offset = 0; | 805 | static uint16_t current_offset = 0; |
| 737 | static uint16_t last_timer = 0; | 806 | static uint16_t last_timer = 0; |
| @@ -748,6 +817,11 @@ void rgblight_effect_christmas(void) { | |||
| 748 | } | 817 | } |
| 749 | rgblight_set(); | 818 | rgblight_set(); |
| 750 | } | 819 | } |
| 820 | #endif | ||
| 821 | |||
| 822 | #ifdef RGBLIGHT_EFFECT_RGB_TEST | ||
| 823 | __attribute__ ((weak)) | ||
| 824 | const uint16_t RGBLED_RGBTEST_INTERVALS[] PROGMEM = {1024}; | ||
| 751 | 825 | ||
| 752 | void rgblight_effect_rgbtest(void) { | 826 | void rgblight_effect_rgbtest(void) { |
| 753 | static uint8_t pos = 0; | 827 | static uint8_t pos = 0; |
| @@ -774,7 +848,9 @@ void rgblight_effect_rgbtest(void) { | |||
| 774 | rgblight_setrgb(r, g, b); | 848 | rgblight_setrgb(r, g, b); |
| 775 | pos = (pos + 1) % 3; | 849 | pos = (pos + 1) % 3; |
| 776 | } | 850 | } |
| 851 | #endif | ||
| 777 | 852 | ||
| 853 | #ifdef RGBLIGHT_EFFECT_ALTERNATING | ||
| 778 | void rgblight_effect_alternating(void){ | 854 | void rgblight_effect_alternating(void){ |
| 779 | static uint16_t last_timer = 0; | 855 | static uint16_t last_timer = 0; |
| 780 | static uint16_t pos = 0; | 856 | static uint16_t pos = 0; |
| @@ -795,5 +871,4 @@ void rgblight_effect_alternating(void){ | |||
| 795 | rgblight_set(); | 871 | rgblight_set(); |
| 796 | pos = (pos + 1) % 2; | 872 | pos = (pos + 1) % 2; |
| 797 | } | 873 | } |
| 798 | 874 | #endif | |
| 799 | #endif /* RGBLIGHT_ANIMATIONS */ | ||
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index ba010dfae..d1e00eef3 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
| @@ -16,11 +16,23 @@ | |||
| 16 | #ifndef RGBLIGHT_H | 16 | #ifndef RGBLIGHT_H |
| 17 | #define RGBLIGHT_H | 17 | #define RGBLIGHT_H |
| 18 | 18 | ||
| 19 | #ifdef RGBLIGHT_ANIMATIONS | 19 | #include "rgblight_reconfig.h" |
| 20 | #define RGBLIGHT_MODES 36 | 20 | |
| 21 | #else | 21 | #define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_ ## sym, |
| 22 | #define RGBLIGHT_MODES 1 | 22 | #define _RGBM_SINGLE_DYNAMIC(sym) RGBLIGHT_MODE_ ## sym, |
| 23 | #endif | 23 | #define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_ ## sym, |
| 24 | #define _RGBM_MULTI_DYNAMIC(sym) RGBLIGHT_MODE_ ## sym, | ||
| 25 | #define _RGBM_TMP_STATIC(sym) RGBLIGHT_MODE_ ## sym, | ||
| 26 | #define _RGBM_TMP_DYNAMIC(sym) RGBLIGHT_MODE_ ## sym, | ||
| 27 | enum RGBLIGHT_EFFECT_MODE { | ||
| 28 | RGBLIGHT_MODE_zero = 0, | ||
| 29 | #include "rgblight.h" | ||
| 30 | RGBLIGHT_MODE_last | ||
| 31 | }; | ||
| 32 | |||
| 33 | #ifndef RGBLIGHT_H_DUMMY_DEFINE | ||
| 34 | |||
| 35 | #define RGBLIGHT_MODES (RGBLIGHT_MODE_last-1) | ||
| 24 | 36 | ||
| 25 | #ifndef RGBLIGHT_EFFECT_BREATHE_CENTER | 37 | #ifndef RGBLIGHT_EFFECT_BREATHE_CENTER |
| 26 | #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1-2.7 | 38 | #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1-2.7 |
| @@ -168,4 +180,69 @@ void rgblight_effect_christmas(void); | |||
| 168 | void rgblight_effect_rgbtest(void); | 180 | void rgblight_effect_rgbtest(void); |
| 169 | void rgblight_effect_alternating(void); | 181 | void rgblight_effect_alternating(void); |
| 170 | 182 | ||
| 183 | #endif // #ifndef RGBLIGHT_H_DUMMY_DEFINE | ||
| 184 | #endif // RGBLIGHT_H | ||
| 185 | |||
| 186 | #ifdef _RGBM_SINGLE_STATIC | ||
| 187 | _RGBM_SINGLE_STATIC( STATIC_LIGHT ) | ||
| 188 | #ifdef RGBLIGHT_EFFECT_BREATHING | ||
| 189 | _RGBM_MULTI_DYNAMIC( BREATHING ) | ||
| 190 | _RGBM_TMP_DYNAMIC( breathing_3 ) | ||
| 191 | _RGBM_TMP_DYNAMIC( breathing_4 ) | ||
| 192 | _RGBM_TMP_DYNAMIC( BREATHING_end ) | ||
| 193 | #endif | ||
| 194 | #ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD | ||
| 195 | _RGBM_MULTI_DYNAMIC( RAINBOW_MOOD ) | ||
| 196 | _RGBM_TMP_DYNAMIC( rainbow_mood_7 ) | ||
| 197 | _RGBM_TMP_DYNAMIC( RAINBOW_MOOD_end ) | ||
| 198 | #endif | ||
| 199 | #ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL | ||
| 200 | _RGBM_MULTI_DYNAMIC( RAINBOW_SWIRL ) | ||
| 201 | _RGBM_TMP_DYNAMIC( rainbow_swirl_10 ) | ||
| 202 | _RGBM_TMP_DYNAMIC( rainbow_swirl_11 ) | ||
| 203 | _RGBM_TMP_DYNAMIC( rainbow_swirl_12 ) | ||
| 204 | _RGBM_TMP_DYNAMIC( rainbow_swirl_13 ) | ||
| 205 | _RGBM_TMP_DYNAMIC( RAINBOW_SWIRL_end ) | ||
| 206 | #endif | ||
| 207 | #ifdef RGBLIGHT_EFFECT_SNAKE | ||
| 208 | _RGBM_MULTI_DYNAMIC( SNAKE ) | ||
| 209 | _RGBM_TMP_DYNAMIC( snake_16 ) | ||
| 210 | _RGBM_TMP_DYNAMIC( snake_17 ) | ||
| 211 | _RGBM_TMP_DYNAMIC( snake_18 ) | ||
| 212 | _RGBM_TMP_DYNAMIC( snake_19 ) | ||
| 213 | _RGBM_TMP_DYNAMIC( SNAKE_end ) | ||
| 214 | #endif | ||
| 215 | #ifdef RGBLIGHT_EFFECT_KNIGHT | ||
| 216 | _RGBM_MULTI_DYNAMIC( KNIGHT ) | ||
| 217 | _RGBM_TMP_DYNAMIC( knight_22 ) | ||
| 218 | _RGBM_TMP_DYNAMIC( KNIGHT_end ) | ||
| 219 | #endif | ||
| 220 | #ifdef RGBLIGHT_EFFECT_CHRISTMAS | ||
| 221 | _RGBM_SINGLE_DYNAMIC( CHRISTMAS ) | ||
| 222 | #endif | ||
| 223 | #ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT | ||
| 224 | _RGBM_MULTI_STATIC( STATIC_GRADIENT ) | ||
| 225 | _RGBM_TMP_STATIC( static_gradient_26 ) | ||
| 226 | _RGBM_TMP_STATIC( static_gradient_27 ) | ||
| 227 | _RGBM_TMP_STATIC( static_gradient_28 ) | ||
| 228 | _RGBM_TMP_STATIC( static_gradient_29 ) | ||
| 229 | _RGBM_TMP_STATIC( static_gradient_30 ) | ||
| 230 | _RGBM_TMP_STATIC( static_gradient_31 ) | ||
| 231 | _RGBM_TMP_STATIC( static_gradient_32 ) | ||
| 232 | _RGBM_TMP_STATIC( static_gradient_33 ) | ||
| 233 | _RGBM_TMP_STATIC( STATIC_GRADIENT_end ) | ||
| 234 | #endif | ||
| 235 | #ifdef RGBLIGHT_EFFECT_RGB_TEST | ||
| 236 | _RGBM_SINGLE_DYNAMIC( RGB_TEST ) | ||
| 237 | #endif | ||
| 238 | #ifdef RGBLIGHT_EFFECT_ALTERNATING | ||
| 239 | _RGBM_SINGLE_DYNAMIC( ALTERNATING ) | ||
| 240 | #endif | ||
| 171 | #endif | 241 | #endif |
| 242 | |||
| 243 | #undef _RGBM_SINGLE_STATIC | ||
| 244 | #undef _RGBM_SINGLE_DYNAMIC | ||
| 245 | #undef _RGBM_MULTI_STATIC | ||
| 246 | #undef _RGBM_MULTI_DYNAMIC | ||
| 247 | #undef _RGBM_TMP_STATIC | ||
| 248 | #undef _RGBM_TMP_DYNAMIC | ||
diff --git a/quantum/rgblight_reconfig.h b/quantum/rgblight_reconfig.h new file mode 100644 index 000000000..11bd4fd11 --- /dev/null +++ b/quantum/rgblight_reconfig.h | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | #ifndef RGBLIGHT_RECONFIG_H | ||
| 2 | #define RGBLIGHT_RECONFIG_H | ||
| 3 | |||
| 4 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 5 | // for backward compatibility | ||
| 6 | #define RGBLIGHT_EFFECT_BREATHING | ||
| 7 | #define RGBLIGHT_EFFECT_RAINBOW_MOOD | ||
| 8 | #define RGBLIGHT_EFFECT_RAINBOW_SWIRL | ||
| 9 | #define RGBLIGHT_EFFECT_SNAKE | ||
| 10 | #define RGBLIGHT_EFFECT_KNIGHT | ||
| 11 | #define RGBLIGHT_EFFECT_CHRISTMAS | ||
| 12 | #define RGBLIGHT_EFFECT_STATIC_GRADIENT | ||
| 13 | #define RGBLIGHT_EFFECT_RGB_TEST | ||
| 14 | #define RGBLIGHT_EFFECT_ALTERNATING | ||
| 15 | #endif | ||
| 16 | |||
| 17 | #ifdef RGBLIGHT_STATIC_PATTERNS | ||
| 18 | #define RGBLIGHT_EFFECT_STATIC_GRADIENT | ||
| 19 | #endif | ||
| 20 | |||
| 21 | // check dynamic animation effects chose ? | ||
| 22 | #if defined(RGBLIGHT_EFFECT_BREATHING) || \ | ||
| 23 | defined(RGBLIGHT_EFFECT_RAINBOW_MOOD) || \ | ||
| 24 | defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL) || \ | ||
| 25 | defined(RGBLIGHT_EFFECT_SNAKE) || \ | ||
| 26 | defined(RGBLIGHT_EFFECT_KNIGHT) || \ | ||
| 27 | defined(RGBLIGHT_EFFECT_CHRISTMAS) || \ | ||
| 28 | defined(RGBLIGHT_EFFECT_RGB_TEST) || \ | ||
| 29 | defined(RGBLIGHT_EFFECT_ALTERNATING) | ||
| 30 | #define RGBLIGHT_USE_TIMER | ||
| 31 | #ifndef RGBLIGHT_ANIMATIONS | ||
| 32 | #define RGBLIGHT_ANIMATIONS // for backward compatibility | ||
| 33 | #endif | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #endif // RGBLIGHT_RECONFIG_H | ||
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 73fdda6cc..d7a7f049c 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "timer.h" | 10 | #include "timer.h" |
| 11 | #include "led.h" | 11 | #include "led.h" |
| 12 | #include "host.h" | 12 | #include "host.h" |
| 13 | #include "rgblight_reconfig.h" | ||
| 13 | 14 | ||
| 14 | #ifdef PROTOCOL_LUFA | 15 | #ifdef PROTOCOL_LUFA |
| 15 | #include "lufa.h" | 16 | #include "lufa.h" |
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index cb918d3dc..95e0b95b2 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
| @@ -54,6 +54,7 @@ | |||
| 54 | #include "quantum.h" | 54 | #include "quantum.h" |
| 55 | #include <util/atomic.h> | 55 | #include <util/atomic.h> |
| 56 | #include "outputselect.h" | 56 | #include "outputselect.h" |
| 57 | #include "rgblight_reconfig.h" | ||
| 57 | 58 | ||
| 58 | #ifdef NKRO_ENABLE | 59 | #ifdef NKRO_ENABLE |
| 59 | #include "keycode_config.h" | 60 | #include "keycode_config.h" |
