From d8936f343525d68eac632e075bc2ca4a6633100d Mon Sep 17 00:00:00 2001 From: "jonathan.liu" Date: Fri, 14 Sep 2018 15:47:47 -0700 Subject: [PATCH] Use highest active layer only for LEDs --- tmk_core/protocol/arm_atsam/led_matrix.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/led_matrix.c index 1fbd49c3ce0..8da43d05c9f 100644 --- a/tmk_core/protocol/arm_atsam/led_matrix.c +++ b/tmk_core/protocol/arm_atsam/led_matrix.c @@ -364,6 +364,14 @@ void led_matrix_run(led_setup_t *f) } } + uint8_t highest_active_layer = 0; + uint32_t temp_layer_state = layer_state; + + while (temp_layer_state >> 1 != 0) { + highest_active_layer++; + temp_layer_state = temp_layer_state >> 1; + } + while (led_cur < lede && led_this_run < led_per_run) { ro = 0; @@ -430,9 +438,7 @@ void led_matrix_run(led_setup_t *f) } if (led_cur_instruction->flags & LED_FLAG_MATCH_LAYER) { - if (layer_state == 0 && led_cur_instruction->layer == 0) { - // - } else if (~layer_state & (1UL << led_cur_instruction->layer)) { + if (led_cur_instruction->layer != highest_active_layer) { skip = 1; } }