diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/rgblight.c | 45 | ||||
| -rw-r--r-- | quantum/rgblight.h | 2 |
2 files changed, 46 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(); |
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index c02fd4f37..efbffa7fd 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); |
