diff options
| author | Joshua Diamond <josh@windowoffire.com> | 2021-01-11 03:07:09 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-11 00:07:09 -0800 |
| commit | 4d96b85b6f39e89bdcc74853958f91153f27bfc1 (patch) | |
| tree | 55bec712ab1e48867c68809aed89988e0d7c5a8f /quantum/rgblight.c | |
| parent | d877f40b7076ed1594aef61aff7940793b896403 (diff) | |
| download | qmk_firmware-4d96b85b6f39e89bdcc74853958f91153f27bfc1.tar.gz qmk_firmware-4d96b85b6f39e89bdcc74853958f91153f27bfc1.zip | |
Lighting Layers should be disabled when suspended (#11442)
* Lighting Layers should be disabled when suspended
* bugfixes
Diffstat (limited to 'quantum/rgblight.c')
| -rw-r--r-- | quantum/rgblight.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index beeef6568..d856f6d6c 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -95,6 +95,11 @@ rgblight_config_t rgblight_config; | |||
| 95 | rgblight_status_t rgblight_status = {.timer_enabled = false}; | 95 | rgblight_status_t rgblight_status = {.timer_enabled = false}; |
| 96 | bool is_rgblight_initialized = false; | 96 | bool is_rgblight_initialized = false; |
| 97 | 97 | ||
| 98 | #ifdef RGBLIGHT_SLEEP | ||
| 99 | static bool is_suspended; | ||
| 100 | static bool pre_suspend_enabled; | ||
| 101 | #endif | ||
| 102 | |||
| 98 | #ifdef RGBLIGHT_USE_TIMER | 103 | #ifdef RGBLIGHT_USE_TIMER |
| 99 | animation_status_t animation_status = {}; | 104 | animation_status_t animation_status = {}; |
| 100 | #endif | 105 | #endif |
| @@ -708,6 +713,42 @@ void rgblight_unblink_layers(void) { | |||
| 708 | 713 | ||
| 709 | #endif | 714 | #endif |
| 710 | 715 | ||
| 716 | #ifdef RGBLIGHT_SLEEP | ||
| 717 | |||
| 718 | void rgblight_suspend(void) { | ||
| 719 | rgblight_timer_disable(); | ||
| 720 | if (!is_suspended) { | ||
| 721 | is_suspended = true; | ||
| 722 | pre_suspend_enabled = rgblight_config.enable; | ||
| 723 | |||
| 724 | # ifdef RGBLIGHT_LAYER_BLINK | ||
| 725 | // make sure any layer blinks don't come back after suspend | ||
| 726 | rgblight_status.enabled_layer_mask &= ~_blinked_layer_mask; | ||
| 727 | _blinked_layer_mask = 0; | ||
| 728 | # endif | ||
| 729 | |||
| 730 | rgblight_disable_noeeprom(); | ||
| 731 | } | ||
| 732 | } | ||
| 733 | |||
| 734 | void rgblight_wakeup(void) { | ||
| 735 | is_suspended = false; | ||
| 736 | |||
| 737 | if (pre_suspend_enabled) { | ||
| 738 | rgblight_enable_noeeprom(); | ||
| 739 | } | ||
| 740 | # ifdef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF | ||
| 741 | // Need this or else the LEDs won't be set | ||
| 742 | else if (rgblight_status.enabled_layer_mask != 0) { | ||
| 743 | rgblight_set(); | ||
| 744 | } | ||
| 745 | # endif | ||
| 746 | |||
| 747 | rgblight_timer_enable(); | ||
| 748 | } | ||
| 749 | |||
| 750 | #endif | ||
| 751 | |||
| 711 | __attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { ws2812_setleds(start_led, num_leds); } | 752 | __attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { ws2812_setleds(start_led, num_leds); } |
| 712 | 753 | ||
| 713 | #ifndef RGBLIGHT_CUSTOM_DRIVER | 754 | #ifndef RGBLIGHT_CUSTOM_DRIVER |
| @@ -729,8 +770,10 @@ void rgblight_set(void) { | |||
| 729 | 770 | ||
| 730 | # ifdef RGBLIGHT_LAYERS | 771 | # ifdef RGBLIGHT_LAYERS |
| 731 | if (rgblight_layers != NULL | 772 | if (rgblight_layers != NULL |
| 732 | # ifndef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF | 773 | # if !defined(RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF) |
| 733 | && rgblight_config.enable | 774 | && rgblight_config.enable |
| 775 | # elif defined(RGBLIGHT_SLEEP) | ||
| 776 | && !is_suspended | ||
| 734 | # endif | 777 | # endif |
| 735 | ) { | 778 | ) { |
| 736 | rgblight_layers_write(); | 779 | rgblight_layers_write(); |
