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

Enhancement of WPM feature #11727

Merged
merged 8 commits into from
Apr 19, 2021
Merged

Conversation

drashna
Copy link
Member

@drashna drashna commented Jan 29, 2021

Types of Changes

  • Core
  • Enhancement/optimization
  • 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).
    And additional code cleanup

@drashna drashna requested a review from a team January 29, 2021 23:31
Copy link
Contributor

@brickbots brickbots left a comment

Choose a reason for hiding this comment

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

Thanks for these great updates!

@drashna drashna force-pushed the feature/wpm_enhancement branch from 88e8974 to 490dab3 Compare February 20, 2021 18:04
@tzarc tzarc closed this Feb 27, 2021
@tzarc tzarc deleted the branch qmk:develop February 27, 2021 20:28
@tzarc
Copy link
Member

tzarc commented Feb 27, 2021

Sorry about that, GitHub decided to delete the develop branch from upstream when we merged it, despite being told otherwise. Reopened.

@tzarc tzarc reopened this Feb 27, 2021
@stale
Copy link

stale bot commented Apr 18, 2021

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 awaiting review, breaking_change, in progress, or on hold to prevent the issue from being re-flagged.

@stale stale bot removed the awaiting changes label Apr 19, 2021
@drashna drashna force-pushed the feature/wpm_enhancement branch from 490dab3 to 533dc62 Compare April 19, 2021 03:45
@drashna drashna merged commit 180a32e into qmk:develop Apr 19, 2021
@drashna drashna deleted the feature/wpm_enhancement branch April 19, 2021 06:26
@firetech
Copy link
Contributor

firetech commented Jun 6, 2021

@drashna Since this patch, pressing multiple (counted) keys simultaneously makes the WPM skyrocket, often even overflowing the uint8_t it's stored in. As far as I've been able to test, I can't seem to reproduce that with the last version of wpm.c before this.

The reason seems to be that, previously, the old calculation of latest_wpm was stored in a uint8_t before being added to current_wpm, but now that calculation is entirely inline. Adding a uint8_t cast to that part inside the new calculation restores the old behaviour. I.e.

current_wpm += ((uint8_t)(60000 / timer_elapsed(wpm_timer) / WPM_ESTIMATED_WORD_SIZE) - current_wpm) * wpm_smoothing;

Not sure if the potential overflow there was intentional or not...

That said, I'm not entirely sure which of the algorithms is the most correct, but I never really found either of them to be far off other measurements, except for this difference.

Edit: This might be a better solution, clamping the value instead of just relying on a random-ish value after uint8_t overflow:

uint16_t latest_wpm = 60000 / timer_elapsed(wpm_timer) / WPM_ESTIMATED_WORD_SIZE;
if (latest_wpm > UINT8_MAX) {
    latest_wpm = UINT8_MAX;
}
current_wpm += (latest_wpm - current_wpm) * wpm_smoothing;

@firetech firetech mentioned this pull request Jun 7, 2021
14 tasks
nhongooi pushed a commit to nhongooi/qmk_firmware that referenced this pull request Dec 5, 2021
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants