Should lv_obj_set_style_bg_color() skip redraw?
Introduce the problem
I've noticed that several widget operations like lv_obj_clear_flag(obj, LV_OBJ_FLAG_HIDDEN) and lv_obj_clear_state(ui_YourClockTime, LV_STATE_DISABLED | LV_STATE_USER_1 | LV_STATE_USER_2 | LV_STATE_USER_3 | LV_STATE_USER_4 ) do not trigger redrawing a widget if the widget currently doesn't have those flags or states.
This is quite handy when writing code to update widgets that doesn't necessarily run when the widget needs change d - you can adjust the flags and states every time to the desired state and LVGL will only draw when required. One example of this is a digital clock with various fields, options, and background colors depending on the remaining time.
But I've also noticed that a v9.3.0, lv_obj_set_style_bg_color(obj, a_color_that_changes_rarely, LV_PART_MAIN | LV_STATE_DEFAULT) seems to cause a redraw every frame, even when the color is the same as it was on the previous frame.
Proposal
Would it make sense for lv_obj_set_style_bg_color() to become a no-op when the specified color matches?
Or, is it better to do this sort of logic at the application layer, like:
lv_color_t prev_color = lv_obj_get_style_bg_color(obj, LV_PART_MAIN);
if(prev_color != new_color){
lv_obj_set_style_bg_color(obj, LV_PART_MAIN, new_color);
}Source: lvgl/lvgl