summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilios92 <filios92@gmail.com>2025-10-27 00:47:04 +0100
committerGitHub <noreply@github.com>2025-10-26 16:47:04 -0700
commitcb3149b7f26bc8efb0bb9b8ab489fa3eb0f963b9 (patch)
tree9504e5eeb1288785b27f116237ee4de054521930
parent64c84e64c7b1b4ef0120b5e131154d6d1c57b48a (diff)
Fix RGB matrix not syncing and turning off properly on timeout (#25467)
-rw-r--r--quantum/led_matrix/led_matrix.c32
-rw-r--r--quantum/rgb_matrix/rgb_matrix.c32
2 files changed, 36 insertions, 28 deletions
diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c
index b2665597df..715d520d1c 100644
--- a/quantum/led_matrix/led_matrix.c
+++ b/quantum/led_matrix/led_matrix.c
@@ -78,11 +78,12 @@ static const uint8_t led_matrix_flag_steps[] = LED_MATRIX_FLAG_STEPS;
78#define LED_MATRIX_FLAG_STEPS_COUNT ARRAY_SIZE(led_matrix_flag_steps) 78#define LED_MATRIX_FLAG_STEPS_COUNT ARRAY_SIZE(led_matrix_flag_steps)
79 79
80// internals 80// internals
81static bool suspend_state = false; 81static bool suspend_state = false;
82static uint8_t led_last_enable = UINT8_MAX; 82static uint8_t led_last_enable = UINT8_MAX;
83static uint8_t led_last_effect = UINT8_MAX; 83static uint8_t led_last_effect = UINT8_MAX;
84static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false}; 84static uint8_t led_current_effect = 0;
85static led_task_states led_task_state = SYNCING; 85static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false};
86static led_task_states led_task_state = SYNCING;
86 87
87// double buffers 88// double buffers
88static uint32_t led_timer_buffer; 89static uint32_t led_timer_buffer;
@@ -268,6 +269,17 @@ static void led_task_start(void) {
268 g_last_hit_tracker = last_hit_buffer; 269 g_last_hit_tracker = last_hit_buffer;
269#endif // LED_MATRIX_KEYREACTIVE_ENABLED 270#endif // LED_MATRIX_KEYREACTIVE_ENABLED
270 271
272 // Ideally we would also stop sending zeros to the LED driver PWM buffers
273 // while suspended and just do a software shutdown. This is a cheap hack for now.
274 bool suspend_backlight = suspend_state ||
275#if LED_MATRIX_TIMEOUT > 0
276 (last_input_activity_elapsed() > (uint32_t)LED_MATRIX_TIMEOUT) ||
277#endif // LED_MATRIX_TIMEOUT > 0
278 false;
279
280 // Set effect to be renedered
281 led_current_effect = suspend_backlight || !led_matrix_eeconfig.enable ? 0 : led_matrix_eeconfig.mode;
282
271 // next task 283 // next task
272 led_task_state = RENDERING; 284 led_task_state = RENDERING;
273} 285}
@@ -349,15 +361,7 @@ static void led_task_flush(uint8_t effect) {
349void led_matrix_task(void) { 361void led_matrix_task(void) {
350 led_task_timers(); 362 led_task_timers();
351 363
352 // Ideally we would also stop sending zeros to the LED driver PWM buffers 364 uint8_t effect = led_current_effect;
353 // while suspended and just do a software shutdown. This is a cheap hack for now.
354 bool suspend_backlight = suspend_state ||
355#if LED_MATRIX_TIMEOUT > 0
356 (last_input_activity_elapsed() > (uint32_t)LED_MATRIX_TIMEOUT) ||
357#endif // LED_MATRIX_TIMEOUT > 0
358 false;
359
360 uint8_t effect = suspend_backlight || !led_matrix_eeconfig.enable ? 0 : led_matrix_eeconfig.mode;
361 365
362 switch (led_task_state) { 366 switch (led_task_state) {
363 case STARTING: 367 case STARTING:
diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c
index 19edfb52b0..f517190e35 100644
--- a/quantum/rgb_matrix/rgb_matrix.c
+++ b/quantum/rgb_matrix/rgb_matrix.c
@@ -80,11 +80,12 @@ static const uint8_t rgb_matrix_flag_steps[] = RGB_MATRIX_FLAG_STEPS;
80#define RGB_MATRIX_FLAG_STEPS_COUNT ARRAY_SIZE(rgb_matrix_flag_steps) 80#define RGB_MATRIX_FLAG_STEPS_COUNT ARRAY_SIZE(rgb_matrix_flag_steps)
81 81
82// internals 82// internals
83static bool suspend_state = false; 83static bool suspend_state = false;
84static uint8_t rgb_last_enable = UINT8_MAX; 84static uint8_t rgb_last_enable = UINT8_MAX;
85static uint8_t rgb_last_effect = UINT8_MAX; 85static uint8_t rgb_last_effect = UINT8_MAX;
86static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false}; 86static uint8_t rgb_current_effect = 0;
87static rgb_task_states rgb_task_state = SYNCING; 87static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false};
88static rgb_task_states rgb_task_state = SYNCING;
88 89
89// double buffers 90// double buffers
90static uint32_t rgb_timer_buffer; 91static uint32_t rgb_timer_buffer;
@@ -296,6 +297,17 @@ static void rgb_task_start(void) {
296 g_last_hit_tracker = last_hit_buffer; 297 g_last_hit_tracker = last_hit_buffer;
297#endif // RGB_MATRIX_KEYREACTIVE_ENABLED 298#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
298 299
300 // Ideally we would also stop sending zeros to the LED driver PWM buffers
301 // while suspended and just do a software shutdown. This is a cheap hack for now.
302 bool suspend_backlight = suspend_state ||
303#if RGB_MATRIX_TIMEOUT > 0
304 (last_input_activity_elapsed() > (uint32_t)RGB_MATRIX_TIMEOUT) ||
305#endif // RGB_MATRIX_TIMEOUT > 0
306 false;
307
308 // Set effect to be renedered
309 rgb_current_effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode;
310
299 // next task 311 // next task
300 rgb_task_state = RENDERING; 312 rgb_task_state = RENDERING;
301} 313}
@@ -384,15 +396,7 @@ static void rgb_task_flush(uint8_t effect) {
384void rgb_matrix_task(void) { 396void rgb_matrix_task(void) {
385 rgb_task_timers(); 397 rgb_task_timers();
386 398
387 // Ideally we would also stop sending zeros to the LED driver PWM buffers 399 uint8_t effect = rgb_current_effect;
388 // while suspended and just do a software shutdown. This is a cheap hack for now.
389 bool suspend_backlight = suspend_state ||
390#if RGB_MATRIX_TIMEOUT > 0
391 (last_input_activity_elapsed() > (uint32_t)RGB_MATRIX_TIMEOUT) ||
392#endif // RGB_MATRIX_TIMEOUT > 0
393 false;
394
395 uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode;
396 400
397 switch (rgb_task_state) { 401 switch (rgb_task_state) {
398 case STARTING: 402 case STARTING: