-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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] Stage 4 #7166
[lvgl] Stage 4 #7166
Conversation
animimg checkbox img led line spinner switch
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #7166 +/- ##
==========================================
+ Coverage 53.70% 53.87% +0.16%
==========================================
Files 50 50
Lines 9408 9655 +247
Branches 1654 1707 +53
==========================================
+ Hits 5053 5202 +149
- Misses 4056 4129 +73
- Partials 299 324 +25 ☔ View full report in Codecov by Sentry. |
if CONF_MIN_VALUE in config: | ||
lv.arc_set_range(w.obj, config[CONF_MIN_VALUE], config[CONF_MAX_VALUE]) | ||
lv.arc_set_bg_angles( | ||
w.obj, config[CONF_START_ANGLE] // 10, config[CONF_END_ANGLE] // 10 | ||
) | ||
lv.arc_set_rotation(w.obj, config[CONF_ROTATION] // 10) | ||
lv.arc_set_mode(w.obj, literal(config[CONF_MODE])) | ||
lv.arc_set_change_rate(w.obj, config[CONF_CHANGE_RATE]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a default value of 0 so its always going to be there.
if CONF_MIN_VALUE in config: | |
lv.arc_set_range(w.obj, config[CONF_MIN_VALUE], config[CONF_MAX_VALUE]) | |
lv.arc_set_bg_angles( | |
w.obj, config[CONF_START_ANGLE] // 10, config[CONF_END_ANGLE] // 10 | |
) | |
lv.arc_set_rotation(w.obj, config[CONF_ROTATION] // 10) | |
lv.arc_set_mode(w.obj, literal(config[CONF_MODE])) | |
lv.arc_set_change_rate(w.obj, config[CONF_CHANGE_RATE]) | |
lv.arc_set_range(w.obj, config[CONF_MIN_VALUE], config[CONF_MAX_VALUE]) | |
lv.arc_set_bg_angles( | |
w.obj, config[CONF_START_ANGLE] // 10, config[CONF_END_ANGLE] // 10 | |
) | |
lv.arc_set_rotation(w.obj, config[CONF_ROTATION] // 10) | |
lv.arc_set_mode(w.obj, literal(config[CONF_MODE])) | |
lv.arc_set_change_rate(w.obj, config[CONF_CHANGE_RATE]) |
if CONF_SRC in config: | ||
for x in config[CONF_SRC]: | ||
await cg.get_variable(x) | ||
srcs = [lv_expr.img_from(MockObj(x)) for x in config[CONF_SRC]] | ||
src_id = cg.static_const_array(config[CONF_SRC_LIST_ID], srcs) | ||
count = len(config[CONF_SRC]) | ||
lv.animimg_set_src(w.obj, src_id, count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONF_SRC
is Required so it will always be there
if CONF_SRC in config: | |
for x in config[CONF_SRC]: | |
await cg.get_variable(x) | |
srcs = [lv_expr.img_from(MockObj(x)) for x in config[CONF_SRC]] | |
src_id = cg.static_const_array(config[CONF_SRC_LIST_ID], srcs) | |
count = len(config[CONF_SRC]) | |
lv.animimg_set_src(w.obj, src_id, count) | |
for x in config[CONF_SRC]: | |
await cg.get_variable(x) | |
srcs = [lv_expr.img_from(MockObj(x)) for x in config[CONF_SRC]] | |
src_id = cg.static_const_array(config[CONF_SRC_LIST_ID], srcs) | |
count = len(config[CONF_SRC]) | |
lv.animimg_set_src(w.obj, src_id, count) |
if CONF_MIN_VALUE in config: | ||
lv.bar_set_range(var, config[CONF_MIN_VALUE], config[CONF_MAX_VALUE]) | ||
lv.bar_set_mode(var, literal(config[CONF_MODE])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if CONF_MIN_VALUE in config: | |
lv.bar_set_range(var, config[CONF_MIN_VALUE], config[CONF_MAX_VALUE]) | |
lv.bar_set_mode(var, literal(config[CONF_MODE])) | |
lv.bar_set_range(var, config[CONF_MIN_VALUE], config[CONF_MAX_VALUE]) | |
lv.bar_set_mode(var, literal(config[CONF_MODE])) |
async def to_code(self, w: Widget, config): | ||
add_lv_use(CONF_BAR) | ||
if CONF_MIN_VALUE in config: | ||
# not modify case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only because of this comment I realised that the reason all of the above has config checks is because the to_code
function is being reused here for updates
.
To save on this confusion in the future, it would be nice if there was modify_to_code
or similar in the Widget
s
(Im leaving the suggestions as I already made them before getting this far)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To save on this confusion in the future, it would be nice if there was
modify_to_code
or similar in theWidget
s
That would just duplicate the code in many cases. The point of using the same function is that you can then be confident that an update has exactly the same effect as an original definition.
DO NOT USE THIS PR as an external component - it is not a complete implementation. See #6363 or #7184 for a working implementation of LVGL.
What does this implement/fix?
Types of changes
Related issue or feature (if applicable): fixes
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#3678
Test Environment
Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: