-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lvgl] Revise code generation to allow early widget creation #7611
Merged
Conversation
This file contains 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
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #7611 +/- ##
==========================================
+ Coverage 53.70% 54.04% +0.33%
==========================================
Files 50 50
Lines 9408 9715 +307
Branches 1654 1345 -309
==========================================
+ Hits 5053 5250 +197
- Misses 4056 4139 +83
- Partials 299 326 +27 ☔ View full report in Codecov by Sentry. |
jesserockz
reviewed
Oct 17, 2024
jesserockz
approved these changes
Oct 17, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What does this implement/fix?
The LVGL component relied on the code generation creating lambdas which contained all the code for creating widgets and which were executed during the LVGL
setup()
function. The reason for this was that the LVGL library could not be initialised until display parameters (dimensions and rotation) were known, which had to wait until after the display was setup.A major issue with this was the occurrence of calls to modify state of widgets (e.g. from a switch with a restore mode, linked to a widget, trying to set state during the switch
setup()
). This was worked-around by wrapping all such calls in tests for LVGL initialisation being complete to avoid null pointer references. However this meant some state synchronisation could be lost.However It transpires that it is not necessary to wait until the display is setup, merely to wait until it is configured since all LVGL needs initially is to get the display parameters. This will be guaranteed by the code generation process with its coroutine structure.
Accordingly the basic initialisation of LVGL is now done in its constructor, allowing all widgets to be created in the ESPHome
main()
function before any component is setup and avoiding the need for the null pointer test wrappers.Types of changes
Test Environment
Example entry for
config.yaml
:# Example config.yaml
Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: