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

Add encoder abstraction. #21548

Merged
merged 24 commits into from
Feb 18, 2024
Merged

Add encoder abstraction. #21548

merged 24 commits into from
Feb 18, 2024

Conversation

tzarc
Copy link
Member

@tzarc tzarc commented Jul 17, 2023

Description

Splits out encoder processing logic so that the underlying driver is decoupled from high-level encoder logic.
Effectively allows for "custom encoder lite":

// Driver implements:
void encoder_driver_init(void);
void encoder_driver_task(void);
// Driver invokes during its task:
bool encoder_queue_event(uint8_t index, bool clockwise);

rules.mk picked up:

ENCODER_DRIVER ?= quadrature
VALID_ENCODER_DRIVER_TYPES := quadrature custom

info.json picked up:

{
    /* ... */
    "encoder": {
        "driver": "quadrature" // or "custom"
    },
    /* ... */
}

Quadrature encoder has other weakly-defined functions in order to be able to just override pin reads\s without needing to replicate logic.

Split support is present and tested.

Events are queued and executed on the main loop -- this caters for cases such as split or interrupt-driven, where production of events may not coincide with the main loop's invocation.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@tzarc tzarc requested a review from a team July 17, 2023 00:46
@github-actions github-actions bot added the core label Jul 17, 2023
@tzarc tzarc marked this pull request as draft July 17, 2023 00:59
@tzarc tzarc force-pushed the encoder-abstraction branch 4 times, most recently from f27b435 to 8fa8681 Compare July 17, 2023 11:59
@zzeneg
Copy link
Contributor

zzeneg commented Jul 18, 2023

@tzarc I've tested new code for Pica40, all works!

@tzarc tzarc marked this pull request as ready for review August 2, 2023 07:01
@tzarc tzarc requested a review from a team August 2, 2023 07:02
@github-actions github-actions bot added the dd Data Driven Changes label Dec 16, 2023
Copy link

Thank you for your contribution!
This pull request has been automatically marked as stale because it has not had activity in the last 45 days. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, or re-open when it's ready.
For maintainers: Please label with bug, awaiting review, breaking_change, in progress, or on hold to prevent the issue from being re-flagged.

@github-actions github-actions bot added the stale Issues or pull requests that have become inactive without resolution. label Jan 31, 2024
@drashna drashna added in progress and removed stale Issues or pull requests that have become inactive without resolution. labels Feb 1, 2024
quantum/encoder.c Outdated Show resolved Hide resolved
Copy link
Member

@drashna drashna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to match what is in core already

drivers/encoder/encoder_graycode.c Outdated Show resolved Hide resolved
drivers/encoder/encoder_graycode.c Outdated Show resolved Hide resolved
@tzarc tzarc merged commit 9d9cdaa into qmk:develop Feb 18, 2024
4 of 5 checks passed
@tzarc tzarc deleted the encoder-abstraction branch February 18, 2024 10:59
thebengeu pushed a commit to thebengeu/qmk_firmware that referenced this pull request Apr 21, 2024
Mesabloo pushed a commit to Mesabloo/qmk_firmware that referenced this pull request May 27, 2024
ykeisuke added a commit to ykeisuke/qmk_firmware that referenced this pull request Jun 4, 2024
This reverts commit 9d9cdaa.

# Conflicts:
#	data/schemas/keyboard.jsonschema
#	keyboards/pica40/rev2/rev2.c
#	keyboards/planck/rev7/matrix.c
#	keyboards/ploopyco/mouse/config.h
#	keyboards/ploopyco/mouse/keyboard.json
#	keyboards/ploopyco/mouse/rules.mk
#	keyboards/ploopyco/ploopyco.c
#	keyboards/ploopyco/trackball/config.h
#	keyboards/ploopyco/trackball/info.json
#	keyboards/ploopyco/trackball/rules.mk
#	keyboards/ploopyco/trackball/trackball.c
#	keyboards/ploopyco/trackball_mini/config.h
#	keyboards/ploopyco/trackball_mini/info.json
#	keyboards/ploopyco/trackball_mini/rules.mk
#	keyboards/ploopyco/trackball_mini/trackball_mini.c
#	keyboards/ploopyco/trackball_thumb/config.h
#	keyboards/ploopyco/trackball_thumb/trackball_thumb.c
#	quantum/encoder.c
#	quantum/encoder.h
#	quantum/split_common/transaction_id_define.h
#	quantum/split_common/transactions.c
ykeisuke added a commit to ykeisuke/qmk_firmware that referenced this pull request Jun 4, 2024
This reverts commit e3cb6bb.

# Conflicts:
#	keyboards/mechwild/sugarglider/matrix.c
#	keyboards/pica40/rev2/rev2.c
#	keyboards/ploopyco/mouse/config.h
#	keyboards/ploopyco/mouse/keyboard.json
#	keyboards/ploopyco/mouse/rules.mk
#	keyboards/ploopyco/ploopyco.c
#	keyboards/ploopyco/ploopyco.h
#	keyboards/ploopyco/trackball/config.h
#	keyboards/ploopyco/trackball/info.json
#	keyboards/ploopyco/trackball/rules.mk
#	keyboards/ploopyco/trackball_mini/config.h
#	keyboards/ploopyco/trackball_mini/info.json
#	keyboards/ploopyco/trackball_mini/rules.mk
#	keyboards/ploopyco/trackball_thumb/config.h
#	keyboards/ploopyco/trackball_thumb/info.json
AJO-Python pushed a commit to AJO-Python/qmk_firmware that referenced this pull request Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants