summaryrefslogtreecommitdiff
path: root/quantum/rgblight.c
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/rgblight.c
parent4fdde323466a80d8abc204e093038a00047d0097 (diff)
parent4d96b85b6f39e89bdcc74853958f91153f27bfc1 (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'quantum/rgblight.c')
-rw-r--r--quantum/rgblight.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 59b3f40264..b16c3e7c26 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -98,6 +98,11 @@ rgblight_config_t rgblight_config;
rgblight_status_t rgblight_status = {.timer_enabled = false};
bool is_rgblight_initialized = false;
+#ifdef RGBLIGHT_SLEEP
+static bool is_suspended;
+static bool pre_suspend_enabled;
+#endif
+
#ifdef RGBLIGHT_USE_TIMER
animation_status_t animation_status = {};
#endif
@@ -709,6 +714,42 @@ void rgblight_unblink_layers(void) {
#endif
+#ifdef RGBLIGHT_SLEEP
+
+void rgblight_suspend(void) {
+ rgblight_timer_disable();
+ if (!is_suspended) {
+ is_suspended = true;
+ pre_suspend_enabled = rgblight_config.enable;
+
+# ifdef RGBLIGHT_LAYER_BLINK
+ // make sure any layer blinks don't come back after suspend
+ rgblight_status.enabled_layer_mask &= ~_blinked_layer_mask;
+ _blinked_layer_mask = 0;
+# endif
+
+ rgblight_disable_noeeprom();
+ }
+}
+
+void rgblight_wakeup(void) {
+ is_suspended = false;
+
+ if (pre_suspend_enabled) {
+ rgblight_enable_noeeprom();
+ }
+# ifdef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF
+ // Need this or else the LEDs won't be set
+ else if (rgblight_status.enabled_layer_mask != 0) {
+ rgblight_set();
+ }
+# endif
+
+ rgblight_timer_enable();
+}
+
+#endif
+
__attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { ws2812_setleds(start_led, num_leds); }
#ifndef RGBLIGHT_CUSTOM_DRIVER
@@ -730,8 +771,10 @@ void rgblight_set(void) {
# ifdef RGBLIGHT_LAYERS
if (rgblight_layers != NULL
-# ifndef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF
+# if !defined(RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF)
&& rgblight_config.enable
+# elif defined(RGBLIGHT_SLEEP)
+ && !is_suspended
# endif
) {
rgblight_layers_write();