In touchgfx,is it possible to rotate a container other then pre_made pictures?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-27 9:21 PM - edited ‎2024-05-28 12:36 AM
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?
Solved! Go to Solution.
- Labels:
-
TouchGFX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-29 2:08 AM - edited ‎2024-06-03 1:20 AM
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.
Software engineer at ST (TouchGFX)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-29 2:08 AM - edited ‎2024-06-03 1:20 AM
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.
Software engineer at ST (TouchGFX)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-29 4:16 AM - edited ‎2024-05-29 4:35 AM
Thanks for your answer,that helps a lot .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-30 4:09 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-31 2:30 AM
Hello @amb ,
You can find an example of cacheable custom container in the board specific demo of the STM32U5G9 : the Ebike demo.
This is how we turn a custom container to cacheable :
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,
Software engineer at ST (TouchGFX)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-31 3:24 AM - edited ‎2024-05-31 5:06 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-31 4:19 AM
If you have other questions, don't hesitate to create a new thread! :smiling_face_with_smiling_eyes:
Software engineer at ST (TouchGFX)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-31 4:45 AM
hello @GaetanGodart
I have tried the demo and found the cacheable container indeed can be used as a source of textureMapper .
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-03 1:21 AM
That's great to hear.
I have updated the message that was selected as best answer to reflect this!
Regards,
Software engineer at ST (TouchGFX)
