From 179049dfc9310a46d2d3210334e0a62c21b1d3d7 Mon Sep 17 00:00:00 2001 From: zvecr Date: Fri, 30 Sep 2022 00:16:11 +0100 Subject: [PATCH] Fix some matrix effects --- data/constants/led_matrix_0.0.1.json | 4 ++- data/constants/rgb_matrix_0.0.1.json | 12 +++++--- .../qmk/xap/gen_firmware/inline_generator.py | 29 ++++++++++++++++--- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/data/constants/led_matrix_0.0.1.json b/data/constants/led_matrix_0.0.1.json index 5d59c7a14ce..769f3d3fbad 100644 --- a/data/constants/led_matrix_0.0.1.json +++ b/data/constants/led_matrix_0.0.1.json @@ -1,6 +1,8 @@ { "groups": { - "reactive": {} + "reactive": { + "define": "LED_MATRIX_KEYREACTIVE_ENABLED" + } }, "effects": { "0x00": { diff --git a/data/constants/rgb_matrix_0.0.1.json b/data/constants/rgb_matrix_0.0.1.json index 350dcdeb074..114126841a0 100644 --- a/data/constants/rgb_matrix_0.0.1.json +++ b/data/constants/rgb_matrix_0.0.1.json @@ -1,7 +1,11 @@ { "groups": { - "framebuffer": {}, - "reactive": {} + "framebuffer": { + "define": "RGB_MATRIX_FRAMEBUFFER_EFFECTS" + }, + "reactive": { + "define": "RGB_MATRIX_KEYREACTIVE_ENABLED" + } }, "effects": { "0x00": { @@ -109,11 +113,11 @@ "group": "reactive" }, "0x21": { - "key": "RGB_MATRIX_SOLID_REACTIVE", + "key": "SOLID_REACTIVE", "group": "reactive" }, "0x22": { - "key": "RGB_MATRIX_SOLID_REACTIVE_WIDE", + "key": "SOLID_REACTIVE_WIDE", "group": "reactive" }, "0x23": { diff --git a/lib/python/qmk/xap/gen_firmware/inline_generator.py b/lib/python/qmk/xap/gen_firmware/inline_generator.py index e6fe3f60223..c987fdda160 100755 --- a/lib/python/qmk/xap/gen_firmware/inline_generator.py +++ b/lib/python/qmk/xap/gen_firmware/inline_generator.py @@ -316,6 +316,7 @@ def _append_broadcast_messages(lines, container): def _append_lighting_map(lines, feature, spec): """TODO: """ + groups = spec.get('groups', {}) ifdef_prefix = PREFIX_MAP[feature]['ifdef'] def_prefix = PREFIX_MAP[feature]['def'] @@ -324,10 +325,19 @@ def _append_lighting_map(lines, feature, spec): define = obj["define"] offset = f' + {obj["offset"]}' if obj["offset"] else '' - lines.append(f''' + line = f''' #ifdef {ifdef_prefix}_{define} {{ {id}, {def_prefix}_{define}{offset}}}, -#endif''') +#endif''' + + group = groups.get(obj.get("group", None), {}).get('define', None) + if group: + line = f''' +#ifdef {group} +{line} +#endif''' + + lines.append(line) lines.append('};') @@ -355,16 +365,27 @@ uint8_t xap2{feature}(uint8_t val) {{ def _append_lighting_bitmask(lines, feature, spec): """TODO: """ + groups = spec.get('groups', {}) ifdef_prefix = PREFIX_MAP[feature]['ifdef'] lines.append(f"static const uint64_t ENABLED_{feature.upper()}_EFFECTS = 0") for id, obj in spec.get('effects', {}).items(): define = obj["define"] - lines.append(f''' + line = f''' #ifdef {ifdef_prefix}_{define} | (1ULL << {id}) -#endif''') +#endif''' + + group = groups.get(obj.get("group", None), {}).get('define', None) + if group: + line = f''' +#ifdef {group} +{line} +#endif''' + + lines.append(line) + lines.append(';')