Decouple lighting_map from XAP

This commit is contained in:
zvecr 2023-03-21 15:05:40 +00:00
parent 5eed80c66b
commit 42895141de
13 changed files with 1206 additions and 1178 deletions

View File

@ -58,6 +58,7 @@ subcommands = [
'qmk.cli.generate.keyboard_h', 'qmk.cli.generate.keyboard_h',
'qmk.cli.generate.keycodes', 'qmk.cli.generate.keycodes',
'qmk.cli.generate.keycodes_tests', 'qmk.cli.generate.keycodes_tests',
'qmk.cli.generate.lighting_map',
'qmk.cli.generate.rgb_breathe_table', 'qmk.cli.generate.rgb_breathe_table',
'qmk.cli.generate.rules_mk', 'qmk.cli.generate.rules_mk',
'qmk.cli.generate.version_h', 'qmk.cli.generate.version_h',
@ -83,7 +84,6 @@ subcommands = [
'qmk.cli.xap', 'qmk.cli.xap',
'qmk.cli.xap.generate_docs', 'qmk.cli.xap.generate_docs',
'qmk.cli.xap.generate_json', 'qmk.cli.xap.generate_json',
'qmk.cli.xap.generate_lighting',
'qmk.cli.xap.generate_python', 'qmk.cli.xap.generate_python',
'qmk.cli.xap.generate_qmk', 'qmk.cli.xap.generate_qmk',
] ]

View File

@ -2,7 +2,7 @@ from milc import cli
from qmk.path import normpath from qmk.path import normpath
from qmk.commands import dump_lines from qmk.commands import dump_lines
from qmk.xap.common import load_lighting_spec from qmk.lighting import load_lighting_spec
from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE
PREFIX_MAP = { PREFIX_MAP = {
@ -21,8 +21,21 @@ PREFIX_MAP = {
} }
def _always_enabled(id):
"""Assumption that first effect is always enabled
"""
return id == '0x00'
def _wrap_ifdef(line, define):
return f'''
#ifdef {define}
{line}
#endif'''
def _append_lighting_map(lines, feature, spec): def _append_lighting_map(lines, feature, spec):
"""TODO: """Translate effect to 'constant id'->'firmware id' lookup table
""" """
groups = spec.get('groups', {}) groups = spec.get('groups', {})
ifdef_prefix = PREFIX_MAP[feature]['ifdef'] ifdef_prefix = PREFIX_MAP[feature]['ifdef']
@ -33,17 +46,14 @@ def _append_lighting_map(lines, feature, spec):
define = obj['define'] define = obj['define']
offset = f' + {obj["offset"]}' if obj['offset'] else '' offset = f' + {obj["offset"]}' if obj['offset'] else ''
line = f''' line = f'{{ {id}, {def_prefix}_{define}{offset}}},'
#ifdef {ifdef_prefix}_{define}
{{ {id}, {def_prefix}_{define}{offset}}}, if not _always_enabled(id):
#endif''' line = _wrap_ifdef(line, f'{ifdef_prefix}_{define}')
group = groups.get(obj.get('group', None), {}).get('define', None) group = groups.get(obj.get('group', None), {}).get('define', None)
if group: if group:
line = f''' line = _wrap_ifdef(line, group)
#ifdef {group}
{line}
#endif'''
lines.append(line) lines.append(line)
@ -52,7 +62,7 @@ def _append_lighting_map(lines, feature, spec):
# add helper funcs # add helper funcs
lines.append( lines.append(
f''' f'''
uint8_t {feature}2xap(uint8_t val) {{ uint8_t {feature}_effect_to_id(uint8_t val) {{
for(uint8_t i = 0; i < ARRAY_SIZE({feature}_effect_map); i++) {{ for(uint8_t i = 0; i < ARRAY_SIZE({feature}_effect_map); i++) {{
if (pgm_read_byte(&{feature}_effect_map[i][1]) == val) if (pgm_read_byte(&{feature}_effect_map[i][1]) == val)
return pgm_read_byte(&{feature}_effect_map[i][0]); return pgm_read_byte(&{feature}_effect_map[i][0]);
@ -60,7 +70,7 @@ uint8_t {feature}2xap(uint8_t val) {{
return 0xFF; return 0xFF;
}} }}
uint8_t xap2{feature}(uint8_t val) {{ uint8_t {feature}_id_to_effect(uint8_t val) {{
for(uint8_t i = 0; i < ARRAY_SIZE({feature}_effect_map); i++) {{ for(uint8_t i = 0; i < ARRAY_SIZE({feature}_effect_map); i++) {{
if (pgm_read_byte(&{feature}_effect_map[i][0]) == val) if (pgm_read_byte(&{feature}_effect_map[i][0]) == val)
return pgm_read_byte(&{feature}_effect_map[i][1]); return pgm_read_byte(&{feature}_effect_map[i][1]);
@ -70,8 +80,8 @@ uint8_t xap2{feature}(uint8_t val) {{
) )
def _append_lighting_bitmask(lines, feature, spec): def _append_lighting_bit_field(lines, feature, spec):
"""TODO: """Translate effect to bit of bit-field
""" """
groups = spec.get('groups', {}) groups = spec.get('groups', {})
ifdef_prefix = PREFIX_MAP[feature]['ifdef'] ifdef_prefix = PREFIX_MAP[feature]['ifdef']
@ -80,49 +90,37 @@ def _append_lighting_bitmask(lines, feature, spec):
for id, obj in spec.get('effects', {}).items(): for id, obj in spec.get('effects', {}).items():
define = obj['define'] define = obj['define']
line = f''' line = f' | (1ULL << {id})'
#ifdef {ifdef_prefix}_{define}
| (1ULL << {id}) if not _always_enabled(id):
#endif''' line = _wrap_ifdef(line, f'{ifdef_prefix}_{define}')
group = groups.get(obj.get('group', None), {}).get('define', None) group = groups.get(obj.get('group', None), {}).get('define', None)
if group: if group:
line = f''' line = _wrap_ifdef(line, group)
#ifdef {group}
{line}
#endif'''
lines.append(line) lines.append(line)
lines.append('};') lines.append('};')
def _append_lighting_mapping(lines): def _append_lighting_mapping(lines, feature):
"""TODO: """Generate lookup table and bit-field of effect
""" """
# TODO: remove bodge for always enabled effects
lines.append('''
#define RGBLIGHT_EFFECT_STATIC_LIGHT
#define ENABLE_RGB_MATRIX_SOLID_COLOR
#define ENABLE_LED_MATRIX_SOLID
''')
for feature in PREFIX_MAP.keys():
spec = load_lighting_spec(feature) spec = load_lighting_spec(feature)
lines.append(f'#ifdef {feature.upper()}_ENABLE') _append_lighting_bit_field(lines, feature, spec)
_append_lighting_map(lines, feature, spec) _append_lighting_map(lines, feature, spec)
_append_lighting_bitmask(lines, feature, spec)
lines.append(f'#endif //{feature.upper()}_ENABLE')
@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to') @cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") @cli.argument('-q', '--quiet', arg_only=True, action='store_true', help='Quiet mode, only output error messages')
@cli.argument('-f', '--feature', required=True, help='Feature to generate map', choices=PREFIX_MAP.keys())
@cli.subcommand('Generates effect header.') @cli.subcommand('Generates effect header.')
def xap_generate_lighting_map(cli): def generate_lighting_map(cli):
# Preamble # Preamble
lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '#pragma once', '// clang-format off'] lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '#pragma once', '// clang-format off']
_append_lighting_mapping(lines) _append_lighting_mapping(lines, cli.args.feature)
dump_lines(cli.args.output, lines, cli.args.quiet) dump_lines(cli.args.output, lines, cli.args.quiet)

View File

@ -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

View File

@ -1,7 +1,5 @@
"""This script handles the XAP protocol data files. """This script handles the XAP protocol data files.
""" """
import re
import os
import hjson import hjson
import jsonschema import jsonschema
from pathlib import Path from pathlib import Path
@ -10,6 +8,7 @@ from jinja2 import Environment, FileSystemLoader, select_autoescape
import qmk.constants import qmk.constants
from qmk.git import git_get_version from qmk.git import git_get_version
from qmk.lighting import load_lighting_spec
from qmk.json_schema import json_load, validate, merge_ordered_dicts from qmk.json_schema import json_load, validate, merge_ordered_dicts
from qmk.makefile import parse_rules_mk_file from qmk.makefile import parse_rules_mk_file
from qmk.decorators import lru_cache from qmk.decorators import lru_cache
@ -21,41 +20,8 @@ USERSPACE_DIR = Path('users')
XAP_SPEC = 'xap.hjson' XAP_SPEC = 'xap.hjson'
def list_lighting_versions(feature):
"""Return available versions - sorted newest first
"""
ret = []
for file in Path('data/constants/').glob(f'{feature}_[0-9].[0-9].[0-9].json'):
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/{feature}_{version}.json'))
# 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
def _get_jinja2_env(data_templates_xap_subdir: str): def _get_jinja2_env(data_templates_xap_subdir: str):
templates_dir = os.path.join(qmk.constants.QMK_FIRMWARE, 'data', 'templates', 'xap', data_templates_xap_subdir) templates_dir = qmk.constants.QMK_FIRMWARE / 'data/templates/xap' / data_templates_xap_subdir
j2 = Environment(loader=FileSystemLoader(templates_dir), autoescape=select_autoescape(), lstrip_blocks=True, trim_blocks=True) j2 = Environment(loader=FileSystemLoader(templates_dir), autoescape=select_autoescape(), lstrip_blocks=True, trim_blocks=True)
return j2 return j2

View File

@ -0,0 +1,263 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
/*******************************************************************************
88888888888 888 d8b .d888 d8b 888 d8b
888 888 Y8P d88P" Y8P 888 Y8P
888 888 888 888
888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b
888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K
888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b.
888 888 888 888 X88 888 888 888 Y8b. 888 X88
888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P'
888 888
888 888
888 888
.d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888
d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888
888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888
Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888
"Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888
888
Y8b d88P
"Y88P"
*******************************************************************************/
#pragma once
// clang-format off
enum { ENABLED_LED_MATRIX_EFFECTS = 0
| (1ULL << 0x00)
#ifdef ENABLE_LED_MATRIX_ALPHAS_MODS
| (1ULL << 0x01)
#endif
#ifdef ENABLE_LED_MATRIX_BREATHING
| (1ULL << 0x02)
#endif
#ifdef ENABLE_LED_MATRIX_BAND
| (1ULL << 0x03)
#endif
#ifdef ENABLE_LED_MATRIX_BAND_PINWHEEL
| (1ULL << 0x04)
#endif
#ifdef ENABLE_LED_MATRIX_BAND_SPIRAL
| (1ULL << 0x05)
#endif
#ifdef ENABLE_LED_MATRIX_CYCLE_LEFT_RIGHT
| (1ULL << 0x06)
#endif
#ifdef ENABLE_LED_MATRIX_CYCLE_UP_DOWN
| (1ULL << 0x07)
#endif
#ifdef ENABLE_LED_MATRIX_CYCLE_OUT_IN
| (1ULL << 0x08)
#endif
#ifdef ENABLE_LED_MATRIX_DUAL_BEACON
| (1ULL << 0x09)
#endif
#ifdef ENABLE_LED_MATRIX_WAVE_LEFT_RIGHT
| (1ULL << 0x0A)
#endif
#ifdef ENABLE_LED_MATRIX_WAVE_UP_DOWN
| (1ULL << 0x0B)
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_SIMPLE
| (1ULL << 0x0C)
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE
| (1ULL << 0x0D)
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE
| (1ULL << 0x0E)
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_CROSS
| (1ULL << 0x0F)
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS
| (1ULL << 0x10)
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS
| (1ULL << 0x11)
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS
| (1ULL << 0x12)
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_SPLASH
| (1ULL << 0x13)
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_MULTISPLASH
| (1ULL << 0x14)
#endif
#endif
};
static const uint8_t led_matrix_effect_map[][2] PROGMEM = {
{ 0x00, LED_MATRIX_SOLID},
#ifdef ENABLE_LED_MATRIX_ALPHAS_MODS
{ 0x01, LED_MATRIX_ALPHAS_MODS},
#endif
#ifdef ENABLE_LED_MATRIX_BREATHING
{ 0x02, LED_MATRIX_BREATHING},
#endif
#ifdef ENABLE_LED_MATRIX_BAND
{ 0x03, LED_MATRIX_BAND},
#endif
#ifdef ENABLE_LED_MATRIX_BAND_PINWHEEL
{ 0x04, LED_MATRIX_BAND_PINWHEEL},
#endif
#ifdef ENABLE_LED_MATRIX_BAND_SPIRAL
{ 0x05, LED_MATRIX_BAND_SPIRAL},
#endif
#ifdef ENABLE_LED_MATRIX_CYCLE_LEFT_RIGHT
{ 0x06, LED_MATRIX_CYCLE_LEFT_RIGHT},
#endif
#ifdef ENABLE_LED_MATRIX_CYCLE_UP_DOWN
{ 0x07, LED_MATRIX_CYCLE_UP_DOWN},
#endif
#ifdef ENABLE_LED_MATRIX_CYCLE_OUT_IN
{ 0x08, LED_MATRIX_CYCLE_OUT_IN},
#endif
#ifdef ENABLE_LED_MATRIX_DUAL_BEACON
{ 0x09, LED_MATRIX_DUAL_BEACON},
#endif
#ifdef ENABLE_LED_MATRIX_WAVE_LEFT_RIGHT
{ 0x0A, LED_MATRIX_WAVE_LEFT_RIGHT},
#endif
#ifdef ENABLE_LED_MATRIX_WAVE_UP_DOWN
{ 0x0B, LED_MATRIX_WAVE_UP_DOWN},
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_SIMPLE
{ 0x0C, LED_MATRIX_SOLID_REACTIVE_SIMPLE},
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE
{ 0x0D, LED_MATRIX_SOLID_REACTIVE_WIDE},
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE
{ 0x0E, LED_MATRIX_SOLID_REACTIVE_MULTIWIDE},
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_CROSS
{ 0x0F, LED_MATRIX_SOLID_REACTIVE_CROSS},
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS
{ 0x10, LED_MATRIX_SOLID_REACTIVE_MULTICROSS},
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS
{ 0x11, LED_MATRIX_SOLID_REACTIVE_NEXUS},
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS
{ 0x12, LED_MATRIX_SOLID_REACTIVE_MULTINEXUS},
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_SPLASH
{ 0x13, LED_MATRIX_SOLID_SPLASH},
#endif
#endif
#ifdef LED_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_LED_MATRIX_SOLID_MULTISPLASH
{ 0x14, LED_MATRIX_SOLID_MULTISPLASH},
#endif
#endif
};
uint8_t led_matrix_effect_to_id(uint8_t val) {
for(uint8_t i = 0; i < ARRAY_SIZE(led_matrix_effect_map); i++) {
if (pgm_read_byte(&led_matrix_effect_map[i][1]) == val)
return pgm_read_byte(&led_matrix_effect_map[i][0]);
}
return 0xFF;
}
uint8_t led_matrix_id_to_effect(uint8_t val) {
for(uint8_t i = 0; i < ARRAY_SIZE(led_matrix_effect_map); i++) {
if (pgm_read_byte(&led_matrix_effect_map[i][0]) == val)
return pgm_read_byte(&led_matrix_effect_map[i][1]);
}
return 0xFF;
}

View File

@ -0,0 +1,477 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
/*******************************************************************************
88888888888 888 d8b .d888 d8b 888 d8b
888 888 Y8P d88P" Y8P 888 Y8P
888 888 888 888
888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b
888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K
888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b.
888 888 888 888 X88 888 888 888 Y8b. 888 X88
888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P'
888 888
888 888
888 888
.d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888
d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888
888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888
Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888
"Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888
888
Y8b d88P
"Y88P"
*******************************************************************************/
#pragma once
// clang-format off
enum { ENABLED_RGB_MATRIX_EFFECTS = 0
| (1ULL << 0x00)
#ifdef ENABLE_RGB_MATRIX_ALPHAS_MODS
| (1ULL << 0x01)
#endif
#ifdef ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN
| (1ULL << 0x02)
#endif
#ifdef ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT
| (1ULL << 0x03)
#endif
#ifdef ENABLE_RGB_MATRIX_BREATHING
| (1ULL << 0x04)
#endif
#ifdef ENABLE_RGB_MATRIX_BAND_SAT
| (1ULL << 0x05)
#endif
#ifdef ENABLE_RGB_MATRIX_BAND_VAL
| (1ULL << 0x06)
#endif
#ifdef ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
| (1ULL << 0x07)
#endif
#ifdef ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL
| (1ULL << 0x08)
#endif
#ifdef ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT
| (1ULL << 0x09)
#endif
#ifdef ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL
| (1ULL << 0x0A)
#endif
#ifdef ENABLE_RGB_MATRIX_CYCLE_ALL
| (1ULL << 0x0B)
#endif
#ifdef ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
| (1ULL << 0x0C)
#endif
#ifdef ENABLE_RGB_MATRIX_CYCLE_UP_DOWN
| (1ULL << 0x0D)
#endif
#ifdef ENABLE_RGB_MATRIX_CYCLE_OUT_IN
| (1ULL << 0x0E)
#endif
#ifdef ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
| (1ULL << 0x0F)
#endif
#ifdef ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
| (1ULL << 0x10)
#endif
#ifdef ENABLE_RGB_MATRIX_CYCLE_PINWHEEL
| (1ULL << 0x11)
#endif
#ifdef ENABLE_RGB_MATRIX_CYCLE_SPIRAL
| (1ULL << 0x12)
#endif
#ifdef ENABLE_RGB_MATRIX_DUAL_BEACON
| (1ULL << 0x13)
#endif
#ifdef ENABLE_RGB_MATRIX_RAINBOW_BEACON
| (1ULL << 0x14)
#endif
#ifdef ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS
| (1ULL << 0x15)
#endif
#ifdef ENABLE_RGB_MATRIX_RAINDROPS
| (1ULL << 0x16)
#endif
#ifdef ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
| (1ULL << 0x17)
#endif
#ifdef ENABLE_RGB_MATRIX_HUE_BREATHING
| (1ULL << 0x18)
#endif
#ifdef ENABLE_RGB_MATRIX_HUE_PENDULUM
| (1ULL << 0x19)
#endif
#ifdef ENABLE_RGB_MATRIX_HUE_WAVE
| (1ULL << 0x1A)
#endif
#ifdef ENABLE_RGB_MATRIX_PIXEL_FRACTAL
| (1ULL << 0x1B)
#endif
#ifdef ENABLE_RGB_MATRIX_PIXEL_FLOW
| (1ULL << 0x1C)
#endif
#ifdef ENABLE_RGB_MATRIX_PIXEL_RAIN
| (1ULL << 0x1D)
#endif
#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS
#ifdef ENABLE_RGB_MATRIX_TYPING_HEATMAP
| (1ULL << 0x1E)
#endif
#endif
#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS
#ifdef ENABLE_RGB_MATRIX_DIGITAL_RAIN
| (1ULL << 0x1F)
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
| (1ULL << 0x20)
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE
| (1ULL << 0x21)
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
| (1ULL << 0x22)
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
| (1ULL << 0x23)
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
| (1ULL << 0x24)
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
| (1ULL << 0x25)
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
| (1ULL << 0x26)
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
| (1ULL << 0x27)
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SPLASH
| (1ULL << 0x28)
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_MULTISPLASH
| (1ULL << 0x29)
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_SPLASH
| (1ULL << 0x2A)
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
| (1ULL << 0x2B)
#endif
#endif
};
static const uint8_t rgb_matrix_effect_map[][2] PROGMEM = {
{ 0x00, RGB_MATRIX_SOLID_COLOR},
#ifdef ENABLE_RGB_MATRIX_ALPHAS_MODS
{ 0x01, RGB_MATRIX_ALPHAS_MODS},
#endif
#ifdef ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN
{ 0x02, RGB_MATRIX_GRADIENT_UP_DOWN},
#endif
#ifdef ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT
{ 0x03, RGB_MATRIX_GRADIENT_LEFT_RIGHT},
#endif
#ifdef ENABLE_RGB_MATRIX_BREATHING
{ 0x04, RGB_MATRIX_BREATHING},
#endif
#ifdef ENABLE_RGB_MATRIX_BAND_SAT
{ 0x05, RGB_MATRIX_BAND_SAT},
#endif
#ifdef ENABLE_RGB_MATRIX_BAND_VAL
{ 0x06, RGB_MATRIX_BAND_VAL},
#endif
#ifdef ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
{ 0x07, RGB_MATRIX_BAND_PINWHEEL_SAT},
#endif
#ifdef ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL
{ 0x08, RGB_MATRIX_BAND_PINWHEEL_VAL},
#endif
#ifdef ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT
{ 0x09, RGB_MATRIX_BAND_SPIRAL_SAT},
#endif
#ifdef ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL
{ 0x0A, RGB_MATRIX_BAND_SPIRAL_VAL},
#endif
#ifdef ENABLE_RGB_MATRIX_CYCLE_ALL
{ 0x0B, RGB_MATRIX_CYCLE_ALL},
#endif
#ifdef ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
{ 0x0C, RGB_MATRIX_CYCLE_LEFT_RIGHT},
#endif
#ifdef ENABLE_RGB_MATRIX_CYCLE_UP_DOWN
{ 0x0D, RGB_MATRIX_CYCLE_UP_DOWN},
#endif
#ifdef ENABLE_RGB_MATRIX_CYCLE_OUT_IN
{ 0x0E, RGB_MATRIX_CYCLE_OUT_IN},
#endif
#ifdef ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
{ 0x0F, RGB_MATRIX_CYCLE_OUT_IN_DUAL},
#endif
#ifdef ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
{ 0x10, RGB_MATRIX_RAINBOW_MOVING_CHEVRON},
#endif
#ifdef ENABLE_RGB_MATRIX_CYCLE_PINWHEEL
{ 0x11, RGB_MATRIX_CYCLE_PINWHEEL},
#endif
#ifdef ENABLE_RGB_MATRIX_CYCLE_SPIRAL
{ 0x12, RGB_MATRIX_CYCLE_SPIRAL},
#endif
#ifdef ENABLE_RGB_MATRIX_DUAL_BEACON
{ 0x13, RGB_MATRIX_DUAL_BEACON},
#endif
#ifdef ENABLE_RGB_MATRIX_RAINBOW_BEACON
{ 0x14, RGB_MATRIX_RAINBOW_BEACON},
#endif
#ifdef ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS
{ 0x15, RGB_MATRIX_RAINBOW_PINWHEELS},
#endif
#ifdef ENABLE_RGB_MATRIX_RAINDROPS
{ 0x16, RGB_MATRIX_RAINDROPS},
#endif
#ifdef ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
{ 0x17, RGB_MATRIX_JELLYBEAN_RAINDROPS},
#endif
#ifdef ENABLE_RGB_MATRIX_HUE_BREATHING
{ 0x18, RGB_MATRIX_HUE_BREATHING},
#endif
#ifdef ENABLE_RGB_MATRIX_HUE_PENDULUM
{ 0x19, RGB_MATRIX_HUE_PENDULUM},
#endif
#ifdef ENABLE_RGB_MATRIX_HUE_WAVE
{ 0x1A, RGB_MATRIX_HUE_WAVE},
#endif
#ifdef ENABLE_RGB_MATRIX_PIXEL_FRACTAL
{ 0x1B, RGB_MATRIX_PIXEL_FRACTAL},
#endif
#ifdef ENABLE_RGB_MATRIX_PIXEL_FLOW
{ 0x1C, RGB_MATRIX_PIXEL_FLOW},
#endif
#ifdef ENABLE_RGB_MATRIX_PIXEL_RAIN
{ 0x1D, RGB_MATRIX_PIXEL_RAIN},
#endif
#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS
#ifdef ENABLE_RGB_MATRIX_TYPING_HEATMAP
{ 0x1E, RGB_MATRIX_TYPING_HEATMAP},
#endif
#endif
#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS
#ifdef ENABLE_RGB_MATRIX_DIGITAL_RAIN
{ 0x1F, RGB_MATRIX_DIGITAL_RAIN},
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
{ 0x20, RGB_MATRIX_SOLID_REACTIVE_SIMPLE},
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE
{ 0x21, RGB_MATRIX_SOLID_REACTIVE},
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
{ 0x22, RGB_MATRIX_SOLID_REACTIVE_WIDE},
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
{ 0x23, RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE},
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
{ 0x24, RGB_MATRIX_SOLID_REACTIVE_CROSS},
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
{ 0x25, RGB_MATRIX_SOLID_REACTIVE_MULTICROSS},
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
{ 0x26, RGB_MATRIX_SOLID_REACTIVE_NEXUS},
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
{ 0x27, RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS},
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SPLASH
{ 0x28, RGB_MATRIX_SPLASH},
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_MULTISPLASH
{ 0x29, RGB_MATRIX_MULTISPLASH},
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_SPLASH
{ 0x2A, RGB_MATRIX_SOLID_SPLASH},
#endif
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifdef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
{ 0x2B, RGB_MATRIX_SOLID_MULTISPLASH},
#endif
#endif
};
uint8_t rgb_matrix_effect_to_id(uint8_t val) {
for(uint8_t i = 0; i < ARRAY_SIZE(rgb_matrix_effect_map); i++) {
if (pgm_read_byte(&rgb_matrix_effect_map[i][1]) == val)
return pgm_read_byte(&rgb_matrix_effect_map[i][0]);
}
return 0xFF;
}
uint8_t rgb_matrix_id_to_effect(uint8_t val) {
for(uint8_t i = 0; i < ARRAY_SIZE(rgb_matrix_effect_map); i++) {
if (pgm_read_byte(&rgb_matrix_effect_map[i][0]) == val)
return pgm_read_byte(&rgb_matrix_effect_map[i][1]);
}
return 0xFF;
}

View File

@ -0,0 +1,377 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later
/*******************************************************************************
88888888888 888 d8b .d888 d8b 888 d8b
888 888 Y8P d88P" Y8P 888 Y8P
888 888 888 888
888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b
888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K
888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b.
888 888 888 888 X88 888 888 888 Y8b. 888 X88
888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P'
888 888
888 888
888 888
.d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888
d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888
888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888
Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888
"Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888
888
Y8b d88P
"Y88P"
*******************************************************************************/
#pragma once
// clang-format off
enum { ENABLED_RGBLIGHT_EFFECTS = 0
| (1ULL << 0x00)
#ifdef RGBLIGHT_EFFECT_BREATHING
| (1ULL << 0x01)
#endif
#ifdef RGBLIGHT_EFFECT_BREATHING
| (1ULL << 0x02)
#endif
#ifdef RGBLIGHT_EFFECT_BREATHING
| (1ULL << 0x03)
#endif
#ifdef RGBLIGHT_EFFECT_BREATHING
| (1ULL << 0x04)
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
| (1ULL << 0x05)
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
| (1ULL << 0x06)
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
| (1ULL << 0x07)
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
| (1ULL << 0x08)
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
| (1ULL << 0x09)
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
| (1ULL << 0x0A)
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
| (1ULL << 0x0B)
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
| (1ULL << 0x0C)
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
| (1ULL << 0x0D)
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
| (1ULL << 0x0E)
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
| (1ULL << 0x0F)
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
| (1ULL << 0x10)
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
| (1ULL << 0x11)
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
| (1ULL << 0x12)
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
| (1ULL << 0x13)
#endif
#ifdef RGBLIGHT_EFFECT_KNIGHT
| (1ULL << 0x14)
#endif
#ifdef RGBLIGHT_EFFECT_KNIGHT
| (1ULL << 0x15)
#endif
#ifdef RGBLIGHT_EFFECT_KNIGHT
| (1ULL << 0x16)
#endif
#ifdef RGBLIGHT_EFFECT_CHRISTMAS
| (1ULL << 0x17)
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
| (1ULL << 0x18)
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
| (1ULL << 0x19)
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
| (1ULL << 0x1A)
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
| (1ULL << 0x1B)
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
| (1ULL << 0x1C)
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
| (1ULL << 0x1D)
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
| (1ULL << 0x1E)
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
| (1ULL << 0x1F)
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
| (1ULL << 0x20)
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
| (1ULL << 0x21)
#endif
#ifdef RGBLIGHT_EFFECT_RGB_TEST
| (1ULL << 0x22)
#endif
#ifdef RGBLIGHT_EFFECT_ALTERNATING
| (1ULL << 0x23)
#endif
#ifdef RGBLIGHT_EFFECT_TWINKLE
| (1ULL << 0x24)
#endif
#ifdef RGBLIGHT_EFFECT_TWINKLE
| (1ULL << 0x25)
#endif
#ifdef RGBLIGHT_EFFECT_TWINKLE
| (1ULL << 0x26)
#endif
#ifdef RGBLIGHT_EFFECT_TWINKLE
| (1ULL << 0x27)
#endif
#ifdef RGBLIGHT_EFFECT_TWINKLE
| (1ULL << 0x28)
#endif
#ifdef RGBLIGHT_EFFECT_TWINKLE
| (1ULL << 0x29)
#endif
};
static const uint8_t rgblight_effect_map[][2] PROGMEM = {
{ 0x00, RGBLIGHT_MODE_STATIC_LIGHT},
#ifdef RGBLIGHT_EFFECT_BREATHING
{ 0x01, RGBLIGHT_MODE_BREATHING},
#endif
#ifdef RGBLIGHT_EFFECT_BREATHING
{ 0x02, RGBLIGHT_MODE_BREATHING + 1},
#endif
#ifdef RGBLIGHT_EFFECT_BREATHING
{ 0x03, RGBLIGHT_MODE_BREATHING + 2},
#endif
#ifdef RGBLIGHT_EFFECT_BREATHING
{ 0x04, RGBLIGHT_MODE_BREATHING + 3},
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
{ 0x05, RGBLIGHT_MODE_RAINBOW_MOOD},
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
{ 0x06, RGBLIGHT_MODE_RAINBOW_MOOD + 1},
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
{ 0x07, RGBLIGHT_MODE_RAINBOW_MOOD + 2},
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
{ 0x08, RGBLIGHT_MODE_RAINBOW_SWIRL},
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
{ 0x09, RGBLIGHT_MODE_RAINBOW_SWIRL + 1},
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
{ 0x0A, RGBLIGHT_MODE_RAINBOW_SWIRL + 2},
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
{ 0x0B, RGBLIGHT_MODE_RAINBOW_SWIRL + 3},
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
{ 0x0C, RGBLIGHT_MODE_RAINBOW_SWIRL + 4},
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
{ 0x0D, RGBLIGHT_MODE_RAINBOW_SWIRL + 5},
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
{ 0x0E, RGBLIGHT_MODE_SNAKE},
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
{ 0x0F, RGBLIGHT_MODE_SNAKE + 1},
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
{ 0x10, RGBLIGHT_MODE_SNAKE + 2},
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
{ 0x11, RGBLIGHT_MODE_SNAKE + 3},
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
{ 0x12, RGBLIGHT_MODE_SNAKE + 4},
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
{ 0x13, RGBLIGHT_MODE_SNAKE + 5},
#endif
#ifdef RGBLIGHT_EFFECT_KNIGHT
{ 0x14, RGBLIGHT_MODE_KNIGHT},
#endif
#ifdef RGBLIGHT_EFFECT_KNIGHT
{ 0x15, RGBLIGHT_MODE_KNIGHT + 1},
#endif
#ifdef RGBLIGHT_EFFECT_KNIGHT
{ 0x16, RGBLIGHT_MODE_KNIGHT + 2},
#endif
#ifdef RGBLIGHT_EFFECT_CHRISTMAS
{ 0x17, RGBLIGHT_MODE_CHRISTMAS},
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
{ 0x18, RGBLIGHT_MODE_STATIC_GRADIENT},
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
{ 0x19, RGBLIGHT_MODE_STATIC_GRADIENT + 1},
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
{ 0x1A, RGBLIGHT_MODE_STATIC_GRADIENT + 2},
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
{ 0x1B, RGBLIGHT_MODE_STATIC_GRADIENT + 3},
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
{ 0x1C, RGBLIGHT_MODE_STATIC_GRADIENT + 4},
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
{ 0x1D, RGBLIGHT_MODE_STATIC_GRADIENT + 5},
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
{ 0x1E, RGBLIGHT_MODE_STATIC_GRADIENT + 6},
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
{ 0x1F, RGBLIGHT_MODE_STATIC_GRADIENT + 7},
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
{ 0x20, RGBLIGHT_MODE_STATIC_GRADIENT + 8},
#endif
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
{ 0x21, RGBLIGHT_MODE_STATIC_GRADIENT + 9},
#endif
#ifdef RGBLIGHT_EFFECT_RGB_TEST
{ 0x22, RGBLIGHT_MODE_RGB_TEST},
#endif
#ifdef RGBLIGHT_EFFECT_ALTERNATING
{ 0x23, RGBLIGHT_MODE_ALTERNATING},
#endif
#ifdef RGBLIGHT_EFFECT_TWINKLE
{ 0x24, RGBLIGHT_MODE_TWINKLE},
#endif
#ifdef RGBLIGHT_EFFECT_TWINKLE
{ 0x25, RGBLIGHT_MODE_TWINKLE + 1},
#endif
#ifdef RGBLIGHT_EFFECT_TWINKLE
{ 0x26, RGBLIGHT_MODE_TWINKLE + 2},
#endif
#ifdef RGBLIGHT_EFFECT_TWINKLE
{ 0x27, RGBLIGHT_MODE_TWINKLE + 3},
#endif
#ifdef RGBLIGHT_EFFECT_TWINKLE
{ 0x28, RGBLIGHT_MODE_TWINKLE + 4},
#endif
#ifdef RGBLIGHT_EFFECT_TWINKLE
{ 0x29, RGBLIGHT_MODE_TWINKLE + 5},
#endif
};
uint8_t rgblight_effect_to_id(uint8_t val) {
for(uint8_t i = 0; i < ARRAY_SIZE(rgblight_effect_map); i++) {
if (pgm_read_byte(&rgblight_effect_map[i][1]) == val)
return pgm_read_byte(&rgblight_effect_map[i][0]);
}
return 0xFF;
}
uint8_t rgblight_id_to_effect(uint8_t val) {
for(uint8_t i = 0; i < ARRAY_SIZE(rgblight_effect_map); i++) {
if (pgm_read_byte(&rgblight_effect_map[i][0]) == val)
return pgm_read_byte(&rgblight_effect_map[i][1]);
}
return 0xFF;
}

View File

@ -57,14 +57,14 @@ bool xap_respond_save_backlight_config(xap_token_t token, const void *data, size
extern rgblight_config_t rgblight_config; extern rgblight_config_t rgblight_config;
uint8_t rgblight2xap(uint8_t val); uint8_t rgblight_effect_to_id(uint8_t val);
uint8_t xap2rgblight(uint8_t val); uint8_t rgblight_id_to_effect(uint8_t val);
bool xap_respond_get_rgblight_config(xap_token_t token, const void *data, size_t length) { bool xap_respond_get_rgblight_config(xap_token_t token, const void *data, size_t length) {
xap_route_lighting_rgblight_get_config_t ret; xap_route_lighting_rgblight_get_config_t ret;
ret.enable = rgblight_config.enable; ret.enable = rgblight_config.enable;
ret.mode = rgblight2xap(rgblight_config.mode); ret.mode = rgblight_effect_to_id(rgblight_config.mode);
ret.hue = rgblight_config.hue; ret.hue = rgblight_config.hue;
ret.sat = rgblight_config.sat; ret.sat = rgblight_config.sat;
ret.val = rgblight_config.val; ret.val = rgblight_config.val;
@ -80,7 +80,7 @@ bool xap_respond_set_rgblight_config(xap_token_t token, const void *data, size_t
xap_route_lighting_rgblight_set_config_arg_t *arg = (xap_route_lighting_rgblight_set_config_arg_t *)data; xap_route_lighting_rgblight_set_config_arg_t *arg = (xap_route_lighting_rgblight_set_config_arg_t *)data;
uint8_t mode = xap2rgblight(arg->mode); uint8_t mode = rgblight_id_to_effect(arg->mode);
if (mode == INVALID_EFFECT) { if (mode == INVALID_EFFECT) {
return false; return false;
} }
@ -105,8 +105,8 @@ bool xap_respond_save_rgblight_config(xap_token_t token, const void *data, size_
extern rgb_config_t rgb_matrix_config; extern rgb_config_t rgb_matrix_config;
uint8_t rgb_matrix2xap(uint8_t val); uint8_t rgb_matrix_effect_to_id(uint8_t val);
uint8_t xap2rgb_matrix(uint8_t val); uint8_t rgb_matrix_id_to_effect(uint8_t val);
void rgb_matrix_enabled_noeeprom(bool val) { void rgb_matrix_enabled_noeeprom(bool val) {
val ? rgb_matrix_enable_noeeprom() : rgb_matrix_disable_noeeprom(); val ? rgb_matrix_enable_noeeprom() : rgb_matrix_disable_noeeprom();
@ -116,7 +116,7 @@ bool xap_respond_get_rgb_matrix_config(xap_token_t token, const void *data, size
xap_route_lighting_rgb_matrix_get_config_t ret; xap_route_lighting_rgb_matrix_get_config_t ret;
ret.enable = rgb_matrix_config.enable; ret.enable = rgb_matrix_config.enable;
ret.mode = rgb_matrix2xap(rgb_matrix_config.mode); ret.mode = rgb_matrix_effect_to_id(rgb_matrix_config.mode);
ret.hue = rgb_matrix_config.hsv.h; ret.hue = rgb_matrix_config.hsv.h;
ret.sat = rgb_matrix_config.hsv.s; ret.sat = rgb_matrix_config.hsv.s;
ret.val = rgb_matrix_config.hsv.v; ret.val = rgb_matrix_config.hsv.v;
@ -133,7 +133,7 @@ bool xap_respond_set_rgb_matrix_config(xap_token_t token, const void *data, size
xap_route_lighting_rgb_matrix_set_config_arg_t *arg = (xap_route_lighting_rgb_matrix_set_config_arg_t *)data; xap_route_lighting_rgb_matrix_set_config_arg_t *arg = (xap_route_lighting_rgb_matrix_set_config_arg_t *)data;
uint8_t mode = xap2rgb_matrix(arg->mode); uint8_t mode = rgb_matrix_id_to_effect(arg->mode);
if (mode == INVALID_EFFECT) { if (mode == INVALID_EFFECT) {
return false; return false;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,9 @@
#!/bin/bash #!/bin/bash
set -e set -e
qmk generate-lighting-map -f rgblight -o quantum/rgblight/lighting_map.h
qmk generate-lighting-map -f rgb_matrix -o quantum/rgb_matrix/lighting_map.h
qmk generate-lighting-map -f led_matrix -o quantum/led_matrix/lighting_map.h
qmk generate-rgb-breathe-table -o quantum/rgblight/rgblight_breathe_table.h qmk generate-rgb-breathe-table -o quantum/rgblight/rgblight_breathe_table.h
qmk generate-keycodes --version latest -o quantum/keycodes.h qmk generate-keycodes --version latest -o quantum/keycodes.h
qmk generate-keycodes-tests --version latest -o tests/test_common/keycode_table.cpp qmk generate-keycodes-tests --version latest -o tests/test_common/keycode_table.cpp