move all functionality to apptask#863
Draft
sarthak shaha (Sarthak-Shaha) wants to merge 10 commits intomainfrom
Draft
move all functionality to apptask#863sarthak shaha (Sarthak-Shaha) wants to merge 10 commits intomainfrom
sarthak shaha (Sarthak-Shaha) wants to merge 10 commits intomainfrom
Conversation
9f757c5 to
5a37dc4
Compare
5a37dc4 to
2cc4cd8
Compare
73c1a71 to
7a401e3
Compare
7a401e3 to
b64128e
Compare
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 PR refactors the Silabs lighting-app example by merging LightingManager into AppTask and introducing a CRTP-based extensibility layer. The new design centralizes light logic in AppTask and uses AppTaskImpl for targeted customization without modifying core behavior.
1. Merging of LightingManager and AppTask
Before: LightingManager was a separate singleton managing light state, timers, and actions, with callbacks wired to AppTask.
After: All lighting functionality is moved into AppTask:
mLightState), level, and color attributes live in AppTaskmLightTimer, auto-turn-off, off-with-effect) is in AppTaskInitLight(),InitiateAction(),IsLightOn(),EnableAutoTurnOff(), etc. are implemented in AppTaskLightTypes.hkeeps onlyLightingManager::Action_tandLightingManager::State_tas shared enums to preserve the API surface and avoid circular includes; implementation stays in AppTaskBenefits: Single object for app and light logic, no callback indirection, simpler ownership and data flow.
2. CRTP in AppTaskImpl and Using CustomAppTask
Design:
AppTaskImpl<Derived>is a CRTP base inheriting from AppTask that forwards every overridable operation to a*Impl()method on the derived class.AppInit(),StartAppTask(),PostLightActionRequest(),InitLight(), etc.) forward toDerived::*Impl()via macros (CRTP_RETURN_AND_VERIFY,CRTP_VOID_AND_VERIFY, etc.)*Impl()methods have default implementations that call AppTask; override only what you needButtonHandler,LightActionEventHandler) useCRTP_APP_TASKto call instance methods on the derived AppTask singletonUsing CustomAppTask:
AppTaskImpl<YourCustomClass>:GetAppTask()andsAppTask:Override only the needed
*Impl()methods (e.g.AppInitImpl,ButtonEventHandlerImpl,InitLightImpl,InitiateActionImpl).Wire
AppTask::GetAppTask()to the custom singleton:CustomAppTaskin this PR demonstrates this by overridingAppInitImpl()andButtonEventHandlerImpl().Related issues
Testing
Readability checklist
The checklist below will help the reviewer finish PR review in time and keep the
code readable:
descriptive
“When in Rome…”
rule (coding style)
See: Pull Request Guidelines