Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add *_MATRIX_LED_COUNT generation/validation #19515

Merged
merged 3 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions data/mappings/info_config.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"LED_MATRIX_SPLIT": {"info_key": "led_matrix.split_count", "value_type": "array.int"},
"LED_MATRIX_TIMEOUT": {"info_key": "led_matrix.timeout", "value_type": "int"},
"LED_MATRIX_VAL_STEP": {"info_key": "led_matrix.val_steps", "value_type": "int"},
"LED_MATRIX_LED_COUNT": {"info_key": "led_matrix.led_count", "value_type": "int", "to_json": false},

// LUFA Bootloader
"QMK_ESC_INPUT": {"info_key": "qmk_lufa_bootloader.esc_input"},
Expand Down Expand Up @@ -109,6 +110,7 @@
"RGB_MATRIX_SPLIT": {"info_key": "rgb_matrix.split_count", "value_type": "array.int"},
"RGB_MATRIX_TIMEOUT": {"info_key": "rgb_matrix.timeout", "value_type": "int"},
"RGB_MATRIX_VAL_STEP": {"info_key": "rgb_matrix.val_steps", "value_type": "int"},
"RGB_MATRIX_LED_COUNT": {"info_key": "rgb_matrix.led_count", "value_type": "int", "to_json": false},

// RGBLight
"RGBLED_NUM": {"info_key": "rgblight.led_count", "value_type": "int"},
Expand Down
2 changes: 2 additions & 0 deletions data/schemas/keyboard.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@
}
},
"driver": {"type": "string"},
"led_count": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"center_point": {
"type": "array",
"minItems": 2,
Expand Down Expand Up @@ -423,6 +424,7 @@
}
},
"driver": {"type": "string"},
"led_count": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"center_point": {
"type": "array",
"minItems": 2,
Expand Down
10 changes: 9 additions & 1 deletion lib/python/qmk/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _get_key_left_position(key):
return key['x'] - 0.25 if key.get('h', 1) == 2 and key.get('w', 1) == 1.25 else key['x']


def _additional_validation(keyboard, info_data):
def _additional_validation(keyboard, info_data): # noqa: C901
"""Non schema checks
"""
layouts = info_data.get('layouts', {})
Expand Down Expand Up @@ -105,6 +105,14 @@ def _additional_validation(keyboard, info_data):
if not decl.get("aliases", []):
_log_error(info_data, f'Keycode {decl["key"]} has no short form alias')

# Ensure LED config is somewhat valid
for feature in ['rgb_matrix', 'led_matrix']:
if feature in info_data and all(key in info_data[feature] for key in ["layout", "led_count"]):
layout_count = len(info_data[feature]["layout"])
led_count = info_data[feature]["led_count"]
if led_count != layout_count:
_log_warning(info_data, '%s: mismatch between LED count (%d) and layout items (%d)' % (feature, led_count, layout_count))


def _validate(keyboard, info_data):
"""Perform various validation on the provided info.json data
Expand Down