2019-10-15 02:51 AM
Since the new TouchGFX 4.12.3 came out, i saw it's finally possible to swtch from landscape to portrait orientation, which is great because i was asked to develop my project with both orientations.
i saw the orientation is changed by this line of code :
touchgfx::HAL::getInstance()->setDisplayOrientation(touchgfx::ORIENTATION_LANDSCAPE);
just switching the function argument.
so i changed my code calling that function changing that parameter, and the effective orientation of the simulator changed, but the problems are the images
as you can see the images are rotated if are square, and just a mess if are rectangle.
i saw you can change the image oriantation in the designer, but that make all the images cpp file recompiled, so impracticable for changing orientation runtime...
Any way to accomplish what i'm looking for?
Thanks
Stefano
2019-10-15 04:57 AM
Lanscape/Portrait has always been possible, but now it can be configured through the designer, yes!
What you're trying to do now is create an application oriented natively to landscape. But you haven't generated your images in that format, so you're seeing some "garbage", or, images drawn in the wrong direction.
You can read more about how to create applications that support dynamic rotation:
https://touchgfx.zendesk.com/hc/en-us/articles/203563972-Display-Orientation
/Martin
2019-10-15 05:13 AM
ok, thanks, just a question before i dive in... will i need to load images in both orientation?
2019-10-15 05:54 AM
Yes, "unfortunately" (but not surprisingly) - You need to have the assets in both configurations if you intend on doing it runtime.
/Martin
2019-10-15 06:37 AM
uhm, i tryed to rename myImage.png in myImage.90.png, and touchGFX creates a myImage.90.cpp of the same size, and there is not any myImage.cpp, and i loaded only the myImage.90.png, so your comment confuses me... unless by assets you means the picture and other elements spatial positions, and not the images themselves (i have a LOT of images, my memory is almost full, can't afford to double images for portrait orientation)
2019-10-15 07:11 AM
Before we continue - Do you need to support dynamic rotation? If yes, then you need two sets of images. Translating images run-time would be terribly inefficient.
When you call HAL::getInstance()->setDisplayOrientation(..) you're not changing hardware configuration, only software, so you can imagine that the TFT controller is still just clocking out pixels and the display is displaying those pixels starting from the same perception it has of 0,0 as before. So if you want to dynamically display a different orientation, effectively, you must know all states of the images at run-time.
/Martin
2019-10-15 07:47 AM
no, i'm not going to dinamically rotate, but my software will be loaded in 2 different machine, one with potrait screen and one with landscape scree, and i was told to do just one version with both, so when changes to the software will be asked, only one version will be changed
2019-10-16 12:53 AM
OK now i'm definitey confused, yesterday my app seems to worked fine after renamin all the image.png in image.90.png, but this morning all went back to the situation in the picture i linked above, and worst things is that if i put layout rotation 90 in touchGFX, TODAY he acts like was rotation 270 (see picture)
also you can see behind the cup and hand images some remains of the previous screen (although i have a black box filling the whole background)
pls help
2019-10-17 05:13 AM
Okay, not haveing to support dynamic rotation simplifies things a bit, in a way. But i think there are things you're not considering. You can't just rotate an application and expect touchgfx to magically guess how your application should look. By enabling "PORTRAIT" mode, you're just telling TouchGFX to render things in a different way. It will not "rotate" your box for you, for instance. So whoever told you to just have it all as one application might not have thought things completely through.
If you're using 4.12.3 you can configure your application to be portrait mode or landscape mode from within the designer gui (Otherwise you just pass "-rotate90" to imageconverter and tell HAL to set the display orientation).
You will have to create an application for each. Your background box will no longer be .e.g 800 x 480, but now it should be 480 x 800. And you need to handle that in application code one way or the other. Does that make sense?
You could have everything in the same application but you'd have additional code that checked for the current ORIENTATION and then set up the view accordingly, OR you would have to use preprocessor directives that set up the view depending on the orientation.
What changing orientation through the designer will also do is tell the "image converter" to rotate all images when it generates pixels to c++ code.
/Martin
2019-10-17 05:33 AM
Well, OFC i wasn't expecting TouchGfx would magically know where i would all things to be located in the portrait mode, i've already wrote the code that moves everything in the right place.
you say :"[quote] our background box will no longer be .e.g 800 x 480, but now it should be 480 x 800. And you need to handle that in application code one way or the other. Does that make sense?"[/quote]
Maybe i'm wrong, but doesn't make sense to me, the 800 x 480 is the same that the 480 x 800 just rotated, but the bytes are the same, that's why i was wondering if there was a way to tell touchGFX to rotate the image from the image.cpp file instead of having to recompile all the images every time i need to rotate my app...
[quote]You could have everything in the same application but you'd have additional code that checked for the current ORIENTATION and then set up the view accordingly, OR you would have to use preprocessor directives that set up the view depending on the orientation.[/quote]
How to do that? because actually i need to recompile after changing layout rotation in touchGfx...