Change to local memory allocation for pin arrays - Fixes issues #7 and #9#10
Open
foxblock wants to merge 1 commit intobridystone:ShiftRegisterfrom
Open
Change to local memory allocation for pin arrays - Fixes issues #7 and #9#10foxblock wants to merge 1 commit intobridystone:ShiftRegisterfrom
foxblock wants to merge 1 commit intobridystone:ShiftRegisterfrom
Conversation
Add destructor to SevSegShift with proper memory cleanup Fixes issues bridystone#7 and bridystone#9 Instead of copying just the pointer of the shiftRegisterMapDigits and shiftRegisterMapSegments arrays passed to begin, we allocate the memory for them in SegSevShift and copy the values manually. This removes the implicit need for passing global/static variables, so begin can be called with local/temporary memory.
|
It should be considered as critical bug fix! Big vote to merge! Otherwise, the display breaks in case more or less complex logic uses memory. |
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.
Fixes #7 and #9
Instead of copying just the pointer of the shiftRegisterMapDigits and
shiftRegisterMapSegments arrays passed to begin, we allocate the memory
for them in SegSevShift and copy the values manually.
This removes the implicit need for passing global/static variables, so
begin can be called with local/temporary memory.
Sorry this took a while. I had no access to hardware to test it until today.
Personally I would have used malloc and memcpy, but I kept it similar to how it is done in SevSeg.
Besides this approach should only be marginally slower and someone who really cares about speed would probably roll their own library anyway...