aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2021-01-11 08:07:48 +0000
committerQMK Bot <hello@qmk.fm>2021-01-11 08:07:48 +0000
commit6f9db2b48e35e13930700152738579eb5f94a839 (patch)
tree901743c846c60d4d5b565e0796157c9dbdfe58b8 /quantum
parent4fdde323466a80d8abc204e093038a00047d0097 (diff)
parent4d96b85b6f39e89bdcc74853958f91153f27bfc1 (diff)
downloadqmk_firmware-6f9db2b48e35e13930700152738579eb5f94a839.tar.gz
qmk_firmware-6f9db2b48e35e13930700152738579eb5f94a839.zip
Merge remote-tracking branch 'origin/master' into develop
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 59b3f4026..b16c3e7c2 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -98,6 +98,11 @@ rgblight_config_t rgblight_config;
98rgblight_status_t rgblight_status = {.timer_enabled = false}; 98rgblight_status_t rgblight_status = {.timer_enabled = false};
99bool is_rgblight_initialized = false; 99bool is_rgblight_initialized = false;
100 100
101#ifdef RGBLIGHT_SLEEP
102static bool is_suspended;
103static bool pre_suspend_enabled;
104#endif
105
101#ifdef RGBLIGHT_USE_TIMER 106#ifdef RGBLIGHT_USE_TIMER
102animation_status_t animation_status = {}; 107animation_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
719void 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
735void 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 === */
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);