fix(ledmatrix): prevent redundant I2C redraws during commands to get much higher FPS on grayscale draws#147
Open
AndrooFrowns wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The tl;dr here is that on every command the matrix was being written to with I2c drastically slowing it down.
I considered fixing that with just a match on which commands need redraws, but decided that it's easier to tinker with or add commands if the draw requests check if they need to write to the matrix for themselves. I'm open to rewriting it in whatever patterns make sense though.
Overall I just wanted smooth animations for fun and ran into the same 6FPS limit that #96 did. This should fix it by removing redundant I2C commands to the display. In my testing it could draw a little over 100FPS with this working. On the grayscale commands the host sends 9 StageGreyCol and 1 DrawGreyColBuffer all of which were causing I2C communication, so it was 10x chattier than required.
To do this I split out the
MatrixSyncfromPatternssince it has very little to do with drawing patterns.I also got rid of
set_brightnessbecause it had a draw call inside it. That mattered more when I was trying out the allowlist of draw commands, but I kept it since it's more clear imo. Like I said though happy to use whatever patterns you prefer.