diff options
| author | Joshua Diamond <josh@windowoffire.com> | 2020-06-01 05:02:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-01 11:02:28 +0200 |
| commit | e2e287ec5f720839efd8f7cecf447763433cda27 (patch) | |
| tree | fba21d51c2a44c3c088872ce940c2d0e48b3fa45 | |
| parent | dfcd4f0d25bb3db8798ad8bb06da0fab68e7cf25 (diff) | |
| download | qmk_firmware-e2e287ec5f720839efd8f7cecf447763433cda27.tar.gz qmk_firmware-e2e287ec5f720839efd8f7cecf447763433cda27.zip | |
Option to allow lighting layers when RGB Lighting is off (#9051)
| -rw-r--r-- | docs/config_options.md | 2 | ||||
| -rw-r--r-- | docs/feature_rgblight.md | 4 | ||||
| -rw-r--r-- | quantum/rgblight.c | 24 |
3 files changed, 24 insertions, 6 deletions
diff --git a/docs/config_options.md b/docs/config_options.md index b96079e60..ab26fd46c 100644 --- a/docs/config_options.md +++ b/docs/config_options.md | |||
| @@ -197,6 +197,8 @@ If you define these options you will enable the associated feature, which may in | |||
| 197 | * Note: Increasing the maximum will increase the firmware size and slow sync on split keyboards. | 197 | * Note: Increasing the maximum will increase the firmware size and slow sync on split keyboards. |
| 198 | * `#define RGBLIGHT_LAYER_BLINK` | 198 | * `#define RGBLIGHT_LAYER_BLINK` |
| 199 | * Adds ability to [blink](feature_rgblight.md?id=lighting-layer-blink) a lighting layer for a specified number of milliseconds (e.g. to acknowledge an action). | 199 | * Adds ability to [blink](feature_rgblight.md?id=lighting-layer-blink) a lighting layer for a specified number of milliseconds (e.g. to acknowledge an action). |
| 200 | * `#define RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF` | ||
| 201 | * If defined, then [lighting layers](feature_rgblight?id=overriding-rgb-lighting-onoff-status) will be shown even if RGB Light is off. | ||
| 200 | * `#define RGBLED_NUM 12` | 202 | * `#define RGBLED_NUM 12` |
| 201 | * number of LEDs | 203 | * number of LEDs |
| 202 | * `#define RGBLIGHT_SPLIT` | 204 | * `#define RGBLIGHT_SPLIT` |
diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md index 7f5c8a36c..5921e9941 100644 --- a/docs/feature_rgblight.md +++ b/docs/feature_rgblight.md | |||
| @@ -278,6 +278,10 @@ void post_process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 278 | } | 278 | } |
| 279 | ``` | 279 | ``` |
| 280 | 280 | ||
| 281 | ### Overriding RGB Lighting on/off status | ||
| 282 | |||
| 283 | Normally lighting layers are not shown when RGB Lighting is disabled (e.g. with `RGB_TOG` keycode). If you would like lighting layers to work even when the RGB Lighting is otherwise off, add `#define RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF` to your `config.h`. | ||
| 284 | |||
| 281 | ## Functions | 285 | ## Functions |
| 282 | 286 | ||
| 283 | If you need to change your RGB lighting in code, for example in a macro to change the color whenever you switch layers, QMK provides a set of functions to assist you. See [`rgblight.h`](https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight.h) for the full list, but the most commonly used functions include: | 287 | If you need to change your RGB lighting in code, for example in a macro to change the color whenever you switch layers, QMK provides a set of functions to assist you. See [`rgblight.h`](https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight.h) for the full list, but the most commonly used functions include: |
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 73a7afd7b..949dd79fe 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -628,6 +628,13 @@ void rgblight_set_layer_state(uint8_t layer, bool enabled) { | |||
| 628 | if (rgblight_status.timer_enabled == false) { | 628 | if (rgblight_status.timer_enabled == false) { |
| 629 | rgblight_mode_noeeprom(rgblight_config.mode); | 629 | rgblight_mode_noeeprom(rgblight_config.mode); |
| 630 | } | 630 | } |
| 631 | |||
| 632 | # ifdef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF | ||
| 633 | // If not enabled, then nothing else will actually set the LEDs... | ||
| 634 | if (!rgblight_config.enable) { | ||
| 635 | rgblight_set(); | ||
| 636 | } | ||
| 637 | # endif | ||
| 631 | } | 638 | } |
| 632 | 639 | ||
| 633 | bool rgblight_get_layer_state(uint8_t layer) { | 640 | bool rgblight_get_layer_state(uint8_t layer) { |
| @@ -693,16 +700,11 @@ void rgblight_unblink_layers(void) { | |||
| 693 | __attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { ws2812_setleds(start_led, num_leds); } | 700 | __attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { ws2812_setleds(start_led, num_leds); } |
| 694 | 701 | ||
| 695 | #ifndef RGBLIGHT_CUSTOM_DRIVER | 702 | #ifndef RGBLIGHT_CUSTOM_DRIVER |
| 703 | |||
| 696 | void rgblight_set(void) { | 704 | void rgblight_set(void) { |
| 697 | LED_TYPE *start_led; | 705 | LED_TYPE *start_led; |
| 698 | uint8_t num_leds = rgblight_ranges.clipping_num_leds; | 706 | uint8_t num_leds = rgblight_ranges.clipping_num_leds; |
| 699 | 707 | ||
| 700 | # ifdef RGBLIGHT_LAYERS | ||
| 701 | if (rgblight_layers != NULL) { | ||
| 702 | rgblight_layers_write(); | ||
| 703 | } | ||
| 704 | # endif | ||
| 705 | |||
| 706 | if (!rgblight_config.enable) { | 708 | if (!rgblight_config.enable) { |
| 707 | for (uint8_t i = rgblight_ranges.effect_start_pos; i < rgblight_ranges.effect_end_pos; i++) { | 709 | for (uint8_t i = rgblight_ranges.effect_start_pos; i < rgblight_ranges.effect_end_pos; i++) { |
| 708 | led[i].r = 0; | 710 | led[i].r = 0; |
| @@ -714,6 +716,16 @@ void rgblight_set(void) { | |||
| 714 | } | 716 | } |
| 715 | } | 717 | } |
| 716 | 718 | ||
| 719 | # ifdef RGBLIGHT_LAYERS | ||
| 720 | if (rgblight_layers != NULL | ||
| 721 | # ifndef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF | ||
| 722 | && rgblight_config.enable | ||
| 723 | # endif | ||
| 724 | ) { | ||
| 725 | rgblight_layers_write(); | ||
| 726 | } | ||
| 727 | # endif | ||
| 728 | |||
| 717 | # ifdef RGBLIGHT_LED_MAP | 729 | # ifdef RGBLIGHT_LED_MAP |
| 718 | LED_TYPE led0[RGBLED_NUM]; | 730 | LED_TYPE led0[RGBLED_NUM]; |
| 719 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | 731 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { |
