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

fix rgb_matrix flicker on split keyboards caused by RGB_DISABLE_TIMEOUT #14954

Merged
merged 1 commit into from
Dec 27, 2021

Conversation

eberthold
Copy link

@eberthold eberthold commented Oct 25, 2021

Description

Workaround for a bug which causes the slave side of a split keyboard (crkbd in my case) to randomly turn the rgb matrix on and off after every keypress when RGB_DISABLE_TIMEOUT is set. (had values like 300000 and 450000 for 5 or 7.5 minutes timeout)

I think the root of this bug has is in sync_timer.c where

sync_timer_ms = time - timer_read32();

can produce a negative value and the result in
return sync_timer_ms + timer_read32();

can still be negative, which then results in a range underflow of the uint32_t result and therefore will be a very large number.

So as a result the code in rgb_matrix.c will eventually go into the if case in line 295 and 296 and make the slave side think the timeout is reached.

I assume the flicker occurs because the calculation oscillate around 0 and sometimes is negative and sometimes positive.

This is just a workaround and only works 99% of the time - some short random flickers still occur.
My C skills and microcontroller knowledge are very rusted/limited so I currently wasn't able to figure out a real solution to fix the root of this problem

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

There is no issue right now for this

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

@github-actions github-actions bot added the core label Oct 25, 2021
@drashna drashna requested a review from a team October 26, 2021 21:16
@drashna drashna requested a review from a team October 29, 2021 20:35
@tzarc tzarc merged commit 2c8d46f into qmk:master Dec 27, 2021
tiktuk pushed a commit to tiktuk/qmk_firmware that referenced this pull request Jan 1, 2022
ryphon pushed a commit to ryphon/qmk_firmware that referenced this pull request Jan 12, 2022
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.

3 participants