mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-08-03 16:00:34 -04:00
Merge remote-tracking branch 'upstream/develop' into xap
This commit is contained in:
@@ -197,6 +197,8 @@ def _coerce_led_token(_type, value):
|
||||
}
|
||||
if _type is Token.Literal.Number.Integer:
|
||||
return int(value)
|
||||
if _type is Token.Literal.Number.Float:
|
||||
return float(value)
|
||||
if _type is Token.Literal.Number.Hex:
|
||||
return int(value, 0)
|
||||
if _type is Token.Name and value in value_map.keys():
|
||||
@@ -233,7 +235,7 @@ def _parse_led_config(file, matrix_cols, matrix_rows):
|
||||
bracket_count -= 1
|
||||
else:
|
||||
# Assume any non whitespace value here is important enough to stash
|
||||
if _type in [Token.Literal.Number.Integer, Token.Literal.Number.Hex, Token.Name]:
|
||||
if _type in [Token.Literal.Number.Integer, Token.Literal.Number.Float, Token.Literal.Number.Hex, Token.Name]:
|
||||
if section == 1 and bracket_count == 3:
|
||||
matrix_raw.append(_coerce_led_token(_type, value))
|
||||
if section == 2 and bracket_count == 3:
|
||||
|
||||
@@ -15,20 +15,21 @@ def _gen_led_config(info_data):
|
||||
cols = info_data['matrix_size']['cols']
|
||||
rows = info_data['matrix_size']['rows']
|
||||
|
||||
led_config = None
|
||||
config_type = None
|
||||
if 'layout' in info_data.get('rgb_matrix', {}):
|
||||
led_config = info_data['rgb_matrix']['layout']
|
||||
config_type = 'rgb_matrix'
|
||||
elif 'layout' in info_data.get('led_matrix', {}):
|
||||
led_config = info_data['led_matrix']['layout']
|
||||
config_type = 'led_matrix'
|
||||
|
||||
lines = []
|
||||
if not led_config:
|
||||
if not config_type:
|
||||
return lines
|
||||
|
||||
matrix = [['NO_PIN'] * cols for i in range(rows)]
|
||||
matrix = [['NO_LED'] * cols for i in range(rows)]
|
||||
pos = []
|
||||
flags = []
|
||||
|
||||
led_config = info_data[config_type]['layout']
|
||||
for index, item in enumerate(led_config, start=0):
|
||||
if 'matrix' in item:
|
||||
(x, y) = item['matrix']
|
||||
@@ -36,6 +37,13 @@ def _gen_led_config(info_data):
|
||||
pos.append(f'{{ {item.get("x", 0)},{item.get("y", 0)} }}')
|
||||
flags.append(str(item.get('flags', 0)))
|
||||
|
||||
if config_type == 'rgb_matrix':
|
||||
lines.append('#ifdef RGB_MATRIX_ENABLE')
|
||||
lines.append('#include "rgb_matrix.h"')
|
||||
elif config_type == 'led_matrix':
|
||||
lines.append('#ifdef LED_MATRIX_ENABLE')
|
||||
lines.append('#include "led_matrix.h"')
|
||||
|
||||
lines.append('__attribute__ ((weak)) led_config_t g_led_config = {')
|
||||
lines.append(' {')
|
||||
for line in matrix:
|
||||
@@ -44,6 +52,7 @@ def _gen_led_config(info_data):
|
||||
lines.append(f' {{ {",".join(pos)} }},')
|
||||
lines.append(f' {{ {",".join(flags)} }},')
|
||||
lines.append('};')
|
||||
lines.append('#endif')
|
||||
|
||||
return lines
|
||||
|
||||
|
||||
Reference in New Issue
Block a user