CLI: Allow generation of both LED and RGB Matrix config (#22896)
This commit is contained in:
parent
e2517ff9a4
commit
1bebaa310a
@ -9,21 +9,25 @@ from qmk.path import normpath
|
|||||||
from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE
|
from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE
|
||||||
|
|
||||||
|
|
||||||
def _gen_led_config(info_data):
|
def _gen_led_configs(info_data):
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
if 'layout' in info_data.get('rgb_matrix', {}):
|
||||||
|
lines.extend(_gen_led_config(info_data, 'rgb_matrix'))
|
||||||
|
|
||||||
|
if 'layout' in info_data.get('led_matrix', {}):
|
||||||
|
lines.extend(_gen_led_config(info_data, 'led_matrix'))
|
||||||
|
|
||||||
|
return lines
|
||||||
|
|
||||||
|
|
||||||
|
def _gen_led_config(info_data, config_type):
|
||||||
"""Convert info.json content to g_led_config
|
"""Convert info.json content to g_led_config
|
||||||
"""
|
"""
|
||||||
cols = info_data['matrix_size']['cols']
|
cols = info_data['matrix_size']['cols']
|
||||||
rows = info_data['matrix_size']['rows']
|
rows = info_data['matrix_size']['rows']
|
||||||
|
|
||||||
config_type = None
|
|
||||||
if 'layout' in info_data.get('rgb_matrix', {}):
|
|
||||||
config_type = 'rgb_matrix'
|
|
||||||
elif 'layout' in info_data.get('led_matrix', {}):
|
|
||||||
config_type = 'led_matrix'
|
|
||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
if not config_type:
|
|
||||||
return lines
|
|
||||||
|
|
||||||
matrix = [['NO_LED'] * cols for _ in range(rows)]
|
matrix = [['NO_LED'] * cols for _ in range(rows)]
|
||||||
pos = []
|
pos = []
|
||||||
@ -53,6 +57,7 @@ def _gen_led_config(info_data):
|
|||||||
lines.append(f' {{ {", ".join(flags)} }},')
|
lines.append(f' {{ {", ".join(flags)} }},')
|
||||||
lines.append('};')
|
lines.append('};')
|
||||||
lines.append('#endif')
|
lines.append('#endif')
|
||||||
|
lines.append('')
|
||||||
|
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
@ -98,7 +103,7 @@ def generate_keyboard_c(cli):
|
|||||||
# Build the layouts.h file.
|
# Build the layouts.h file.
|
||||||
keyboard_h_lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '#include QMK_KEYBOARD_H', '']
|
keyboard_h_lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '#include QMK_KEYBOARD_H', '']
|
||||||
|
|
||||||
keyboard_h_lines.extend(_gen_led_config(kb_info_json))
|
keyboard_h_lines.extend(_gen_led_configs(kb_info_json))
|
||||||
keyboard_h_lines.extend(_gen_matrix_mask(kb_info_json))
|
keyboard_h_lines.extend(_gen_matrix_mask(kb_info_json))
|
||||||
|
|
||||||
# Show the results
|
# Show the results
|
||||||
|
@ -686,13 +686,9 @@ def _extract_led_config(info_data, keyboard):
|
|||||||
cols = info_data['matrix_size']['cols']
|
cols = info_data['matrix_size']['cols']
|
||||||
rows = info_data['matrix_size']['rows']
|
rows = info_data['matrix_size']['rows']
|
||||||
|
|
||||||
# Determine what feature owns g_led_config
|
for feature in ['rgb_matrix', 'led_matrix']:
|
||||||
feature = None
|
if info_data.get('features', {}).get(feature, False) or feature in info_data:
|
||||||
for feat in ['rgb_matrix', 'led_matrix']:
|
|
||||||
if info_data.get('features', {}).get(feat, False) or feat in info_data:
|
|
||||||
feature = feat
|
|
||||||
|
|
||||||
if feature:
|
|
||||||
# Only attempt search if dd led config is missing
|
# Only attempt search if dd led config is missing
|
||||||
if 'layout' not in info_data.get(feature, {}):
|
if 'layout' not in info_data.get(feature, {}):
|
||||||
# Process
|
# Process
|
||||||
|
Loading…
Reference in New Issue
Block a user