From ff728a8a01c1aa81e86f38dfd1753bd49ce39e88 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Mon, 19 Mar 2018 20:59:58 -0700 Subject: [PATCH] [Proposal?] Allow RGB Underglow to turn off when host is idle/asleep (#2104) * Add RGB Underglow Sleeping * Add RGBLIGHT_SLEEP to toggle/control RGB light behavior * Update rgb docs * Update for RGB disable command --- docs/feature_rgblight.md | 2 ++ keyboards/ergodox_ez/keymaps/drashna/config.h | 1 + .../handwired/woodpad/keymaps/drashna/config.h | 1 + keyboards/orthodox/keymaps/drashna/config.h | 1 + keyboards/viterbi/keymaps/drashna/config.h | 1 + tmk_core/common/avr/suspend.c | 16 +++++++++++++++- 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md index f96fa87736..17097f4bca 100644 --- a/docs/feature_rgblight.md +++ b/docs/feature_rgblight.md @@ -42,6 +42,8 @@ You can change the behavior of the RGB Lighting by setting these configuration v | `RGBLIGHT_SAT_STEP` | 17 | How many steps of saturation you'd like. | | `RGBLIGHT_VAL_STEP` | 17 | The number of levels of brightness you want. | | `RGBLIGHT_LIMIT_VAL` | 255 | Limit the val of HSV to limit the maximum brightness simply. | +| `RGBLIGHT_SLEEP` | | `#define` this will shut off the lights when the host goes to sleep | + ### Animations diff --git a/keyboards/ergodox_ez/keymaps/drashna/config.h b/keyboards/ergodox_ez/keymaps/drashna/config.h index d543379a37..71c7de466f 100644 --- a/keyboards/ergodox_ez/keymaps/drashna/config.h +++ b/keyboards/ergodox_ez/keymaps/drashna/config.h @@ -10,6 +10,7 @@ #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 7 #define RGBLIGHT_EFFECT_SNAKE_LENGTH 7 #define RGBLIGHT_EFFECT_BREATHE_CENTER 1 +#define RGBLIGHT_SLEEP #endif // RGBLIGHT_ENABLE #ifdef TAPPING_TERM diff --git a/keyboards/handwired/woodpad/keymaps/drashna/config.h b/keyboards/handwired/woodpad/keymaps/drashna/config.h index a35b60d369..c83a1ac379 100644 --- a/keyboards/handwired/woodpad/keymaps/drashna/config.h +++ b/keyboards/handwired/woodpad/keymaps/drashna/config.h @@ -37,6 +37,7 @@ #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 4 #define RGBLIGHT_EFFECT_SNAKE_LENGTH 3 #define RGBLIGHT_EFFECT_BREATHE_CENTER 1 +#define RGBLIGHT_SLEEP #endif // RGBLIGHT_ENABLE #define FORCE_NKRO diff --git a/keyboards/orthodox/keymaps/drashna/config.h b/keyboards/orthodox/keymaps/drashna/config.h index 107f16d58c..dd8439a44b 100644 --- a/keyboards/orthodox/keymaps/drashna/config.h +++ b/keyboards/orthodox/keymaps/drashna/config.h @@ -64,6 +64,7 @@ along with this program. If not, see . #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 2 #define RGBLIGHT_EFFECT_SNAKE_LENGTH 2 #define RGBLIGHT_EFFECT_BREATHE_CENTER 1 +#define RGBLIGHT_SLEEP #endif // RGBLIGHT_ENABLE #ifdef AUDIO_ENABLE diff --git a/keyboards/viterbi/keymaps/drashna/config.h b/keyboards/viterbi/keymaps/drashna/config.h index 8fabe72f87..02786cfc7d 100644 --- a/keyboards/viterbi/keymaps/drashna/config.h +++ b/keyboards/viterbi/keymaps/drashna/config.h @@ -31,6 +31,7 @@ along with this program. If not, see . #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 2 #define RGBLIGHT_EFFECT_SNAKE_LENGTH 2 #define RGBLIGHT_EFFECT_BREATHE_CENTER 1 +#define RGBLIGHT_SLEEP #define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 300 #define RGBLIGHT_EFFECT_CHRISTMAS_STEP 1 diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 1c7618ff51..213f03f6fa 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c @@ -19,6 +19,9 @@ #include "audio.h" #endif /* AUDIO_ENABLE */ +#ifdef RGBLIGHT_ANIMATIONS + #include "rgblight.h" +#endif #define wdt_intr_enable(value) \ @@ -85,7 +88,12 @@ static void power_down(uint8_t wdto) // This sometimes disables the start-up noise, so it's been disabled // stop_all_notes(); #endif /* AUDIO_ENABLE */ - +#ifdef RGBLIGHT_SLEEP +#ifdef RGBLIGHT_ANIMATIONS + rgblight_timer_disable(); +#endif + rgblight_disable(); +#endif // TODO: more power saving // See PicoPower application note // - I/O port input with pullup @@ -132,6 +140,12 @@ void suspend_wakeup_init(void) backlight_init(); #endif led_set(host_keyboard_leds()); +#ifdef RGBLIGHT_SLEEP + rgblight_enable(); +#ifdef RGBLIGHT_ANIMATIONS + rgblight_timer_enable(); +#endif +#endif } #ifndef NO_SUSPEND_POWER_DOWN