This commit is contained in:
@@ -737,6 +737,7 @@ static void lv_bar_set_value_with_anim(lv_obj_t * bar, int16_t new_value, int16_
|
|||||||
anim_info->anim_start = anim_info->anim_end;
|
anim_info->anim_start = anim_info->anim_end;
|
||||||
anim_info->anim_end = new_value;
|
anim_info->anim_end = new_value;
|
||||||
}
|
}
|
||||||
|
*value_ptr = new_value;
|
||||||
/* Stop the previous animation if it exists */
|
/* Stop the previous animation if it exists */
|
||||||
lv_anim_del(anim_info, NULL);
|
lv_anim_del(anim_info, NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -126,8 +126,8 @@ void lv_switch_on(lv_obj_t * sw, lv_anim_enable_t anim)
|
|||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
anim = LV_ANIM_OFF;
|
anim = LV_ANIM_OFF;
|
||||||
#endif
|
#endif
|
||||||
lv_switch_ext_t * ext = lv_obj_get_ext_attr(sw);
|
if(lv_bar_get_value(sw) == 1)
|
||||||
ext->state = 1;
|
return;
|
||||||
lv_bar_set_value(sw, 1, anim);
|
lv_bar_set_value(sw, 1, anim);
|
||||||
lv_obj_add_state(sw, LV_STATE_CHECKED);
|
lv_obj_add_state(sw, LV_STATE_CHECKED);
|
||||||
}
|
}
|
||||||
@@ -144,8 +144,8 @@ void lv_switch_off(lv_obj_t * sw, lv_anim_enable_t anim)
|
|||||||
#if LV_USE_ANIMATION == 0
|
#if LV_USE_ANIMATION == 0
|
||||||
anim = LV_ANIM_OFF;
|
anim = LV_ANIM_OFF;
|
||||||
#endif
|
#endif
|
||||||
lv_switch_ext_t * ext = lv_obj_get_ext_attr(sw);
|
if(lv_bar_get_value(sw) == 0)
|
||||||
ext->state = 0;
|
return;
|
||||||
lv_bar_set_value(sw, 0, anim);
|
lv_bar_set_value(sw, 0, anim);
|
||||||
lv_obj_clear_state(sw, LV_STATE_CHECKED);
|
lv_obj_clear_state(sw, LV_STATE_CHECKED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ typedef struct {
|
|||||||
lv_bar_ext_t bar; /*Ext. of ancestor*/
|
lv_bar_ext_t bar; /*Ext. of ancestor*/
|
||||||
/*New data for this type */
|
/*New data for this type */
|
||||||
lv_style_list_t style_knob; /*Style of the knob*/
|
lv_style_list_t style_knob; /*Style of the knob*/
|
||||||
uint8_t state : 1; /*The current state*/
|
|
||||||
} lv_switch_ext_t;
|
} lv_switch_ext_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,8 +111,7 @@ static inline void lv_switch_set_anim_time(lv_obj_t * sw, uint16_t anim_time)
|
|||||||
*/
|
*/
|
||||||
static inline bool lv_switch_get_state(const lv_obj_t * sw)
|
static inline bool lv_switch_get_state(const lv_obj_t * sw)
|
||||||
{
|
{
|
||||||
lv_switch_ext_t * ext = (lv_switch_ext_t *)lv_obj_get_ext_attr(sw);
|
return lv_bar_get_value(sw) == 1 ? true : false;
|
||||||
return ext->state ? true : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user