summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2022-07-11 10:51:39 +0100
committerGitHub <noreply@github.com>2022-07-11 10:51:39 +0100
commit35d78aa8a4587ce5286a362471380a9d4f000f3c (patch)
tree92b44f4272700d4768fc334f793fd43b557c5cfd /lib
parent0bee7cbebe156ff8a7f17d0f7c4a30edf089f93c (diff)
downloadqmk_firmware-35d78aa8a4587ce5286a362471380a9d4f000f3c.tar.gz
qmk_firmware-35d78aa8a4587ce5286a362471380a9d4f000f3c.zip
More DD encoder fixes (#17615)
Diffstat (limited to 'lib')
-rwxr-xr-xlib/python/qmk/cli/generate/config_h.py8
-rw-r--r--lib/python/qmk/info.py10
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py
index b53f4ff335..a26dcdf7d7 100755
--- a/lib/python/qmk/cli/generate/config_h.py
+++ b/lib/python/qmk/cli/generate/config_h.py
@@ -142,7 +142,7 @@ def generate_encoder_config(encoder_json, config_h_lines, postfix=''):
for encoder in encoder_json.get("rotary", []):
a_pads.append(encoder["pin_a"])
b_pads.append(encoder["pin_b"])
- resolutions.append(str(encoder.get("resolution", 4)))
+ resolutions.append(encoder.get("resolution", None))
config_h_lines.append(f'#ifndef ENCODERS_PAD_A{postfix}')
config_h_lines.append(f'# define ENCODERS_PAD_A{postfix} {{ { ", ".join(a_pads) } }}')
@@ -152,13 +152,15 @@ def generate_encoder_config(encoder_json, config_h_lines, postfix=''):
config_h_lines.append(f'# define ENCODERS_PAD_B{postfix} {{ { ", ".join(b_pads) } }}')
config_h_lines.append(f'#endif // ENCODERS_PAD_B{postfix}')
- if len(set(resolutions)) == 1:
+ if None in resolutions:
+ cli.log.debug("Unable to generate ENCODER_RESOLUTION configuration")
+ elif len(set(resolutions)) == 1:
config_h_lines.append(f'#ifndef ENCODER_RESOLUTION{postfix}')
config_h_lines.append(f'# define ENCODER_RESOLUTION{postfix} { resolutions[0] }')
config_h_lines.append(f'#endif // ENCODER_RESOLUTION{postfix}')
else:
config_h_lines.append(f'#ifndef ENCODER_RESOLUTIONS{postfix}')
- config_h_lines.append(f'# define ENCODER_RESOLUTIONS{postfix} {{ { ", ".join(resolutions) } }}')
+ config_h_lines.append(f'# define ENCODER_RESOLUTIONS{postfix} {{ { ", ".join(map(str,resolutions)) } }}')
config_h_lines.append(f'#endif // ENCODER_RESOLUTIONS{postfix}')
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