diff options
| -rw-r--r-- | tmk_core/common/chibios/suspend.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c index c0f9c28d4..5be1b7677 100644 --- a/tmk_core/common/chibios/suspend.c +++ b/tmk_core/common/chibios/suspend.c | |||
| @@ -15,6 +15,13 @@ | |||
| 15 | # include "backlight.h" | 15 | # include "backlight.h" |
| 16 | #endif | 16 | #endif |
| 17 | 17 | ||
| 18 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 19 | # include "rgblight.h" | ||
| 20 | extern rgblight_config_t rgblight_config; | ||
| 21 | static bool rgblight_enabled; | ||
| 22 | static bool is_suspended; | ||
| 23 | #endif | ||
| 24 | |||
| 18 | /** \brief suspend idle | 25 | /** \brief suspend idle |
| 19 | * | 26 | * |
| 20 | * FIXME: needs doc | 27 | * FIXME: needs doc |
| @@ -43,6 +50,16 @@ void suspend_power_down(void) { | |||
| 43 | // TODO: figure out what to power down and how | 50 | // TODO: figure out what to power down and how |
| 44 | // shouldn't power down TPM/FTM if we want a breathing LED | 51 | // shouldn't power down TPM/FTM if we want a breathing LED |
| 45 | // also shouldn't power down USB | 52 | // also shouldn't power down USB |
| 53 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 54 | # ifdef RGBLIGHT_ANIMATIONS | ||
| 55 | rgblight_timer_disable(); | ||
| 56 | # endif | ||
| 57 | if (!is_suspended) { | ||
| 58 | is_suspended = true; | ||
| 59 | rgblight_enabled = rgblight_config.enable; | ||
| 60 | rgblight_disable_noeeprom(); | ||
| 61 | } | ||
| 62 | #endif | ||
| 46 | 63 | ||
| 47 | suspend_power_down_kb(); | 64 | suspend_power_down_kb(); |
| 48 | // on AVR, this enables the watchdog for 15ms (max), and goes to | 65 | // on AVR, this enables the watchdog for 15ms (max), and goes to |
| @@ -104,5 +121,14 @@ void suspend_wakeup_init(void) { | |||
| 104 | #ifdef BACKLIGHT_ENABLE | 121 | #ifdef BACKLIGHT_ENABLE |
| 105 | backlight_init(); | 122 | backlight_init(); |
| 106 | #endif /* BACKLIGHT_ENABLE */ | 123 | #endif /* BACKLIGHT_ENABLE */ |
| 124 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 125 | is_suspended = false; | ||
| 126 | if (rgblight_enabled) { | ||
| 127 | rgblight_enable_noeeprom(); | ||
| 128 | } | ||
| 129 | # ifdef RGBLIGHT_ANIMATIONS | ||
| 130 | rgblight_timer_enable(); | ||
| 131 | # endif | ||
| 132 | #endif | ||
| 107 | suspend_wakeup_init_kb(); | 133 | suspend_wakeup_init_kb(); |
| 108 | } | 134 | } |
