summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2023-06-02 02:42:49 +0100
committerGitHub <noreply@github.com>2023-06-02 02:42:49 +0100
commit25c16b3adeb15466d75691162763ce062b2c6e64 (patch)
tree69648ca23dde6176ad84aef94cf469e83e6c734b
parent0a3ec7f59c0b809ae0a0a7a91c427c29c1c9b33c (diff)
Add *_MATRIX_LED_COUNT generation/validation (#19515)
* Add *_MATRIX_LED_COUNT parsing/validation * Disable parsing for now * Disable complexity check
-rw-r--r--data/mappings/info_config.hjson2
-rw-r--r--data/schemas/keyboard.jsonschema2
-rw-r--r--lib/python/qmk/info.py10
3 files changed, 13 insertions, 1 deletions
diff --git a/data/mappings/info_config.hjson b/data/mappings/info_config.hjson
index e53d90da39..da255892dc 100644
--- a/data/mappings/info_config.hjson
+++ b/data/mappings/info_config.hjson
@@ -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"},
@@ -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"},
diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema
index ba4a7eec55..f196e4467d 100644
--- a/data/schemas/keyboard.jsonschema
+++ b/data/schemas/keyboard.jsonschema
@@ -372,6 +372,7 @@
}
},
"driver": {"type": "string"},
+ "led_count": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"center_point": {
"type": "array",
"minItems": 2,
@@ -423,6 +424,7 @@
}
},
"driver": {"type": "string"},
+ "led_count": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"center_point": {
"type": "array",
"minItems": 2,
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py
index dbd26153d8..6628d825ce 100644
--- a/lib/python/qmk/info.py
+++ b/lib/python/qmk/info.py
@@ -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', {})
@@ -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