From 5b4f836e8c31f0441f892e35e2c3fea4d6d8d2c8 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Tue, 10 Jan 2023 16:26:09 +0800 Subject: [PATCH] lotus: Fix Key Matrix to LED Index Now the key press based animations work! Signed-off-by: Daniel Schaefer --- keyboards/lotus/ansi/ansi.c | 16 ++++++++-------- keyboards/lotus/gridpad/keymaps/default/keymap.c | 8 ++++---- keyboards/lotus/led.py | 9 ++++++--- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/keyboards/lotus/ansi/ansi.c b/keyboards/lotus/ansi/ansi.c index 602e2260a4..89f58b2209 100644 --- a/keyboards/lotus/ansi/ansi.c +++ b/keyboards/lotus/ansi/ansi.c @@ -295,14 +295,14 @@ const is31_led g_is31_leds[RGB_MATRIX_LED_COUNT] = { led_config_t g_led_config = { { // Key Matrix to LED Index - {32, 73, 6, 85, 0, 30, 34, 78, 76, 81, 79, 0, 89, 80, 53, 0, }, - { 0, 0, 0, 48, 95, 28, 36, 77, 82, 33, 0, 0, 35, 91, 54, 68, }, - { 0, 0, 94, 0, 3, 20, 40, 41, 56, 0, 27, 0, 0, 64, 0, 92, }, - { 0, 47, 2, 0, 21, 22, 8, 9, 60, 0, 25, 75, 0, 0, 0, 71, }, - { 0, 0, 17, 0, 45, 42, 10, 15, 69, 0, 23, 0, 0, 62, 63, 0, }, - { 0, 0, 16, 0, 13, 14, 12, 11, 70, 0, 18, 0, 0, 61, 65, 0, }, - { 0, 0, 0, 0, 19, 4, 5, 7, 67, 0, 59, 90, 0, 58, 55, 0, }, - { 0, 0, 37, 0, 0, 26, 44, 50, 52, 0, 51, 0, 0, 49, 38, 0, }, + { 31, 72, 5, 84, 255, 29, 33, 77, 75, 80, 78, 255, 88, 79, 52, 255, }, + {255, 255, 255, 47, 94, 27, 35, 76, 81, 32, 255, 255, 34, 90, 53, 67, }, + {255, 255, 93, 255, 2, 19, 39, 40, 55, 255, 26, 255, 255, 63, 255, 91, }, + {255, 46, 1, 255, 20, 21, 7, 8, 59, 255, 24, 74, 255, 255, 255, 70, }, + {255, 255, 16, 255, 44, 41, 9, 14, 68, 255, 22, 255, 255, 61, 62, 255, }, + {255, 255, 15, 255, 12, 13, 11, 10, 69, 255, 17, 255, 255, 60, 64, 255, }, + {255, 255, 255, 255, 18, 3, 4, 6, 66, 255, 58, 89, 255, 57, 54, 255, }, + {255, 255, 36, 255, 255, 25, 43, 49, 51, 255, 50, 255, 255, 48, 37, 255, }, }, { // LED Index to Physical Position { 11, 23 }, // LED 1 diff --git a/keyboards/lotus/gridpad/keymaps/default/keymap.c b/keyboards/lotus/gridpad/keymaps/default/keymap.c index 1f5f5dc796..806aaa59a1 100644 --- a/keyboards/lotus/gridpad/keymaps/default/keymap.c +++ b/keyboards/lotus/gridpad/keymaps/default/keymap.c @@ -44,10 +44,10 @@ const is31_led g_is31_leds[RGB_MATRIX_LED_COUNT] = { led_config_t g_led_config = { { // Key Matrix to LED Index - { 5, 8, 7, 10, 1, 2, 4, 12, }, - { 9, 21, 22, 24, 16, 17, 19, 20, }, - {13, 6, 3, 0, 18, 0, 14, 11, }, - { 0, 0, 0, 0, 23, 0, 0, 0, }, + { 4, 7, 6, 9, 0, 1, 3, 11, }, + { 8, 20, 21, 23, 15, 16, 18, 19, }, + { 12, 5, 2, 255, 17, 255, 13, 10, }, + {255, 255, 255, 255, 22, 255, 255, 255, }, }, { // LED Index to Physical Position { 73, 10 }, // LED 1 diff --git a/keyboards/lotus/led.py b/keyboards/lotus/led.py index 808d687e73..a2600ed943 100755 --- a/keyboards/lotus/led.py +++ b/keyboards/lotus/led.py @@ -190,9 +190,11 @@ gridpad = [ # Recommended by QMK to be the (x,y) range of position values LED_MAX = (224.0, 64.0) +NO_LED = 255 + # Map LEDs to keyboard matrix and normalize LED coordinates def normalize(layout): - led_to_el = [[0 for _ in range(MATRIX_COLS)] for _ in range(MATRIX_ROWS)] + led_to_el = [[NO_LED for _ in range(MATRIX_COLS)] for _ in range(MATRIX_ROWS)] # Find smallest (offset) and largest (max) values offset_x = layout[0]['x'] offset_y = layout[0]['y'] @@ -224,7 +226,8 @@ def normalize(layout): continue (matrix_x,matrix_y) = v['matrix'] # Map LED IDs to keyboard matrix - led_to_el[matrix_y][matrix_x] = int(v['id']) + # Turn LED index into 0-indexed + led_to_el[matrix_y][matrix_x] = int(v['id']) - 1 return led_to_el, normalized # Turn the data to C code that can be used in QMK's keymap.c @@ -234,7 +237,7 @@ def print_matrix(layout, led_to_el, normalized): for row in led_to_el: print(" {", end='') for col in row: - print(f"{col: >2}, ", end='') + print(f"{col: >3}, ", end='') print("},") print("}, {")