|
@@ -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
|