It is possible to resize an Arc during an animation?
The only thing I have managed to do is moving an arc even though i use the lv_obj_set_width, not the lv_obj_set_x.
If I try using both an lv_obj_set_width and lv_obj_set_height in tow different animations at once, it crashed.
And if I try the lv_obj_set_size the arc disappears.
Please fill out the template.
1 Like
Description
It is possible to resize an Arc during an animation?
The only thing I have managed to do is moving an arc even though i use the lv_obj_set_width, not the lv_obj_set_x.
If I try using both an lv_obj_set_width and lv_obj_set_height in tow different animations at once, it crashed.
And if I try the lv_obj_set_size the arc disappears.
What MCU/Processor/Board and compiler are you using?
Pc Simulator on a Linux VMWare
What do you want to achieve?
Animation where an arc is enlarged on click
What have you tried so far?
See Description.
Code to reproduce
static lv_obj_t * Arc;
static void event_handler(lv_obj_t * obj, lv_event_t event)
{
if(event == LV_EVENT_PRESSED) {
lv_anim_t a;
a.var = Arc;
a.start = 135;
a.end = 265;
a.exec_cb = (lv_anim_exec_xcb_t) lv_obj_set_width;
a.path_cb = lv_anim_path_linear;
a.ready_cb = NULL;
a.act_time = 0;
a.time = 500;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
lv_anim_create(&a);
}
Right now the button push is coming from a button obj that has nothing to do with the arc
{
static lv_style_t ArcStyle;
lv_style_copy(&ArcStyle,&lv_style_plain);
ArcStyle.line.color = LV_COLOR_BITZER;
ArcStyle.line.width = 8;
Arc = lv_arc_create(lv_disp_get_scr_act(NULL), NULL);
lv_obj_set_size(Arc,135,135);
lv_arc_set_angles(Arc, 0, 360);
lv_arc_set_style(Arc, LV_ARC_STYLE_MAIN, &ArcStyle);
}
You need to animate the height too:
lv_anim_t a;
a.var = Arc;
a.start = 135;
a.end = 265;
a.exec_cb = (lv_anim_exec_xcb_t) lv_obj_set_width;
a.path_cb = lv_anim_path_linear;
a.ready_cb = NULL;
a.act_time = 0;
a.time = 500;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
lv_anim_create(&a);
/*Use the same anim. data jsut change the width to height*/
a.exec_cb = (lv_anim_exec_xcb_t) lv_obj_set_height;
lv_anim_create(&a);
Thanks, that do work
I thought I should make animation A for one width and B for height, but that only got it to crash instead.
For the record can you copy the code which crashed? It might be useful for people to see the difference.
I am trying to incapsulate the code in C++ classes, to use in a project.
This makes it crash:
LvAnimation WidthChange(Arc);
WidthChange.AnimMode(TypeAnim::Width, PathAnim::Linear);
WidthChange.SetMovement(Arc.GetWidth(), Arc.GetWidth() + 100);
WidthChange.SetTiming(0, 500);
WidthChange.Play();
LvAnimation HeightChange(Arc);
HeightChange.AnimMode(TypeAnim::Height, PathAnim::Linear);
HeightChange.SetMovement(Arc.GetHeigth(),Arc.GetHeigth() + 100);
HeightChange.SetTiming(0, 500);
HeightChange.Play();
While this makes it work
LvAnimation SizeChange(Arc);
SizeChange.AnimMode(TypeAnim::Width, PathAnim::Linear);
SizeChange.SetMovement(Arc.GetWidth(), Arc.GetWidth() + 100);
SizeChange.SetTiming(0, 500);
SizeChange.Play();
SizeChange.AnimMode(TypeAnim::Height, PathAnim::Linear);
SizeChange.Play();
Behind the scenes the following stuff is happening
LvAnimation::LvAnimation(GuiObject obj)
{
this->LvAnim->var = obj.GetObject();
}
void LvAnimation::SetTiming(int16_t StartTime, uint16_t Duration)
{
this->LvAnim->act_time = StartTime;
this->LvAnim->time = Duration;
}
void LvAnimation::SetMovement(int16_t Start, int16_t Finish)
{
this->LvAnim->start = Start;
this->LvAnim->end = Finish;
}
void LvAnimation::Play()
{
lv_anim_create(this->LvAnim);
}
void LvAnimation::AnimMode(int Type, int Path)
{
AnimType(Type);
AnimPath(Path);
}
void LvAnimation::AnimType(int mode)
{
switch (mode) {
case TypeAnim::Height:
{
this->LvAnim->exec_cb = reinterpret_cast<lv_anim_exec_xcb_t>(lv_obj_set_height);
break;
}
case TypeAnim::Width:
{
this->LvAnim->exec_cb = reinterpret_cast<lv_anim_exec_xcb_t>(lv_obj_set_width);
break;
}
case ... ....
}
}
void LvAnimation::AnimPath(int path)
{
switch (path) {
case PathAnim::Linear:
default:
{
this->LvAnim->path_cb = lv_anim_path_linear;
break;
}
case ... ...
}
}
´´´
Thank you. However, I can’t see why it crashes. It seems you are just setting the same values again for height animation.
Yes, And it seems that if I use specific numbers for my start or end width, instead of my getWidth command, it also breaks.
I found the problem:
I had defined the animation variable as the pointer to it, rather then just an animation variable
// Was
lv_anim_t * LvAnim;
// Shoud be
lv_anim_t LvAnim;
Now I can set specific sizes
Great!
I could see it from this->LvAnim->var
because it should be this->LvAnim.var
.
Maybe it’s just a temporary bug. If you could wait for it to pass.
As @ThaBitzer mentioned, the issue was solved.