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

Allocation-free debouncing #22241

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

NilsIrl
Copy link

@NilsIrl NilsIrl commented Oct 10, 2023

Allocate memory for debouncing algorithms statically.

Description

Some keyboards do not support memory allocation and this commit makes it possible to use debouncing algorithms that previously required allocation on those keyboards.

The num_rows variable was added to debounce_init and debounce to support split keyboards but the value passed to those functions is always ROWS_PER_HAND so it is safe to use the ROWS_PER_HAND macro instead similarly to how MATRIX_COLS is assumed to be correct.

Beyond changes to quantum, some of the keyboards had to be updated to support the change of signature, and documentation for custom matrix was also updated.

Types of Changes

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

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

Copy link
Member

@fauxpark fauxpark left a comment

Choose a reason for hiding this comment

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

ROWS_PER_HAND is defined in the following matrix.c files, but has the same value so does not emit an error:

halfcliff
keychron/q10
keychron/q12
keychron/q1v2
keychron/q3
keychron/q5
keychron/q6
keychron/q65
keychron/v1 (errors because it's actually `MATRIX_ROWS` instead of `(MATRIX_ROWS)`)
keychron/v10
keychron/v3
keychron/v5
keychron/v6
nullbitsco/snap
sekigon/grs_70ec
whale/sk/v3

These boards may be an issue because they have ROWS_PER_HAND defined as (MATRIX_ROWS / 2) but are not marked as split keyboards:

handwired/dygma/raise
keyboardio/model01
moonlander

quantum/matrix_common.c Show resolved Hide resolved
@NilsIrl
Copy link
Author

NilsIrl commented Oct 16, 2023

I've removed the definition of ROWS_PER_HAND in all the keyboards but the three mentioned.

For the 3 keyboards which define ROWS_PER_HAND as (MATRIX_ROWS / 2) but are not marked as split keyboard, looking at physical pictures of these keyboards, they are split keyboards so I would be tempted to set SPLIT_KEYBOARD for them but I'd be worried of side effects as ROWS_PER_HAND is used multiple times in quantum/.

Pinging the maintainers/author of the respective keyboard firmwares, maybe they are able to help with this issue @drashna @ibash @abrasive

@NilsIrl NilsIrl force-pushed the debounce_without_allocation branch 2 times, most recently from 54212ee to 66fd5f3 Compare October 16, 2023 02:31
quantum/matrix_common.c Show resolved Hide resolved
Copy link

github-actions bot commented Dec 7, 2023

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 Dec 7, 2023
@ibash
Copy link

ibash commented Dec 11, 2023

Hi @NilsIrl sorry for the delay.

The raise keyboard firmware is a fork of keyboardio, so whatever is done for that keyboard should probably be done for the raise too.
Unfortunately I no longer have a dygma raise so can't help validate this.

num_rows is always ROWS_PER_HAND so it is safe to rely on the value of
ROWS_PER_HAND.
@NilsIrl NilsIrl force-pushed the debounce_without_allocation branch from c0e4374 to c903b00 Compare June 16, 2024 14:06
@tzarc tzarc added the develop-fast-track Intended to be merged early in the next develop cycle. label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting changes core develop-fast-track Intended to be merged early in the next develop cycle. documentation in progress keyboard stale Issues or pull requests that have become inactive without resolution.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants