From 4c1ab343f50f09d8a29b58e5725cf3e5e456213e Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Tue, 27 Dec 2022 16:44:28 +0800 Subject: [PATCH] lotus: Fully configure gridpad LEDs Signed-off-by: Daniel Schaefer --- keyboards/lotus/keymaps/gridpad/keymap.c | 33 ++++++++++++++- keyboards/lotus/led.py | 51 ++++++++++++------------ keyboards/lotus/lotus.h | 18 +++++++++ 3 files changed, 76 insertions(+), 26 deletions(-) diff --git a/keyboards/lotus/keymaps/gridpad/keymap.c b/keyboards/lotus/keymaps/gridpad/keymap.c index 9c76582bbd..009db37ce2 100644 --- a/keyboards/lotus/keymaps/gridpad/keymap.c +++ b/keyboards/lotus/keymaps/gridpad/keymap.c @@ -41,12 +41,43 @@ const is31_led g_is31_leds[RGB_MATRIX_LED_COUNT] = { {0, CS16_SW4, CS17_SW4, CS18_SW4}, // LED 49 }; -// TODO: Add mapping led_config_t g_led_config = { { + // Key Matrix to LED Index + { 10, 14, 12, 20, 1, 2, 47, 22, }, + { 19, 46, 96, 95, 29, 78, 87, 42, }, + { 34, 11, 12, 0, 77, 0, 79, 21, }, + { 0, 0, 0, 0, 46, 0, 0, 0, }, }, { + // LED Index to Physical Potision + { 73, 10 }, // LED 1 + { 73, 24 }, // LED 2 + { 0, 10 }, // LED 10 + { 0, 0 }, // LED 11 + { 0, 37 }, // LED 12 + { 0, 24 }, // LED 14 + { 0, 64 }, // LED 19 + { 0, 50 }, // LED 20 + { 73, 64 }, // LED 21 + { 73, 50 }, // LED 22 + { 150, 64 }, // LED 28 + { 150, 50 }, // LED 29 + { 223, 64 }, // LED 34 + { 223, 37 }, // LED 42 + { 150, 10 }, // LED 46 + { 73, 37 }, // LED 47 + { 223, 0 }, // LED 77 + { 223, 24 }, // LED 78 + { 223, 50 }, // LED 79 + { 223, 10 }, // LED 87 + { 150, 37 }, // LED 95 + { 150, 24 }, // LED 96 }, { + // LED Index to Flag + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4 } }; + #define NUMPAD_ROWS 4 #define NUMPAD_COLS 8 const uint16_t PROGMEM keymaps[][NUMPAD_ROWS][NUMPAD_COLS] = { diff --git a/keyboards/lotus/led.py b/keyboards/lotus/led.py index e0d4009c00..915de489bc 100644 --- a/keyboards/lotus/led.py +++ b/keyboards/lotus/led.py @@ -14,8 +14,12 @@ from collections import OrderedDict # Rows and columns in the electrical keyboard matrix. # Equivalent to QMK's macros: MATRIX_ROWS and MATRIX_COLS +# Keyboard MATRIX_ROWS = 8 MATRIX_COLS = 16 +# Gridpad +#MATRIX_ROWS = 4 +#MATRIX_COLS = 8 LED_FLAG_NONE = 0x00 LED_FLAG_MODIFIER = 0x01 @@ -150,21 +154,21 @@ ansi = [ { "id": "92", "x":1120, "y": 542, "matrix": (15,2) }, ] -numpad = [ - { "id": "11", "x":1332, "y": 158, "matrix": (1,2) }, - { "id": "12", "x":1395, "y": 158, "matrix": (2,2) }, - { "id": "46", "x":1460, "y": 158, "matrix": (4,3) }, - { "id": "77", "x":1523, "y": 158, "matrix": (4,2) }, +gridpad = [ + { "id": "11", "x":1332, "y": 158, "matrix": (1,2) }, + { "id": "12", "x":1395, "y": 158, "matrix": (2,2) }, + { "id": "46", "x":1460, "y": 158, "matrix": (4,3) }, + { "id": "77", "x":1523, "y": 158, "matrix": (4,2) }, - { "id": "10", "x":1332, "y": 219, "matrix": (0,0) }, - { "id": "1", "x":1395, "y": 219, "matrix": (4,0) }, - { "id": "46", "x":1460, "y": 219, "matrix": (1,1) }, - { "id": "87", "x":1523, "y": 219, "matrix": (6,1) }, + { "id": "10", "x":1332, "y": 219, "matrix": (0,0) }, + { "id": "1", "x":1395, "y": 219, "matrix": (4,0) }, + { "id": "46", "x":1460, "y": 219, "matrix": (1,1) }, + { "id": "87", "x":1523, "y": 219, "matrix": (6,1) }, - { "id": "14", "x":1332, "y": 294, "matrix": (1,0) }, - { "id": "2", "x":1395, "y": 294, "matrix": (5,0) }, - { "id": "96", "x":1460, "y": 294, "matrix": (2,1) }, # Plus - { "id": "78", "x":1523, "y": 294 }, # Plus + { "id": "14", "x":1332, "y": 294, "matrix": (1,0) }, + { "id": "2", "x":1395, "y": 294, "matrix": (5,0) }, + { "id": "96", "x":1460, "y": 294, "matrix": (2,1) }, + { "id": "78", "x":1523, "y": 294, "matrix": (5,1) }, { "id": "12", "x":1332, "y": 368, "matrix": (2,0) }, { "id": "47", "x":1395, "y": 368, "matrix": (6,0) }, @@ -173,11 +177,11 @@ numpad = [ { "id": "20", "x":1332, "y": 443, "matrix": (3,0) }, { "id": "22", "x":1395, "y": 443, "matrix": (7,0) }, - { "id": "29", "x":1460, "y": 443, "matrix": (4,1) }, # Enter - { "id": "79", "x":1523, "y": 443 }, # Enter + { "id": "29", "x":1460, "y": 443, "matrix": (4,1) }, + { "id": "79", "x":1523, "y": 443, "matrix": (6,2) }, - { "id": "19", "x":1332, "y": 519, "matrix": (0,1) }, # 0 - { "id": "21", "x":1395, "y": 519 }, # 0 + { "id": "19", "x":1332, "y": 519, "matrix": (0,1) }, + { "id": "21", "x":1395, "y": 519, "matrix": (7,2) }, { "id": "28", "x":1460, "y": 519, "matrix": (5,1) }, { "id": "34", "x":1523, "y": 519, "matrix": (0,2) }, ] @@ -229,17 +233,14 @@ def print_matrix(layout, led_to_el, normalized): for row in led_to_el: print(" {", end='') for col in row: - print(f"{col}, ", end='') + print(f"{col: >4}, ", end='') print("},") print("}, {") - print(" // Key Matrix to LED Index") - for i, (x, y) in normalized.items(): - print(f" {{ {int(x)}, {int(y)} }}", end='') - if i < len(normalized): - print(',') - else: - print() + print(" // LED Index to Physical Potision") + for (i, (led_id, (x, y))) in enumerate(normalized.items()): + coords = f" {{ {int(x): >3}, {int(y): >3} }}," + print(f"{coords: <15} // LED {led_id}") print("}, {") print(" // LED Index to Flag") diff --git a/keyboards/lotus/lotus.h b/keyboards/lotus/lotus.h index 01ede894d2..0cf3649bc4 100644 --- a/keyboards/lotus/lotus.h +++ b/keyboards/lotus/lotus.h @@ -5,6 +5,7 @@ #include "quantum.h" +// The layouts are all mostly the same, except for the extra keys that the different layouts have #define LAYOUT_78_ansi( \ K110, K112, K113, K114, K115, K116, K117, K118, K119, K120, K121, K122, K126, K76, \ K1, K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, K12, K13, K15, \ @@ -44,6 +45,7 @@ { KC_NO, KC_NO, K31, KC_NO, KC_NO, K110, K34, K37, K39, KC_NO, K38, KC_NO, KC_NO, K40, K33, KC_NO }, \ } +// JIS is based off ANSI with a few extra keys #define LAYOUT_83_jis( \ K110, K112, K113, K114, K115, K116, K117, K118, K119, K120, K121, K122, K126, K76, \ K1, K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, K12, K13, K14, K15,\ @@ -63,6 +65,7 @@ { KC_NO, KC_NO, K31, KC_NO, KC_NO, K110, K34, K37, K39, KC_NO, K38, KC_NO, KC_NO, K40, K33, KC_NO,} \ } +// Same as gridpad with a few keys removed #define LAYOUT_numpad( \ H1, H2, H3, H4, \ K90, K95, K100, K105, \ @@ -77,3 +80,18 @@ { K108, H1, H2, KC_NO, H4, KC_NO, KC_NO, KC_NO }, \ { KC_NO, KC_NO, KC_NO, KC_NO, H3, KC_NO, KC_NO, KC_NO }, \ } + +#define LAYOUT_gridpad( \ + H1, H2, H3, H4, \ + K90, K95, K100, K105, \ + K91, K96, K101, K107, \ + K92, K97, K102, K106, \ + K93, K98, K103, K109, \ + K99, K110, K104, K108 \ +) \ +{ \ + { K90, K91, K92, K93, K95, K96, K97, K98 }, \ + { K99, K100, K101, K102, K103, K104, K105, K106 }, \ + { K108, H1, H2, KC_NO, H4, K107, K109, K110 }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, H3, KC_NO, KC_NO, KC_NO }, \ +}