Skip to content
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

Rotate Base object (lv_obj) v9 #6218

Open
iSetebos opened this issue May 13, 2024 · 14 comments
Open

Rotate Base object (lv_obj) v9 #6218

iSetebos opened this issue May 13, 2024 · 14 comments
Labels

Comments

@iSetebos
Copy link

Introduce the problem

Do I return a Base object (lv_obj) with all objects on it in version 9? In version 8 I used lv_obj_set_style_transform_angle.

Proposal

No response

@liamHowatt
Copy link
Collaborator

liamHowatt commented May 13, 2024

If I understand correctly, yes, that aspect is the same in version 9 compared to version 8.

https://docs.lvgl.io/master/overview/obj.html

Regarding lv_obj_set_style_transform_angle, that should work since it's mapped using an API mapping for v8->v9, but lv_obj_set_style_transform_rotation is the new function name.

@iSetebos
Copy link
Author

lv_img_set_angle and lv_obj_set_style_transform_angle not work.

@liamHowatt
Copy link
Collaborator

Do you get a compiler error or do they not work as intended at runtime?

@iSetebos
Copy link
Author

iSetebos commented May 13, 2024

Compiles but does not work properly. More precisely, there is no image. At the same time, the stream in which lvgl loads the processor by 100%.

@liamHowatt
Copy link
Collaborator

Is it a binary image? See #6193. This is a known weakness of binary images.

https://docs.lvgl.io/master/widgets/image.html#transformations

The transformations require the whole image to be available. Therefore indexed images (LV_COLOR_FORMAT_I1/2/4/8_...), alpha only images cannot be transformed. In other words transformations work only on normal (A)RGB or A8 images stored as C array, or if a custom Image decoder returns the whole image.

@iSetebos
Copy link
Author

This is a png-decoded image in ARGB8888 format, which is located in the RAM array.

@liamHowatt
Copy link
Collaborator

Interesting. Could you please send some code to reproduce the issue?

@iSetebos
Copy link
Author

Load image:

void CreatePngImage(T_PNG_IMAGE *Img, const char *mem, uint16_t size, uint16_t w, uint16_t h)
{
  Img->img = fbg_loadPNGFromMemory(mem, size);
  Img->img->data[2] = 4;
 uint32_t x, y, index = 0, color;
	for (uint32_t i=0; i<((w*h)); i++)
		{
			color = Img->img->data[index]<<16;
			color |= Img->img->data[index+1]<<8;
			color |= Img->img->data[index+2];
			if (color == 0xFF00FF)
			{
				Img->img->data[index] = 0;
				Img->img->data[index+1] = 0;
				Img->img->data[index+2] = 0;
				Img->img->data[index+3] = 0;
			}
			index += 4;
		}
 
  uint32_t *img_buff32 = (uint32_t *)(Img->img)->data;
 
  // swap color R<->B
  unsigned char *img_buff = (unsigned char *)(Img->img)->data;
  unsigned char tmp;
  
  for (uint32_t i=0; i<((w*h)); i++)
  {
    tmp = *img_buff;
    *img_buff     = *(img_buff+2);
    *(img_buff+2) = tmp;
    img_buff += 4;
  }
  //
  //Img->dsc.header.always_zero = 0;
  Img->dsc.header.w = w;
  Img->dsc.header.h = h;
  Img->dsc.header.cf = LV_COLOR_FORMAT_ARGB8888; //LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED; 
  Img->dsc.data = (unsigned char *)(Img->img)->data;  
  Img->dsc.data_size = w * h * LV_COLOR_DEPTH / 8;
}

Image display:

lv_obj_t * imgArrow;
CreatePngImage(&IMG.Arrow,      &_imageArrow,     392,  43,  44);
imgArrow= lv_img_create(osdDirHome.Panel);  
lv_img_set_src(imgArrow, &IMG.Arrow.dsc);
lv_obj_set_size(imgArrow, 43, 44);
lv_obj_set_pos(imgArrow, 48/2-43/2, 48/2-44/2);
lv_img_set_angle(imgArrow, (180+osdDirHome.Angel*10)%360);

@kisvegabor
Copy link
Member

kisvegabor commented May 14, 2024

lv_img_set_angle(imgArrow, (180+osdDirHome.Angel*10)%360);

The angle is in 0.1° unit, so it should be:

lv_img_set_angle(imgArrow, (1800+osdDirHome.Angel*10)%3600); //1800 and %3600

@iSetebos
Copy link
Author

lv_img_set_angle(imgArrow, (180+osdDirHome.Angel*10)%360);

The angle is in 0.1° unit, so it should be:

lv_img_set_angle(imgArrow, (1800+osdDirHome.Angel*10)%3600); //1800 and %3600

I agree. But that's not the problem.

@liamHowatt
Copy link
Collaborator

I can't seem to reproduce it. Does it work perfectly when you don't set the angle?

@iSetebos
Copy link
Author

If the angle is 0, then everything works, in other cases the program hangs.

@liamHowatt
Copy link
Collaborator

You mentioned the CPU goes to 100%. There's a chance an LV_ASSERT failed and the default behavior is to spin forever (while(1);). Do you have a way of getting a stacktrace or some other way of finding out where it's failing?

@lvgl-bot
Copy link

lvgl-bot commented Jun 4, 2024

We need some feedback on this issue.

Now we mark this as "stale" because there was no activity here for 14 days.

Remove the "stale" label or comment else this will be closed in 7 days.

@lvgl-bot lvgl-bot added the stale label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants