MicroBitDisplay: move display refresh timer ownership to MicroBit#515
Merged
finneyj merged 1 commit intolancaster-university:masterfrom Dec 17, 2025
Merged
Conversation
Create the display refresh timer in MicroBit and pass it to MicroBitDisplay, avoiding inline allocation and potential timer leaks. Signed-off-by: Mannu Lambrichts <mannu346@gmail.com>
Contributor
|
Thanks @MannuLambrichts - looks good! |
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.
Summary
This pull request updates how the display refresh timer is instantiated and owned within the Codal display stack. Instead of allocating the timer inline inside the
MicroBitDisplayconstructor, the timer is now created inMicroBitand passed intoMicroBitDisplayby reference, aligning it with how other Codal timers (system, adc, touch) are managed.Motivation
Previously,
MicroBitDisplayallocated the display refresh timer usingnewwithin its constructor. The resulting reference was not retained byMicroBitDisplayitself, relying instead on internal storage withinNRF52LedMatrix. Since that member is private, the timer could not be explicitly managed or cleaned up. Also,NRF52LedMatrixdoes not allocate the timer, so it should not be responsible for maintaining it.In rare (more advanced) scenarios, this could lead to orphaned timers and memory leaks.
Implementation details
MicroBit, similar to all other timers used by Codal.MicroBitDisplayreceives the timer via reference, making ownership and lifetime explicit.MicroBitDisplayconstructor is preserved for compatibility but is marked as deprecated to discourage further use.