diff options
| author | Pete Neisen <pete@neisen.xyz> | 2023-11-29 15:38:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-30 09:38:06 +1100 |
| commit | 7cc90c234f55364bb5ebf45f9bb4274fd9926b9d (patch) | |
| tree | 97e03c3eb5007cf857968b22529379102019aa16 | |
| parent | cfbbb503a430a4f11c764cfab44737c4856afe0d (diff) | |
Converted RGB matrix to use last_input_activity_elapsed(). (#21687)
Co-authored-by: Nick Brassel <nick@tzarc.org>
| -rw-r--r-- | quantum/led_matrix/led_matrix.c | 23 | ||||
| -rw-r--r-- | quantum/rgb_matrix/rgb_matrix.c | 19 |
2 files changed, 6 insertions, 36 deletions
diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c index 4d67a295df..4699c4a4c2 100644 --- a/quantum/led_matrix/led_matrix.c +++ b/quantum/led_matrix/led_matrix.c | |||
| @@ -74,9 +74,6 @@ static uint8_t led_last_enable = UINT8_MAX; | |||
| 74 | static uint8_t led_last_effect = UINT8_MAX; | 74 | static uint8_t led_last_effect = UINT8_MAX; |
| 75 | static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false}; | 75 | static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false}; |
| 76 | static led_task_states led_task_state = SYNCING; | 76 | static led_task_states led_task_state = SYNCING; |
| 77 | #if LED_MATRIX_TIMEOUT > 0 | ||
| 78 | static uint32_t led_anykey_timer; | ||
| 79 | #endif // LED_MATRIX_TIMEOUT > 0 | ||
| 80 | 77 | ||
| 81 | // double buffers | 78 | // double buffers |
| 82 | static uint32_t led_timer_buffer; | 79 | static uint32_t led_timer_buffer; |
| @@ -156,9 +153,6 @@ void process_led_matrix(uint8_t row, uint8_t col, bool pressed) { | |||
| 156 | #ifndef LED_MATRIX_SPLIT | 153 | #ifndef LED_MATRIX_SPLIT |
| 157 | if (!is_keyboard_master()) return; | 154 | if (!is_keyboard_master()) return; |
| 158 | #endif | 155 | #endif |
| 159 | #if LED_MATRIX_TIMEOUT > 0 | ||
| 160 | led_anykey_timer = 0; | ||
| 161 | #endif // LED_MATRIX_TIMEOUT > 0 | ||
| 162 | 156 | ||
| 163 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED | 157 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED |
| 164 | uint8_t led[LED_HITS_TO_REMEMBER]; | 158 | uint8_t led[LED_HITS_TO_REMEMBER]; |
| @@ -208,22 +202,11 @@ static bool led_matrix_none(effect_params_t *params) { | |||
| 208 | } | 202 | } |
| 209 | 203 | ||
| 210 | static void led_task_timers(void) { | 204 | static void led_task_timers(void) { |
| 211 | #if defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_MATRIX_TIMEOUT > 0 | 205 | #if defined(LED_MATRIX_KEYREACTIVE_ENABLED) |
| 212 | uint32_t deltaTime = sync_timer_elapsed32(led_timer_buffer); | 206 | uint32_t deltaTime = sync_timer_elapsed32(led_timer_buffer); |
| 213 | #endif // defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_MATRIX_TIMEOUT > 0 | 207 | #endif // defined(LED_MATRIX_KEYREACTIVE_ENABLED) |
| 214 | led_timer_buffer = sync_timer_read32(); | 208 | led_timer_buffer = sync_timer_read32(); |
| 215 | 209 | ||
| 216 | // Update double buffer timers | ||
| 217 | #if LED_MATRIX_TIMEOUT > 0 | ||
| 218 | if (led_anykey_timer < UINT32_MAX) { | ||
| 219 | if (UINT32_MAX - deltaTime < led_anykey_timer) { | ||
| 220 | led_anykey_timer = UINT32_MAX; | ||
| 221 | } else { | ||
| 222 | led_anykey_timer += deltaTime; | ||
| 223 | } | ||
| 224 | } | ||
| 225 | #endif // LED_MATRIX_TIMEOUT > 0 | ||
| 226 | |||
| 227 | // Update double buffer last hit timers | 210 | // Update double buffer last hit timers |
| 228 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED | 211 | #ifdef LED_MATRIX_KEYREACTIVE_ENABLED |
| 229 | uint8_t count = last_hit_buffer.count; | 212 | uint8_t count = last_hit_buffer.count; |
| @@ -329,7 +312,7 @@ void led_matrix_task(void) { | |||
| 329 | // while suspended and just do a software shutdown. This is a cheap hack for now. | 312 | // while suspended and just do a software shutdown. This is a cheap hack for now. |
| 330 | bool suspend_backlight = suspend_state || | 313 | bool suspend_backlight = suspend_state || |
| 331 | #if LED_MATRIX_TIMEOUT > 0 | 314 | #if LED_MATRIX_TIMEOUT > 0 |
| 332 | (led_anykey_timer > (uint32_t)LED_MATRIX_TIMEOUT) || | 315 | (last_input_activity_elapsed() > (uint32_t)LED_MATRIX_TIMEOUT) || |
| 333 | #endif // LED_MATRIX_TIMEOUT > 0 | 316 | #endif // LED_MATRIX_TIMEOUT > 0 |
| 334 | false; | 317 | false; |
| 335 | 318 | ||
diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c index d93d189827..ebaf3077dc 100644 --- a/quantum/rgb_matrix/rgb_matrix.c +++ b/quantum/rgb_matrix/rgb_matrix.c | |||
| @@ -76,9 +76,6 @@ static uint8_t rgb_last_enable = UINT8_MAX; | |||
| 76 | static uint8_t rgb_last_effect = UINT8_MAX; | 76 | static uint8_t rgb_last_effect = UINT8_MAX; |
| 77 | static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false}; | 77 | static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false}; |
| 78 | static rgb_task_states rgb_task_state = SYNCING; | 78 | static rgb_task_states rgb_task_state = SYNCING; |
| 79 | #if RGB_MATRIX_TIMEOUT > 0 | ||
| 80 | static uint32_t rgb_anykey_timer; | ||
| 81 | #endif // RGB_MATRIX_TIMEOUT > 0 | ||
| 82 | 79 | ||
| 83 | // double buffers | 80 | // double buffers |
| 84 | static uint32_t rgb_timer_buffer; | 81 | static uint32_t rgb_timer_buffer; |
| @@ -163,9 +160,6 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { | |||
| 163 | #ifndef RGB_MATRIX_SPLIT | 160 | #ifndef RGB_MATRIX_SPLIT |
| 164 | if (!is_keyboard_master()) return; | 161 | if (!is_keyboard_master()) return; |
| 165 | #endif | 162 | #endif |
| 166 | #if RGB_MATRIX_TIMEOUT > 0 | ||
| 167 | rgb_anykey_timer = 0; | ||
| 168 | #endif // RGB_MATRIX_TIMEOUT > 0 | ||
| 169 | 163 | ||
| 170 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | 164 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED |
| 171 | uint8_t led[LED_HITS_TO_REMEMBER]; | 165 | uint8_t led[LED_HITS_TO_REMEMBER]; |
| @@ -246,18 +240,11 @@ static bool rgb_matrix_none(effect_params_t *params) { | |||
| 246 | } | 240 | } |
| 247 | 241 | ||
| 248 | static void rgb_task_timers(void) { | 242 | static void rgb_task_timers(void) { |
| 249 | #if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_MATRIX_TIMEOUT > 0 | 243 | #if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) |
| 250 | uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer); | 244 | uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer); |
| 251 | #endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_MATRIX_TIMEOUT > 0 | 245 | #endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) |
| 252 | rgb_timer_buffer = sync_timer_read32(); | 246 | rgb_timer_buffer = sync_timer_read32(); |
| 253 | 247 | ||
| 254 | // Update double buffer timers | ||
| 255 | #if RGB_MATRIX_TIMEOUT > 0 | ||
| 256 | if (rgb_anykey_timer + deltaTime <= UINT32_MAX) { | ||
| 257 | rgb_anykey_timer += deltaTime; | ||
| 258 | } | ||
| 259 | #endif // RGB_MATRIX_TIMEOUT > 0 | ||
| 260 | |||
| 261 | // Update double buffer last hit timers | 248 | // Update double buffer last hit timers |
| 262 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED | 249 | #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED |
| 263 | uint8_t count = last_hit_buffer.count; | 250 | uint8_t count = last_hit_buffer.count; |
| @@ -370,7 +357,7 @@ void rgb_matrix_task(void) { | |||
| 370 | // while suspended and just do a software shutdown. This is a cheap hack for now. | 357 | // while suspended and just do a software shutdown. This is a cheap hack for now. |
| 371 | bool suspend_backlight = suspend_state || | 358 | bool suspend_backlight = suspend_state || |
| 372 | #if RGB_MATRIX_TIMEOUT > 0 | 359 | #if RGB_MATRIX_TIMEOUT > 0 |
| 373 | (rgb_anykey_timer > (uint32_t)RGB_MATRIX_TIMEOUT) || | 360 | (last_input_activity_elapsed() > (uint32_t)RGB_MATRIX_TIMEOUT) || |
| 374 | #endif // RGB_MATRIX_TIMEOUT > 0 | 361 | #endif // RGB_MATRIX_TIMEOUT > 0 |
| 375 | false; | 362 | false; |
| 376 | 363 | ||
