fix rgb_matrix flicker on split keyboards caused by RGB_DISABLE_TIMEOUT #14954
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
whereqmk_firmware/tmk_core/common/sync_timer.c
Line 36 in 6e8eb2c
can produce a negative value and the result in
qmk_firmware/tmk_core/common/sync_timer.c
Line 46 in 6e8eb2c
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
Issues Fixed or Closed by This PR
There is no issue right now for this
Checklist