From 29c82cfb33bda7fecc58fa9eadfe56bd10af2c56 Mon Sep 17 00:00:00 2001
From: Albert Y <76888457+filterpaper@users.noreply.github.com>
Date: Thu, 25 Mar 2021 20:01:03 +0800
Subject: [PATCH] Add RGB Matrix suspend wake functions to BM40 (#12246)

* Add suspend wake functions for RGB Matrix

* Add suspension RGB functions to Planck/rev6 and Preonic/rev3

* Add suspend wake to Mark 65

* Revert changes to planck and preonic

* Remove changes to The Mark65

Co-authored-by: filterpaper <filterpaper@localhost>
---
 keyboards/bm40hsrgb/bm40hsrgb.c | 11 +++++++++++
 keyboards/bm40hsrgb/config.h    |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/keyboards/bm40hsrgb/bm40hsrgb.c b/keyboards/bm40hsrgb/bm40hsrgb.c
index a44263a8b8..a0ba84db3c 100755
--- a/keyboards/bm40hsrgb/bm40hsrgb.c
+++ b/keyboards/bm40hsrgb/bm40hsrgb.c
@@ -39,4 +39,15 @@ led_config_t g_led_config = {
         2, 2, 2, 2, 2, 2
     }
 };
+
+
+void suspend_power_down_kb(void) {
+    rgb_matrix_set_suspend_state(true);
+    suspend_power_down_user();
+}
+
+void suspend_wakeup_init_kb(void) {
+    rgb_matrix_set_suspend_state(false);
+    suspend_wakeup_init_user();
+}
 #endif
diff --git a/keyboards/bm40hsrgb/config.h b/keyboards/bm40hsrgb/config.h
index 5c1ee06212..84d0950d59 100755
--- a/keyboards/bm40hsrgb/config.h
+++ b/keyboards/bm40hsrgb/config.h
@@ -50,3 +50,6 @@
 #ifdef RGB_DI_PIN
     #define RGB_MATRIX_KEYPRESSES // reacts to keypresses
 #endif
+#ifdef RGB_MATRIX_ENABLE
+#    define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended
+#endif