Fix issues with data driven split keyboards (#16457)
This commit is contained in:
parent
e884414e1e
commit
779c7debcf
4 changed files with 32 additions and 27 deletions
|
@ -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']))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue