Skip to content

Comments

Change to local memory allocation for pin arrays - Fixes issues #7 and #9#10

Open
foxblock wants to merge 1 commit intobridystone:ShiftRegisterfrom
foxblock:ShiftRegister
Open

Change to local memory allocation for pin arrays - Fixes issues #7 and #9#10
foxblock wants to merge 1 commit intobridystone:ShiftRegisterfrom
foxblock:ShiftRegister

Conversation

@foxblock
Copy link

@foxblock foxblock commented May 30, 2022

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

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.
@loginov-rocks
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with esp8266

2 participants