From 1a400d8644a1f0763c68626863b897cb83c6c939 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 21 Jun 2022 04:15:06 +0100 Subject: Allow encoder config from info.json (#17295) --- lib/python/qmk/info.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'lib/python/qmk/info.py') diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 23761d71b7..d308de9db8 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -218,6 +218,62 @@ def _extract_audio(info_data, config_c): info_data['audio'] = {'pins': audio_pins} +def _extract_encoders_values(config_c, postfix=''): + """Common encoder extraction logic + """ + a_pad = config_c.get(f'ENCODERS_PAD_A{postfix}', '').replace(' ', '')[1:-1] + b_pad = config_c.get(f'ENCODERS_PAD_B{postfix}', '').replace(' ', '')[1:-1] + resolutions = config_c.get(f'ENCODER_RESOLUTIONS{postfix}', '').replace(' ', '')[1:-1] + + default_resolution = config_c.get('ENCODER_RESOLUTION', '4') + + if a_pad and b_pad: + a_pad = list(filter(None, a_pad.split(','))) + b_pad = list(filter(None, b_pad.split(','))) + resolutions = list(filter(None, resolutions.split(','))) + resolutions += [default_resolution] * (len(a_pad) - len(resolutions)) + + encoders = [] + for index in range(len(a_pad)): + encoders.append({'pin_a': a_pad[index], 'pin_b': b_pad[index], "resolution": int(resolutions[index])}) + + return encoders + + +def _extract_encoders(info_data, config_c): + """Populate data about encoder pins + """ + encoders = _extract_encoders_values(config_c) + if encoders: + if 'encoder' not in info_data: + info_data['encoder'] = {} + + if 'rotary' in info_data['encoder']: + _log_warning(info_data, 'Encoder config is specified in both config.h and info.json (encoder.rotary) (Value: %s), the config.h value wins.' % info_data['encoder']['rotary']) + + info_data['encoder']['rotary'] = encoders + + +def _extract_split_encoders(info_data, config_c): + """Populate data about split encoder pins + """ + encoders = _extract_encoders_values(config_c, '_RIGHT') + if encoders: + if 'split' not in info_data: + info_data['split'] = {} + + if 'encoder' not in info_data['split']: + info_data['split']['encoder'] = {} + + if 'right' not in info_data['split']['encoder']: + info_data['split']['encoder']['right'] = {} + + if 'rotary' in info_data['split']['encoder']['right']: + _log_warning(info_data, 'Encoder config is specified in both config.h and info.json (encoder.rotary) (Value: %s), the config.h value wins.' % info_data['split']['encoder']['right']['rotary']) + + info_data['split']['encoder']['right']['rotary'] = encoders + + def _extract_secure_unlock(info_data, config_c): """Populate data about the secure unlock sequence """ @@ -506,6 +562,8 @@ def _extract_config_h(info_data, config_c): _extract_split_main(info_data, config_c) _extract_split_transport(info_data, config_c) _extract_split_right_pins(info_data, config_c) + _extract_encoders(info_data, config_c) + _extract_split_encoders(info_data, config_c) _extract_device_version(info_data) return info_data -- cgit v1.2.3 From 35d78aa8a4587ce5286a362471380a9d4f000f3c Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Mon, 11 Jul 2022 10:51:39 +0100 Subject: More DD encoder fixes (#17615) --- lib/python/qmk/info.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/python/qmk/info.py') diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index dac2fd6e9e..72424f390e 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -225,17 +225,21 @@ def _extract_encoders_values(config_c, postfix=''): b_pad = config_c.get(f'ENCODERS_PAD_B{postfix}', '').replace(' ', '')[1:-1] resolutions = config_c.get(f'ENCODER_RESOLUTIONS{postfix}', '').replace(' ', '')[1:-1] - default_resolution = config_c.get('ENCODER_RESOLUTION', '4') + default_resolution = config_c.get('ENCODER_RESOLUTION', None) if a_pad and b_pad: a_pad = list(filter(None, a_pad.split(','))) b_pad = list(filter(None, b_pad.split(','))) resolutions = list(filter(None, resolutions.split(','))) - resolutions += [default_resolution] * (len(a_pad) - len(resolutions)) + if default_resolution: + resolutions += [default_resolution] * (len(a_pad) - len(resolutions)) encoders = [] for index in range(len(a_pad)): - encoders.append({'pin_a': a_pad[index], 'pin_b': b_pad[index], "resolution": int(resolutions[index])}) + encoder = {'pin_a': a_pad[index], 'pin_b': b_pad[index]} + if index < len(resolutions): + encoder['resolution'] = int(resolutions[index]) + encoders.append(encoder) return encoders -- cgit v1.2.3 From 154d35ac146422bef938ed9756f6e0012baa83a2 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 6 Aug 2022 23:23:35 +1000 Subject: Remove `UNUSED_PINS` (#17931) --- lib/python/qmk/info.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'lib/python/qmk/info.py') diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index bc07f68d7b..7ed636d0f9 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -374,11 +374,9 @@ def _extract_split_right_pins(info_data, config_c): # Figure out the right half matrix pins row_pins = config_c.get('MATRIX_ROW_PINS_RIGHT', '').replace('{', '').replace('}', '').strip() col_pins = config_c.get('MATRIX_COL_PINS_RIGHT', '').replace('{', '').replace('}', '').strip() - unused_pin_text = config_c.get('UNUSED_PINS_RIGHT') - unused_pins = unused_pin_text.replace('{', '').replace('}', '').strip() if isinstance(unused_pin_text, str) else None direct_pins = config_c.get('DIRECT_PINS_RIGHT', '').replace(' ', '')[1:-1] - if row_pins or col_pins or direct_pins or unused_pins: + if row_pins or col_pins or direct_pins: if info_data.get('split', {}).get('matrix_pins', {}).get('right') in info_data: _log_warning(info_data, 'Right hand matrix data is specified in both info.json and config.h, the config.h values win.') @@ -400,17 +398,12 @@ def _extract_split_right_pins(info_data, config_c): if direct_pins: info_data['split']['matrix_pins']['right']['direct'] = _extract_direct_matrix(direct_pins) - if unused_pins: - info_data['split']['matrix_pins']['right']['unused'] = _extract_pins(unused_pins) - def _extract_matrix_info(info_data, config_c): """Populate the matrix information. """ row_pins = config_c.get('MATRIX_ROW_PINS', '').replace('{', '').replace('}', '').strip() col_pins = config_c.get('MATRIX_COL_PINS', '').replace('{', '').replace('}', '').strip() - unused_pin_text = config_c.get('UNUSED_PINS') - unused_pins = unused_pin_text.replace('{', '').replace('}', '').strip() if isinstance(unused_pin_text, str) else None direct_pins = config_c.get('DIRECT_PINS', '').replace(' ', '')[1:-1] info_snippet = {} @@ -436,12 +429,6 @@ def _extract_matrix_info(info_data, config_c): info_snippet['direct'] = _extract_direct_matrix(direct_pins) - if unused_pins: - if 'matrix_pins' not in info_data: - info_data['matrix_pins'] = {} - - info_snippet['unused'] = _extract_pins(unused_pins) - if config_c.get('CUSTOM_MATRIX', 'no') != 'no': if 'matrix_pins' in info_data and 'custom' in info_data['matrix_pins']: _log_warning(info_data, 'Custom Matrix is specified in both info.json and config.h, the config.h values win.') -- cgit v1.2.3 From 3c745caf6113cfe8778cf9c11edbc0217c34e236 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Fri, 19 Aug 2022 01:56:48 +0100 Subject: Remove legacy bootmagic cli parsing (#18099) --- lib/python/qmk/info.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'lib/python/qmk/info.py') diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 7ed636d0f9..c95b55916c 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -110,14 +110,7 @@ def info_json(keyboard): def _extract_features(info_data, rules): """Find all the features enabled in rules.mk. """ - # Special handling for bootmagic which also supports a "lite" mode. - if rules.get('BOOTMAGIC_ENABLE') == 'lite': - rules['BOOTMAGIC_LITE_ENABLE'] = 'on' - del rules['BOOTMAGIC_ENABLE'] - if rules.get('BOOTMAGIC_ENABLE') == 'full': - rules['BOOTMAGIC_ENABLE'] = 'on' - - # Process the rest of the rules as booleans + # Process booleans rules for key, value in rules.items(): if key.endswith('_ENABLE'): key = '_'.join(key.split('_')[:-1]).lower() -- cgit v1.2.3