Skip to main content
Associate II
January 29, 2024
Question

TouchGFX screen rotation

  • January 29, 2024
  • 2 replies
  • 2797 views

Hello,

In our project (STM32U5) we would like to make animation with TouchGFX (4.22) at display (320*240). We have one screen (landscape 320*240), with some pictures, text, and dynamic graph. Everything works ok. After few seconds we would like to use another screen, which is rotated for 90degrees (portrait - 240*320). But we have some problems with that.

  1. TouchGFXF does not support animation with mixing landscape and portrait screens.
  2. We can use new landscape screen and rotate text for 90degress, use rotated pictures but we cannot rotate graph.

Is there any other option for us?

This topic has been closed for replies.

2 replies

ST Employee
January 29, 2024

Hello @MatjazF ,

You can actually rotate the screen at runtime using the following function:

void ScreenWithNewOrientationView::setupScreen()
{
 touchgfx::HAL::getInstance()->setDisplayOrientation(ORIENTATION_LANDSCAPE);
 ScreenWithNewOrientationViewBase::setupScreen();
}

However, this function only rotates everything automatically, so you need to adjust the position of your widgets accordingly, so they will be shown correctly. The API for the function is available at this web page.

You also don't need to rotate your pictures manually, just need to set their rotation from the Images tab in TouchGFX.

Rotation of ImagesRotation of Images

 

I hope this helps you

MatjazFAuthor
Associate II
January 30, 2024

This is good solution if you have square screen (240*240). If you have 320*240 is not good option. In this case you just rotate the landscape screen to portrait. You lost the right part of the landscape screen and lower part of the new portrait screen is empty.

 I made one example. I rotate the landscape (320*240) screen to Portrait. Then I tried to move one Image (function moveTo (X,Y) in screenView.cpp ) from point (20,20) to point (20, 240) and there is no image. I cannot move some graphics to lower part of new portrait screen. Any suggestions?

ST Employee
February 2, 2024

I see the problem, sorry for my miss guidance. 
If you call the setDisplayOrientation() before moving to the new screen, the problem should be resolved. For instance, if you have a button that changes the screen, call setDisplayOrientation() in that function and not in the setupScreen of the newly rotated screen. 
It might not show properly in the simulator, but it works fine on the target.

void Screen1View::changeScreenAndOrientation()
{ 
 touchgfx::HAL::getInstance()->setDisplayOrientation(ORIENTATION_LANDSCAPE);
 application().gotoScreen2ScreenSlideTransitionEast();
}

--------------------------------------------------------------------------------------

void Screen2View::setupScreen()
{
 image1.moveTo(image1.getY(), image1.getX());

 Screen2ViewBase::setupScreen();
}

 

Let me know if you have more questions

MatjazFAuthor
Associate II
February 6, 2024

Thank you. Works better! :)