Description
I am using a checkbox in my display. I am using lv_obj_add_state API and setting the status to LV_STATE_CHECKED and LV_STATE_DISABLED.
When I query back to has state and get state APIS both are returning wrong states.
I see that there is a difference in implementations of the add-state api from previous lvgl to current lvgl.
Previous LVGL
void lv_obj_add_state(lv_obj_t * obj, lv_state_t state)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_state_t new_state = obj->state | state;
if(obj->state != new_state) {
if(new_state & LV_STATE_DISABLED) {
lv_indev_reset(NULL, obj);
}
lv_obj_set_state(obj, new_state);
}
}
Current LVGL
void lv_obj_add_state(lv_obj_t * obj, lv_state_t state)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_state_t new_state = obj->state | state;
if(obj->state != new_state) {
if(new_state & ~obj->state & LV_STATE_DISABLED) {
lv_indev_reset(NULL, obj);
}
update_obj_state(obj, new_state);
}
}
The creation of checkbox in the checked and disabled looks correct and it is only an issue when I try to get a state of this button
What MCU/Processor/Board and compiler are you using?
DISCOVERY-769NI
What LVGL version are you using?
9.2.2
What do you want to achieve?
I want to get status of checkbox and see if it is both checked and disabled.
What have you tried so far?
Also tried using lv_obj_get_state(). This doesn’t work either. In debugger I see 145 being returned as the state but it should be 129.
The lv_obj_has_state is returning true even for all LV_STATE_CHECKED, LV_STATE_DISABLED and LV_STATE_CHECKED | LV_STATE_DISABLED as well.
This exact piece of code works when the checkbox state is only LV_STATE_CHECKED. Also this code worked okay with previous lvgl version as well.
Code to reproduce
for (cnt = 0; cnt < chck_box_cnt; cnt++){
lv_obj_add_state(checkboxes[cnt],
LV_STATE_CHECKED | LV_STATE_DISABLED);
lv_obj_has_state(checkboxes[cnt],
LV_STATE_CHECKED | LV_STATE_DISABLED);
}