summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/generate/config_h.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/qmk/cli/generate/config_h.py')
-rwxr-xr-xlib/python/qmk/cli/generate/config_h.py36
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py
index 6b1012fae7..24bbbdf517 100755
--- a/lib/python/qmk/cli/generate/config_h.py
+++ b/lib/python/qmk/cli/generate/config_h.py
@@ -21,18 +21,7 @@ def direct_pins(direct_pins, postfix):
cols = ','.join(map(str, [col or 'NO_PIN' for col in row]))
rows.append('{' + cols + '}')
- col_count = len(direct_pins[0])
- row_count = len(direct_pins)
-
return f"""
-#ifndef MATRIX_COLS{postfix}
-# define MATRIX_COLS{postfix} {col_count}
-#endif // MATRIX_COLS{postfix}
-
-#ifndef MATRIX_ROWS{postfix}
-# define MATRIX_ROWS{postfix} {row_count}
-#endif // MATRIX_ROWS{postfix}
-
#ifndef DIRECT_PINS{postfix}
# define DIRECT_PINS{postfix} {{ {", ".join(rows)} }}
#endif // DIRECT_PINS{postfix}
@@ -42,14 +31,9 @@ def direct_pins(direct_pins, postfix):
def pin_array(define, pins, postfix):
"""Return the config.h lines that set a pin array.
"""
- pin_num = len(pins)
pin_array = ', '.join(map(str, [pin or 'NO_PIN' for pin in pins]))
return f"""
-#ifndef {define}S{postfix}
-# define {define}S{postfix} {pin_num}
-#endif // {define}S{postfix}
-
#ifndef {define}_PINS{postfix}
# define {define}_PINS{postfix} {{ {pin_array} }}
#endif // {define}_PINS{postfix}
@@ -73,6 +57,24 @@ def matrix_pins(matrix_pins, postfix=''):
return '\n'.join(pins)
+def generate_matrix_size(kb_info_json, config_h_lines):
+ """Add the matrix size to the config.h.
+ """
+ if 'matrix_pins' in kb_info_json:
+ col_count = kb_info_json['matrix_size']['cols']
+ row_count = kb_info_json['matrix_size']['rows']
+
+ config_h_lines.append(f"""
+#ifndef MATRIX_COLS
+# define MATRIX_COLS {col_count}
+#endif // MATRIX_COLS
+
+#ifndef MATRIX_ROWS
+# define MATRIX_ROWS {row_count}
+#endif // MATRIX_ROWS
+""")
+
+
def generate_config_items(kb_info_json, config_h_lines):
"""Iterate through the info_config map to generate basic config values.
"""
@@ -183,6 +185,8 @@ def generate_config_h(cli):
generate_config_items(kb_info_json, config_h_lines)
+ generate_matrix_size(kb_info_json, config_h_lines)
+
if 'matrix_pins' in kb_info_json:
config_h_lines.append(matrix_pins(kb_info_json['matrix_pins']))