Converted RGB matrix to use last_input_activity_elapsed(). (#21687)

Co-authored-by: Nick Brassel <nick@tzarc.org>
master
Pete Neisen 2023-11-29 15:38:06 -07:00 committed by GitHub
parent cfbbb503a4
commit 7cc90c234f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 36 deletions

View File

@ -74,9 +74,6 @@ static uint8_t led_last_enable = UINT8_MAX;
static uint8_t led_last_effect = UINT8_MAX; static uint8_t led_last_effect = UINT8_MAX;
static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false}; static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false};
static led_task_states led_task_state = SYNCING; static led_task_states led_task_state = SYNCING;
#if LED_MATRIX_TIMEOUT > 0
static uint32_t led_anykey_timer;
#endif // LED_MATRIX_TIMEOUT > 0
// double buffers // double buffers
static uint32_t led_timer_buffer; static uint32_t led_timer_buffer;
@ -156,9 +153,6 @@ void process_led_matrix(uint8_t row, uint8_t col, bool pressed) {
#ifndef LED_MATRIX_SPLIT #ifndef LED_MATRIX_SPLIT
if (!is_keyboard_master()) return; if (!is_keyboard_master()) return;
#endif #endif
#if LED_MATRIX_TIMEOUT > 0
led_anykey_timer = 0;
#endif // LED_MATRIX_TIMEOUT > 0
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED #ifdef LED_MATRIX_KEYREACTIVE_ENABLED
uint8_t led[LED_HITS_TO_REMEMBER]; uint8_t led[LED_HITS_TO_REMEMBER];
@ -208,22 +202,11 @@ static bool led_matrix_none(effect_params_t *params) {
} }
static void led_task_timers(void) { static void led_task_timers(void) {
#if defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_MATRIX_TIMEOUT > 0 #if defined(LED_MATRIX_KEYREACTIVE_ENABLED)
uint32_t deltaTime = sync_timer_elapsed32(led_timer_buffer); uint32_t deltaTime = sync_timer_elapsed32(led_timer_buffer);
#endif // defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_MATRIX_TIMEOUT > 0 #endif // defined(LED_MATRIX_KEYREACTIVE_ENABLED)
led_timer_buffer = sync_timer_read32(); led_timer_buffer = sync_timer_read32();
// Update double buffer timers
#if LED_MATRIX_TIMEOUT > 0
if (led_anykey_timer < UINT32_MAX) {
if (UINT32_MAX - deltaTime < led_anykey_timer) {
led_anykey_timer = UINT32_MAX;
} else {
led_anykey_timer += deltaTime;
}
}
#endif // LED_MATRIX_TIMEOUT > 0
// Update double buffer last hit timers // Update double buffer last hit timers
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED #ifdef LED_MATRIX_KEYREACTIVE_ENABLED
uint8_t count = last_hit_buffer.count; uint8_t count = last_hit_buffer.count;
@ -329,7 +312,7 @@ void led_matrix_task(void) {
// while suspended and just do a software shutdown. This is a cheap hack for now. // while suspended and just do a software shutdown. This is a cheap hack for now.
bool suspend_backlight = suspend_state || bool suspend_backlight = suspend_state ||
#if LED_MATRIX_TIMEOUT > 0 #if LED_MATRIX_TIMEOUT > 0
(led_anykey_timer > (uint32_t)LED_MATRIX_TIMEOUT) || (last_input_activity_elapsed() > (uint32_t)LED_MATRIX_TIMEOUT) ||
#endif // LED_MATRIX_TIMEOUT > 0 #endif // LED_MATRIX_TIMEOUT > 0
false; false;

View File

@ -76,9 +76,6 @@ static uint8_t rgb_last_enable = UINT8_MAX;
static uint8_t rgb_last_effect = UINT8_MAX; static uint8_t rgb_last_effect = UINT8_MAX;
static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false}; static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false};
static rgb_task_states rgb_task_state = SYNCING; static rgb_task_states rgb_task_state = SYNCING;
#if RGB_MATRIX_TIMEOUT > 0
static uint32_t rgb_anykey_timer;
#endif // RGB_MATRIX_TIMEOUT > 0
// double buffers // double buffers
static uint32_t rgb_timer_buffer; static uint32_t rgb_timer_buffer;
@ -163,9 +160,6 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) {
#ifndef RGB_MATRIX_SPLIT #ifndef RGB_MATRIX_SPLIT
if (!is_keyboard_master()) return; if (!is_keyboard_master()) return;
#endif #endif
#if RGB_MATRIX_TIMEOUT > 0
rgb_anykey_timer = 0;
#endif // RGB_MATRIX_TIMEOUT > 0
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
uint8_t led[LED_HITS_TO_REMEMBER]; uint8_t led[LED_HITS_TO_REMEMBER];
@ -246,18 +240,11 @@ static bool rgb_matrix_none(effect_params_t *params) {
} }
static void rgb_task_timers(void) { static void rgb_task_timers(void) {
#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_MATRIX_TIMEOUT > 0 #if defined(RGB_MATRIX_KEYREACTIVE_ENABLED)
uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer); uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer);
#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_MATRIX_TIMEOUT > 0 #endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED)
rgb_timer_buffer = sync_timer_read32(); rgb_timer_buffer = sync_timer_read32();
// Update double buffer timers
#if RGB_MATRIX_TIMEOUT > 0
if (rgb_anykey_timer + deltaTime <= UINT32_MAX) {
rgb_anykey_timer += deltaTime;
}
#endif // RGB_MATRIX_TIMEOUT > 0
// Update double buffer last hit timers // Update double buffer last hit timers
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
uint8_t count = last_hit_buffer.count; uint8_t count = last_hit_buffer.count;
@ -370,7 +357,7 @@ void rgb_matrix_task(void) {
// while suspended and just do a software shutdown. This is a cheap hack for now. // while suspended and just do a software shutdown. This is a cheap hack for now.
bool suspend_backlight = suspend_state || bool suspend_backlight = suspend_state ||
#if RGB_MATRIX_TIMEOUT > 0 #if RGB_MATRIX_TIMEOUT > 0
(rgb_anykey_timer > (uint32_t)RGB_MATRIX_TIMEOUT) || (last_input_activity_elapsed() > (uint32_t)RGB_MATRIX_TIMEOUT) ||
#endif // RGB_MATRIX_TIMEOUT > 0 #endif // RGB_MATRIX_TIMEOUT > 0
false; false;