aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/led_matrix.c18
-rw-r--r--quantum/led_matrix.h1
-rw-r--r--quantum/rgb_matrix.c18
-rw-r--r--quantum/rgb_matrix.h1
4 files changed, 18 insertions, 20 deletions
diff --git a/quantum/led_matrix.c b/quantum/led_matrix.c
index 72eb5190b..5dd37dff1 100644
--- a/quantum/led_matrix.c
+++ b/quantum/led_matrix.c
@@ -35,8 +35,8 @@
35# define LED_DISABLE_TIMEOUT 0 35# define LED_DISABLE_TIMEOUT 0
36#endif 36#endif
37 37
38#ifndef LED_DISABLE_WHEN_USB_SUSPENDED 38#if LED_DISABLE_WHEN_USB_SUSPENDED == false
39# define LED_DISABLE_WHEN_USB_SUSPENDED false 39# undef LED_DISABLE_WHEN_USB_SUSPENDED
40#endif 40#endif
41 41
42#if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX 42#if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
@@ -65,7 +65,6 @@
65#endif 65#endif
66 66
67// globals 67// globals
68bool g_suspend_state = false;
69led_eeconfig_t led_matrix_eeconfig; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr 68led_eeconfig_t led_matrix_eeconfig; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr
70uint32_t g_led_timer; 69uint32_t g_led_timer;
71#ifdef LED_MATRIX_FRAMEBUFFER_EFFECTS 70#ifdef LED_MATRIX_FRAMEBUFFER_EFFECTS
@@ -76,6 +75,7 @@ last_hit_t g_last_hit_tracker;
76#endif // LED_MATRIX_KEYREACTIVE_ENABLED 75#endif // LED_MATRIX_KEYREACTIVE_ENABLED
77 76
78// internals 77// internals
78static bool suspend_state = false;
79static uint8_t led_last_enable = UINT8_MAX; 79static uint8_t led_last_enable = UINT8_MAX;
80static uint8_t led_last_effect = UINT8_MAX; 80static uint8_t led_last_effect = UINT8_MAX;
81static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false}; 81static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false};
@@ -325,9 +325,7 @@ void led_matrix_task(void) {
325 // Ideally we would also stop sending zeros to the LED driver PWM buffers 325 // Ideally we would also stop sending zeros to the LED driver PWM buffers
326 // while suspended and just do a software shutdown. This is a cheap hack for now. 326 // while suspended and just do a software shutdown. This is a cheap hack for now.
327 bool suspend_backlight = 327 bool suspend_backlight =
328#if LED_DISABLE_WHEN_USB_SUSPENDED == true 328 suspend_state ||
329 g_suspend_state ||
330#endif // LED_DISABLE_WHEN_USB_SUSPENDED == true
331#if LED_DISABLE_TIMEOUT > 0 329#if LED_DISABLE_TIMEOUT > 0
332 (led_anykey_timer > (uint32_t)LED_DISABLE_TIMEOUT) || 330 (led_anykey_timer > (uint32_t)LED_DISABLE_TIMEOUT) ||
333#endif // LED_DISABLE_TIMEOUT > 0 331#endif // LED_DISABLE_TIMEOUT > 0
@@ -416,13 +414,15 @@ void led_matrix_init(void) {
416} 414}
417 415
418void led_matrix_set_suspend_state(bool state) { 416void led_matrix_set_suspend_state(bool state) {
419 if (LED_DISABLE_WHEN_USB_SUSPENDED && state) { 417#ifdef LED_DISABLE_WHEN_USB_SUSPENDED
418 if (state) {
420 led_matrix_set_value_all(0); // turn off all LEDs when suspending 419 led_matrix_set_value_all(0); // turn off all LEDs when suspending
421 } 420 }
422 g_suspend_state = state; 421 suspend_state = state;
422#endif
423} 423}
424 424
425bool led_matrix_get_suspend_state(void) { return g_suspend_state; } 425bool led_matrix_get_suspend_state(void) { return suspend_state; }
426 426
427void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) { 427void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) {
428 led_matrix_eeconfig.enable ^= 1; 428 led_matrix_eeconfig.enable ^= 1;
diff --git a/quantum/led_matrix.h b/quantum/led_matrix.h
index f35bbe209..a3fa552b0 100644
--- a/quantum/led_matrix.h
+++ b/quantum/led_matrix.h
@@ -134,7 +134,6 @@ extern const led_matrix_driver_t led_matrix_driver;
134 134
135extern led_eeconfig_t led_matrix_eeconfig; 135extern led_eeconfig_t led_matrix_eeconfig;
136 136
137extern bool g_suspend_state;
138extern uint32_t g_led_timer; 137extern uint32_t g_led_timer;
139extern led_config_t g_led_config; 138extern led_config_t g_led_config;
140#ifdef LED_MATRIX_KEYREACTIVE_ENABLED 139#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c
index 8aae48603..1f7604943 100644
--- a/quantum/rgb_matrix.c
+++ b/quantum/rgb_matrix.c
@@ -67,8 +67,8 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv
67# define RGB_DISABLE_TIMEOUT 0 67# define RGB_DISABLE_TIMEOUT 0
68#endif 68#endif
69 69
70#ifndef RGB_DISABLE_WHEN_USB_SUSPENDED 70#if RGB_DISABLE_WHEN_USB_SUSPENDED == false
71# define RGB_DISABLE_WHEN_USB_SUSPENDED false 71# undef RGB_DISABLE_WHEN_USB_SUSPENDED
72#endif 72#endif
73 73
74#if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX 74#if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
@@ -118,7 +118,6 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv
118#endif 118#endif
119 119
120// globals 120// globals
121bool g_suspend_state = false;
122rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr 121rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr
123uint32_t g_rgb_timer; 122uint32_t g_rgb_timer;
124#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS 123#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS
@@ -129,6 +128,7 @@ last_hit_t g_last_hit_tracker;
129#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 128#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
130 129
131// internals 130// internals
131static bool suspend_state = false;
132static uint8_t rgb_last_enable = UINT8_MAX; 132static uint8_t rgb_last_enable = UINT8_MAX;
133static uint8_t rgb_last_effect = UINT8_MAX; 133static uint8_t rgb_last_effect = UINT8_MAX;
134static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false}; 134static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false};
@@ -410,9 +410,7 @@ void rgb_matrix_task(void) {
410 // Ideally we would also stop sending zeros to the LED driver PWM buffers 410 // Ideally we would also stop sending zeros to the LED driver PWM buffers
411 // while suspended and just do a software shutdown. This is a cheap hack for now. 411 // while suspended and just do a software shutdown. This is a cheap hack for now.
412 bool suspend_backlight = 412 bool suspend_backlight =
413#if RGB_DISABLE_WHEN_USB_SUSPENDED == true 413 suspend_state ||
414 g_suspend_state ||
415#endif // RGB_DISABLE_WHEN_USB_SUSPENDED == true
416#if RGB_DISABLE_TIMEOUT > 0 414#if RGB_DISABLE_TIMEOUT > 0
417 (rgb_anykey_timer > (uint32_t)RGB_DISABLE_TIMEOUT) || 415 (rgb_anykey_timer > (uint32_t)RGB_DISABLE_TIMEOUT) ||
418#endif // RGB_DISABLE_TIMEOUT > 0 416#endif // RGB_DISABLE_TIMEOUT > 0
@@ -501,13 +499,15 @@ void rgb_matrix_init(void) {
501} 499}
502 500
503void rgb_matrix_set_suspend_state(bool state) { 501void rgb_matrix_set_suspend_state(bool state) {
504 if (RGB_DISABLE_WHEN_USB_SUSPENDED && state) { 502#ifdef RGB_DISABLE_WHEN_USB_SUSPENDED
503 if (state) {
505 rgb_matrix_set_color_all(0, 0, 0); // turn off all LEDs when suspending 504 rgb_matrix_set_color_all(0, 0, 0); // turn off all LEDs when suspending
506 } 505 }
507 g_suspend_state = state; 506 suspend_state = state;
507#endif
508} 508}
509 509
510bool rgb_matrix_get_suspend_state(void) { return g_suspend_state; } 510bool rgb_matrix_get_suspend_state(void) { return suspend_state; }
511 511
512void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) { 512void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) {
513 rgb_matrix_config.enable ^= 1; 513 rgb_matrix_config.enable ^= 1;
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h
index bb8bcfab6..a615b8422 100644
--- a/quantum/rgb_matrix.h
+++ b/quantum/rgb_matrix.h
@@ -216,7 +216,6 @@ extern const rgb_matrix_driver_t rgb_matrix_driver;
216 216
217extern rgb_config_t rgb_matrix_config; 217extern rgb_config_t rgb_matrix_config;
218 218
219extern bool g_suspend_state;
220extern uint32_t g_rgb_timer; 219extern uint32_t g_rgb_timer;
221extern led_config_t g_led_config; 220extern led_config_t g_led_config;
222#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED 221#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED