cancel
Showing results for 
Search instead for 
Did you mean: 

In touchgfx,is it possible to rotate a container other then pre_made pictures?

amb
Associate III

I am trying to use touchfgx on stm32,but I have some problems .the background on the hmi will rotate sometimes,the background has a lot moving lines and shapes that rotate along.I know I can use texture mapper to realize it,but that need many texture mapper widgets.So I want to know if I can draw these shape and lines on a container,and then rotate the whole container. as far as I know,emwin can do this by using memdev.

one more question:if I want to draw many lines and shapes on the container ,I have to declare the lines in designer? or   Can I draw lines dynamicly like emwin?

1 ACCEPTED SOLUTION

Accepted Solutions
GaetanGodart
ST Employee

Hello @amb and welcome to the community!

 

If you use gpu2d like on the new stm32H7RS7 which is both affordable and very powerful, the texture mappers will be managed by the gpu2d which will be very fast. SO you can add a lot of them with no problem.
This way, you don't need to rotate a container.
Also, as far as I know, TouchGFX doesn't support rotating containers.

It is not recommended to add elements during runtime in embedded (memory limited) devices but it is possible.
You can either :

  • as you mentioned, create the lines in Designer before running
  • create the lines in code before running
  • create the lines in code during runtime

To create lines in code before running, simply declare your lines in your header file and add them to your screen in the initialize function by setting the x and y position, adding them and invalidating them.

To create lines at runtime, declare your lines in a function at runtime with "new" and set the x and y position, add them and invalidate them.

 

If this comment answer your question, I invite you to select it as "best answer".

 

Regards,

 

Edit : 

You can create a custom container, set it as cacheable, this will create a bitmap that you can use inside a texture mapper that you can rotate.
See messages below for more information.

Gaetan Godart
Software engineer at ST (TouchGFX)

View solution in original post

8 REPLIES 8
GaetanGodart
ST Employee

Hello @amb and welcome to the community!

 

If you use gpu2d like on the new stm32H7RS7 which is both affordable and very powerful, the texture mappers will be managed by the gpu2d which will be very fast. SO you can add a lot of them with no problem.
This way, you don't need to rotate a container.
Also, as far as I know, TouchGFX doesn't support rotating containers.

It is not recommended to add elements during runtime in embedded (memory limited) devices but it is possible.
You can either :

  • as you mentioned, create the lines in Designer before running
  • create the lines in code before running
  • create the lines in code during runtime

To create lines in code before running, simply declare your lines in your header file and add them to your screen in the initialize function by setting the x and y position, adding them and invalidating them.

To create lines at runtime, declare your lines in a function at runtime with "new" and set the x and y position, add them and invalidate them.

 

If this comment answer your question, I invite you to select it as "best answer".

 

Regards,

 

Edit : 

You can create a custom container, set it as cacheable, this will create a bitmap that you can use inside a texture mapper that you can rotate.
See messages below for more information.

Gaetan Godart
Software engineer at ST (TouchGFX)

Thanks for your answer,that helps a lot .

Hello @GaetanGodart  

I read the docs and found CacheableContainer. In docs,it says this:

The important difference is that a CacheableContainer can also render its content to a dynamic bitmap which can then be used as a texture in subsequent drawing operations, either as a simple Image or in a TextureMapper. If the bitmap format of the dynamic bitmap differs from the format of the current LCD, the LCD from drawing the bitmap must be setup using HAL::setAuxiliaryLCD().

I hope this CacheableContainer can solve my problem. But I didn't found any demos or examples in designer,can you give me one?

hope for your reply.

GaetanGodart
ST Employee

Hello @amb ,

 

You can find an example of cacheable custom container in the board specific demo of the STM32U5G9 : the Ebike demo.

GaetanGodart_0-1717145747552.png

This is how we turn a custom container to cacheable :

GaetanGodart_1-1717147284049.png

When cached, it is turned into a bitmap.
From there you can load that bitmap as data for your texture mapper.
I have looked in the code, I don't think we use texture mapper. I have also looked at the BitmapDatabase.cpp file to see if we had the containers as bitmaps but I haven't seen them.

 

Nevertheless, texture mappers are expensive to redraw unless you have hardware graphic acceleration (neochrom or chrom art).
Also, if you know your elements (that turn in circle) are at the same position from each other (like the stars in the sky at night, they are all spaced at a constant distance from one another) then you could just make a big image of those elements (in your case lines) and simply rotate the image?

 

You said "the background will rotate sometimes, the background has a lot of lines that will move along". So just making a new background image with the lines included and rotating the image seems the easiest solution.

If you lack memory, compress the background image. If you need better performance, do not compress the image.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

hello @GaetanGodart 

I have already bought a few u599 for test,I believe the drawing speed wouldn't be a problem. the u5g9 has gpu2d VG for vector grapth,it may be a better choice,but I have to try u599 first.

thanks for your help ,I will look into the ebike demos.

If you have other questions, don't hesitate to create a new thread! :smiling_face_with_smiling_eyes:

Gaetan Godart
Software engineer at ST (TouchGFX)

hello @GaetanGodart 

I have tried the demo and found the cacheable container indeed can be used as a source of textureMapper .

QQ截图20240531193354.png

the red part is a image widget,the yellow part is a textureMapper widget with 1 rad rotate .The image source is dynamicBitmaps[1].

this really makes my project a lot easier.

That's great to hear.

I have updated the message that was selected as best answer to reflect this!

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)