summaryrefslogtreecommitdiffstats
path: root/lib/python/qmk/cli/generate
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2022-02-27 12:40:01 +0000
committerQMK Bot <hello@qmk.fm>2022-02-27 12:40:01 +0000
commit3c7c9bdd8614cd332b4db7ab6d05429d513ba11d (patch)
tree81ca3c2dc35766e7f456e607a0caeb279a3ca695 /lib/python/qmk/cli/generate
parent48f06ae6463f1199c059c05f617304952f6dd110 (diff)
parent779c7debcfff1a4a3ad578a0c12bdd50cba11039 (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'lib/python/qmk/cli/generate')
-rwxr-xr-xlib/python/qmk/cli/generate/config_h.py36
-rwxr-xr-xlib/python/qmk/cli/generate/layouts.py16
-rwxr-xr-xlib/python/qmk/cli/generate/rules_mk.py2
3 files changed, 27 insertions, 27 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']))
diff --git a/lib/python/qmk/cli/generate/layouts.py b/lib/python/qmk/cli/generate/layouts.py
index e44266e1c8..a21311bd49 100755
--- a/lib/python/qmk/cli/generate/layouts.py
+++ b/lib/python/qmk/cli/generate/layouts.py
@@ -40,16 +40,12 @@ def generate_layouts(cli):
# Build the layouts.h file.
layouts_h_lines = ['/* This file was generated by `qmk generate-layouts`. Do not edit or copy.', ' */', '', '#pragma once']
- if 'matrix_pins' in kb_info_json:
- if 'direct' in kb_info_json['matrix_pins']:
- col_num = len(kb_info_json['matrix_pins']['direct'][0])
- row_num = len(kb_info_json['matrix_pins']['direct'])
- elif 'cols' in kb_info_json['matrix_pins'] and 'rows' in kb_info_json['matrix_pins']:
- col_num = len(kb_info_json['matrix_pins']['cols'])
- row_num = len(kb_info_json['matrix_pins']['rows'])
- else:
- cli.log.error('%s: Invalid matrix config.', cli.config.generate_layouts.keyboard)
- return False
+ if 'matrix_size' not in kb_info_json:
+ cli.log.error('%s: Invalid matrix config.', cli.config.generate_layouts.keyboard)
+ return False
+
+ col_num = kb_info_json['matrix_size']['cols']
+ row_num = kb_info_json['matrix_size']['rows']
for layout_name in kb_info_json['layouts']:
if kb_info_json['layouts'][layout_name]['c_macro']:
diff --git a/lib/python/qmk/cli/generate/rules_mk.py b/lib/python/qmk/cli/generate/rules_mk.py
index 5d8d7cc8a7..ce824f6378 100755
--- a/lib/python/qmk/cli/generate/rules_mk.py
+++ b/lib/python/qmk/cli/generate/rules_mk.py
@@ -29,7 +29,7 @@ def process_mapping_rule(kb_info_json, rules_key, info_dict):
if key_type in ['array', 'list']:
return f'{rules_key} ?= {" ".join(rules_value)}'
elif key_type == 'bool':
- return f'{rules_key} ?= {"on" if rules_value else "off"}'
+ return f'{rules_key} ?= {"yes" if rules_value else "no"}'
elif key_type == 'mapping':
return '\n'.join([f'{key} ?= {value}' for key, value in rules_value.items()])