Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added extra construction support to Encoder.py to support pullup direction from Code.py #891

Merged
merged 5 commits into from
Oct 18, 2023

Conversation

Bob837217
Copy link
Contributor

Added support to Encoder.py to allow GPIOEncoder to accept tuple for pin_button construction. This includes allowance for pull resistor (pullup/pulldown) customisation directly from code.py. Additionally the change preserves state generation semantics for pin_button.get_value(self) and depends upon the pull direction. The default pull direction remains as digitalio.Pull.UP

An example config from code.py to customise the pin button pull up direction:
encoder_handler.pins = ((board.VOLC_A, board.VOLC_B, (board.VOLC_PUSH, True, digitalio.Pull.DOWN), False, 2),)

Tested this out on my own code.py.

…pin_button construction. This includes allowance for pull resistor (pullup/pulldown) customisation directly from code.py. Additionally the change preserves state generation semantics for pin_button.get_value(self) and depends upon the pull direction. The default pull direction remains as digitalio.Pull.UP
kmk/modules/encoder.py Outdated Show resolved Hide resolved
kmk/modules/encoder.py Outdated Show resolved Hide resolved
Gordon Jamieson added 2 commits September 28, 2023 12:10
…tatement for EncoderPin.get_value() as suggested in review
… button action and was activating upon keyboard USB insertion without user interaction. Fixed this error.
@xs5871
Copy link
Collaborator

xs5871 commented Oct 13, 2023

On another note: new features require documentation for a merge.

…in an additional optional argument defaulting to Pull.UP instead of overloading the argument with a tuple. This is tested, and documented in English
@xs5871 xs5871 merged commit 4df8a9d into KMKfw:master Oct 18, 2023
1 check passed
@Bob837217 Bob837217 deleted the EncoderButtonFix branch October 18, 2023 14:10
hixan pushed a commit to hixan/kmk_firmware that referenced this pull request Nov 25, 2023
…ction from Code.py (KMKfw#891)

* Added support to Encoder.py to allow GPIOEncoder to accept tuple for pin_button construction.  This includes allowance for pull resistor (pullup/pulldown) customisation directly from code.py.  Additionally the change preserves state generation semantics for pin_button.get_value(self) and depends upon the pull direction.  The default pull direction remains as digitalio.Pull.UP

* Replaced multiline ternary/conditional expression with a regular If statement for EncoderPin.get_value() as suggested in review

* Prior commit failed test. Audio Mute was assigned to the encoder push button action and was activating upon keyboard USB insertion without user interaction. Fixed this error.

* Implemented the reviewer suggestion for the GPIO constructor to take in an additional optional  argument defaulting to Pull.UP instead of overloading the  argument with a tuple.  This is tested, and documented in English

* Fix formatting encoder.py

---------

Co-authored-by: Gordon Jamieson <[email protected]>
Co-authored-by: xs5871 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants