diff options
| -rw-r--r-- | quantum/rgblight.c | 45 | ||||
| -rw-r--r-- | quantum/rgblight.h | 2 | ||||
| -rw-r--r-- | tmk_core/common/avr/suspend.c | 16 | ||||
| -rw-r--r-- | tmk_core/common/chibios/suspend.c | 16 |
4 files changed, 50 insertions, 29 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 59b3f4026..b16c3e7c2 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -98,6 +98,11 @@ rgblight_config_t rgblight_config; | |||
| 98 | rgblight_status_t rgblight_status = {.timer_enabled = false}; | 98 | rgblight_status_t rgblight_status = {.timer_enabled = false}; |
| 99 | bool is_rgblight_initialized = false; | 99 | bool is_rgblight_initialized = false; |
| 100 | 100 | ||
| 101 | #ifdef RGBLIGHT_SLEEP | ||
| 102 | static bool is_suspended; | ||
| 103 | static bool pre_suspend_enabled; | ||
| 104 | #endif | ||
| 105 | |||
| 101 | #ifdef RGBLIGHT_USE_TIMER | 106 | #ifdef RGBLIGHT_USE_TIMER |
| 102 | animation_status_t animation_status = {}; | 107 | animation_status_t animation_status = {}; |
| 103 | #endif | 108 | #endif |
| @@ -709,6 +714,42 @@ void rgblight_unblink_layers(void) { | |||
| 709 | 714 | ||
| 710 | #endif | 715 | #endif |
| 711 | 716 | ||
| 717 | #ifdef RGBLIGHT_SLEEP | ||
| 718 | |||
| 719 | void rgblight_suspend(void) { | ||
| 720 | rgblight_timer_disable(); | ||
| 721 | if (!is_suspended) { | ||
| 722 | is_suspended = true; | ||
| 723 | pre_suspend_enabled = rgblight_config.enable; | ||
| 724 | |||
| 725 | # ifdef RGBLIGHT_LAYER_BLINK | ||
| 726 | // make sure any layer blinks don't come back after suspend | ||
| 727 | rgblight_status.enabled_layer_mask &= ~_blinked_layer_mask; | ||
| 728 | _blinked_layer_mask = 0; | ||
| 729 | # endif | ||
| 730 | |||
| 731 | rgblight_disable_noeeprom(); | ||
| 732 | } | ||
| 733 | } | ||
| 734 | |||
| 735 | void rgblight_wakeup(void) { | ||
| 736 | is_suspended = false; | ||
| 737 | |||
| 738 | if (pre_suspend_enabled) { | ||
| 739 | rgblight_enable_noeeprom(); | ||
| 740 | } | ||
| 741 | # ifdef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF | ||
| 742 | // Need this or else the LEDs won't be set | ||
| 743 | else if (rgblight_status.enabled_layer_mask != 0) { | ||
| 744 | rgblight_set(); | ||
| 745 | } | ||
| 746 | # endif | ||
| 747 | |||
| 748 | rgblight_timer_enable(); | ||
| 749 | } | ||
| 750 | |||
| 751 | #endif | ||
| 752 | |||
| 712 | __attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { ws2812_setleds(start_led, num_leds); } | 753 | __attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { ws2812_setleds(start_led, num_leds); } |
| 713 | 754 | ||
| 714 | #ifndef RGBLIGHT_CUSTOM_DRIVER | 755 | #ifndef RGBLIGHT_CUSTOM_DRIVER |
| @@ -730,8 +771,10 @@ void rgblight_set(void) { | |||
| 730 | 771 | ||
| 731 | # ifdef RGBLIGHT_LAYERS | 772 | # ifdef RGBLIGHT_LAYERS |
| 732 | if (rgblight_layers != NULL | 773 | if (rgblight_layers != NULL |
| 733 | # ifndef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF | 774 | # if !defined(RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF) |
| 734 | && rgblight_config.enable | 775 | && rgblight_config.enable |
| 776 | # elif defined(RGBLIGHT_SLEEP) | ||
| 777 | && !is_suspended | ||
| 735 | # endif | 778 | # endif |
| 736 | ) { | 779 | ) { |
| 737 | rgblight_layers_write(); | 780 | rgblight_layers_write(); |
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index 3f0c22be3..b9306e4d2 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
| @@ -357,6 +357,8 @@ HSV rgblight_get_hsv(void); | |||
| 357 | 357 | ||
| 358 | /* === qmk_firmware (core)internal Functions === */ | 358 | /* === qmk_firmware (core)internal Functions === */ |
| 359 | void rgblight_init(void); | 359 | void rgblight_init(void); |
| 360 | void rgblight_suspend(void); | ||
| 361 | void rgblight_wakeup(void); | ||
| 360 | uint32_t rgblight_read_dword(void); | 362 | uint32_t rgblight_read_dword(void); |
| 361 | void rgblight_update_dword(uint32_t dword); | 363 | void rgblight_update_dword(uint32_t dword); |
| 362 | uint32_t eeconfig_read_rgblight(void); | 364 | uint32_t eeconfig_read_rgblight(void); |
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index aa0d42680..86c3df040 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c | |||
| @@ -24,9 +24,6 @@ | |||
| 24 | 24 | ||
| 25 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | 25 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) |
| 26 | # include "rgblight.h" | 26 | # include "rgblight.h" |
| 27 | extern rgblight_config_t rgblight_config; | ||
| 28 | static bool rgblight_enabled; | ||
| 29 | static bool is_suspended; | ||
| 30 | #endif | 27 | #endif |
| 31 | 28 | ||
| 32 | /** \brief Suspend idle | 29 | /** \brief Suspend idle |
| @@ -104,12 +101,7 @@ static void power_down(uint8_t wdto) { | |||
| 104 | // stop_all_notes(); | 101 | // stop_all_notes(); |
| 105 | # endif /* AUDIO_ENABLE */ | 102 | # endif /* AUDIO_ENABLE */ |
| 106 | # if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | 103 | # if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) |
| 107 | rgblight_timer_disable(); | 104 | rgblight_suspend(); |
| 108 | if (!is_suspended) { | ||
| 109 | is_suspended = true; | ||
| 110 | rgblight_enabled = rgblight_config.enable; | ||
| 111 | rgblight_disable_noeeprom(); | ||
| 112 | } | ||
| 113 | # endif | 105 | # endif |
| 114 | suspend_power_down_kb(); | 106 | suspend_power_down_kb(); |
| 115 | 107 | ||
| @@ -177,11 +169,7 @@ void suspend_wakeup_init(void) { | |||
| 177 | #endif | 169 | #endif |
| 178 | led_set(host_keyboard_leds()); | 170 | led_set(host_keyboard_leds()); |
| 179 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | 171 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) |
| 180 | is_suspended = false; | 172 | rgblight_wakeup(); |
| 181 | if (rgblight_enabled) { | ||
| 182 | rgblight_enable_noeeprom(); | ||
| 183 | } | ||
| 184 | rgblight_timer_enable(); | ||
| 185 | #endif | 173 | #endif |
| 186 | suspend_wakeup_init_kb(); | 174 | suspend_wakeup_init_kb(); |
| 187 | } | 175 | } |
diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c index 24efb0ac4..796056019 100644 --- a/tmk_core/common/chibios/suspend.c +++ b/tmk_core/common/chibios/suspend.c | |||
| @@ -18,9 +18,6 @@ | |||
| 18 | 18 | ||
| 19 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | 19 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) |
| 20 | # include "rgblight.h" | 20 | # include "rgblight.h" |
| 21 | extern rgblight_config_t rgblight_config; | ||
| 22 | static bool rgblight_enabled; | ||
| 23 | static bool is_suspended; | ||
| 24 | #endif | 21 | #endif |
| 25 | 22 | ||
| 26 | /** \brief suspend idle | 23 | /** \brief suspend idle |
| @@ -66,12 +63,7 @@ void suspend_power_down(void) { | |||
| 66 | // shouldn't power down TPM/FTM if we want a breathing LED | 63 | // shouldn't power down TPM/FTM if we want a breathing LED |
| 67 | // also shouldn't power down USB | 64 | // also shouldn't power down USB |
| 68 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | 65 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) |
| 69 | rgblight_timer_disable(); | 66 | rgblight_suspend(); |
| 70 | if (!is_suspended) { | ||
| 71 | is_suspended = true; | ||
| 72 | rgblight_enabled = rgblight_config.enable; | ||
| 73 | rgblight_disable_noeeprom(); | ||
| 74 | } | ||
| 75 | #endif | 67 | #endif |
| 76 | 68 | ||
| 77 | suspend_power_down_kb(); | 69 | suspend_power_down_kb(); |
| @@ -136,11 +128,7 @@ void suspend_wakeup_init(void) { | |||
| 136 | #endif /* BACKLIGHT_ENABLE */ | 128 | #endif /* BACKLIGHT_ENABLE */ |
| 137 | led_set(host_keyboard_leds()); | 129 | led_set(host_keyboard_leds()); |
| 138 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | 130 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) |
| 139 | is_suspended = false; | 131 | rgblight_wakeup(); |
| 140 | if (rgblight_enabled) { | ||
| 141 | rgblight_enable_noeeprom(); | ||
| 142 | } | ||
| 143 | rgblight_timer_enable(); | ||
| 144 | #endif | 132 | #endif |
| 145 | suspend_wakeup_init_kb(); | 133 | suspend_wakeup_init_kb(); |
| 146 | } | 134 | } |
