diff options
| author | Filios92 <filios92@gmail.com> | 2025-10-27 00:47:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-26 16:47:04 -0700 |
| commit | cb3149b7f26bc8efb0bb9b8ab489fa3eb0f963b9 (patch) | |
| tree | 9504e5eeb1288785b27f116237ee4de054521930 /quantum/led_matrix | |
| parent | 64c84e64c7b1b4ef0120b5e131154d6d1c57b48a (diff) | |
Fix RGB matrix not syncing and turning off properly on timeout (#25467)
Diffstat (limited to 'quantum/led_matrix')
| -rw-r--r-- | quantum/led_matrix/led_matrix.c | 32 |
1 files changed, 18 insertions, 14 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 |
| 81 | static bool suspend_state = false; | 81 | static bool suspend_state = false; |
| 82 | static uint8_t led_last_enable = UINT8_MAX; | 82 | static uint8_t led_last_enable = UINT8_MAX; |
| 83 | static uint8_t led_last_effect = UINT8_MAX; | 83 | static uint8_t led_last_effect = UINT8_MAX; |
| 84 | static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false}; | 84 | static uint8_t led_current_effect = 0; |
| 85 | static led_task_states led_task_state = SYNCING; | 85 | static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false}; |
| 86 | static led_task_states led_task_state = SYNCING; | ||
| 86 | 87 | ||
| 87 | // double buffers | 88 | // double buffers |
| 88 | static uint32_t led_timer_buffer; | 89 | static 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) { | |||
| 349 | void led_matrix_task(void) { | 361 | void 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: |
