aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/rgblight.c45
-rw-r--r--quantum/rgblight.h2
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;
95rgblight_status_t rgblight_status = {.timer_enabled = false}; 95rgblight_status_t rgblight_status = {.timer_enabled = false};
96bool is_rgblight_initialized = false; 96bool is_rgblight_initialized = false;
97 97
98#ifdef RGBLIGHT_SLEEP
99static bool is_suspended;
100static bool pre_suspend_enabled;
101#endif
102
98#ifdef RGBLIGHT_USE_TIMER 103#ifdef RGBLIGHT_USE_TIMER
99animation_status_t animation_status = {}; 104animation_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
718void 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
734void 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 === */
359void rgblight_init(void); 359void rgblight_init(void);
360void rgblight_suspend(void);
361void rgblight_wakeup(void);
360uint32_t rgblight_read_dword(void); 362uint32_t rgblight_read_dword(void);
361void rgblight_update_dword(uint32_t dword); 363void rgblight_update_dword(uint32_t dword);
362uint32_t eeconfig_read_rgblight(void); 364uint32_t eeconfig_read_rgblight(void);