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

Initial potentiometer support #22449

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft

Initial potentiometer support #22449

wants to merge 1 commit into from

Conversation

zvecr
Copy link
Member

@zvecr zvecr commented Nov 11, 2023

Description

Raising for visibility.

TODO

  • Generalise analog SRC inclusion #22448
  • Just wrap up into analog rather than potentiometer feature?
  • Finish implementation
    • Normalise value before calls to user/keyboard update functions?
    • Filtering mechanisms
    • Default behaviour?
    • Activity updates
  • Complete docs
  • Extend DD?
  • Tests?

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).

@zvecr zvecr added the feature label Nov 11, 2023
@github-actions github-actions bot added core keyboard keymap via Adds via keymap and/or updates keyboard for via support documentation dd Data Driven Changes labels Nov 11, 2023
Comment on lines 44 to 106
uint16_t value = analogReadPin(potentiometer_pads[index]);
if (value != potentiometer_state[index]) {
potentiometer_state[index] = value;
changed |= true;
Copy link
Contributor

Choose a reason for hiding this comment

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

One potential problem here is that the raw analog readings may be noisy; although the user code can filter the raw values to remove that noise, this won't affect the changed flag, which is then used to wake up OLEDs. Not sure how to implement the support for such filtering here while also keeping the common case simple; ideally potentiometer_update_user() should be able to decide whether the analog input activity is actually significant, but there is no good way to return that data from there without adding some pointer argument.

(In the most generic case the user filtering code may also want to see all readings, including the ones which were completely identical to the previous value, so that it can distinguish that case from a delay between readings.)

Copy link
Member Author

@zvecr zvecr Nov 11, 2023

Choose a reason for hiding this comment

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

Filtering was something I was planning to add, and the implementation there is mostly just a stub till a few other things are decided.

The main one being if this would be better as just a high level api to the adc driver. The assumptions that can be made, especially user facing ones, are somewhat simpler if its just for pots.

quantum/keyboard.c Outdated Show resolved Hide resolved
@zvecr zvecr added the no-ci Signals to the CI runners not to build. label Nov 11, 2023
@zvecr zvecr force-pushed the potentiometer branch 2 times, most recently from 1ffbaae to d8e97ab Compare November 13, 2023 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core dd Data Driven Changes documentation feature keyboard keymap no-ci Signals to the CI runners not to build. via Adds via keymap and/or updates keyboard for via support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants