mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-08-04 00:10:42 -04:00
Decouple lighting_map from XAP
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from qmk.json_schema import json_load
|
||||
|
||||
|
||||
def list_lighting_versions(feature):
|
||||
"""Return available versions - sorted newest first
|
||||
"""
|
||||
ret = []
|
||||
for file in Path('data/constants/lighting/').glob(f'{feature}_[0-9].[0-9].[0-9].hjson'):
|
||||
ret.append(file.stem.split('_')[-1])
|
||||
|
||||
ret.sort(reverse=True)
|
||||
return ret
|
||||
|
||||
|
||||
def load_lighting_spec(feature, version='latest'):
|
||||
"""Build lighting data from the requested spec file
|
||||
"""
|
||||
if version == 'latest':
|
||||
version = list_lighting_versions(feature)[0]
|
||||
|
||||
spec = json_load(Path(f'data/constants/lighting/{feature}_{version}.hjson'))
|
||||
|
||||
# preprocess for gross rgblight "mode + n"
|
||||
for obj in spec.get('effects', {}).values():
|
||||
define = obj['key']
|
||||
offset = 0
|
||||
found = re.match('(.*)_(\\d+)$', define)
|
||||
if found:
|
||||
define = found.group(1)
|
||||
offset = int(found.group(2)) - 1
|
||||
obj['define'] = define
|
||||
obj['offset'] = offset
|
||||
|
||||
return spec
|
||||
Reference in New Issue
Block a user