diff options
author | Joshua Diamond <josh@windowoffire.com> | 2021-01-11 03:07:09 -0500 |
---|---|---|
committer | Drashna Jael're <drashna@live.com> | 2021-02-02 09:35:53 -0800 |
commit | dc11c3da3b4878ad3541356c3fe1ac5f36008904 (patch) | |
tree | e11e2e374a1e04eaf40d29dfb5df37db8d4e7755 /quantum | |
parent | f1a82690bef927f531cb767d59e5e7e935100da0 (diff) |
Lighting Layers should be disabled when suspended (#11442)
* Lighting Layers should be disabled when suspended
* bugfixes
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 bd805813c8..52f4b00a1e 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -95,6 +95,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 @@ -710,6 +715,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 @@ -731,8 +772,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(); diff --git a/quantum/rgblight.h b/quantum/rgblight.h index c02fd4f37b..efbffa7fdb 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h @@ -357,6 +357,8 @@ HSV rgblight_get_hsv(void); /* === qmk_firmware (core)internal Functions === */ void rgblight_init(void); +void rgblight_suspend(void); +void rgblight_wakeup(void); uint32_t rgblight_read_dword(void); void rgblight_update_dword(uint32_t dword); uint32_t eeconfig_read_rgblight(void); |