Skip to main content
Freedom_Neo
Senior
February 7, 2022
Solved

I want to rotate screen 90 degree in TouchGFX

  • February 7, 2022
  • 6 replies
  • 8215 views

I want to rotate 90 degree the screen. How do it?

Rotate the screen 90 degrees?

This topic has been closed for replies.
Best answer by MM..1

You dont need for touch register setup (maybe controller IC have one but simpler way is)

edit in target file TouchGFX\target\STM32TouchController.cpp

bool STM32TouchController::sampleTouch(int32_t& x, int32_t& y)
{
 /**
 * By default sampleTouch returns false,
 * return true if a touch has been detected, otherwise false.
 *
 * Coordinates are passed to the caller by reference by x and y.
 *
 * This function is called by the TouchGFX framework.
 * By default sampleTouch is called every tick, this can be adjusted by HAL::setTouchSampleRate(int8_t);
 *
 */
	if(i2cRXbuff[0]==0) return false;
	x=i2cRXbuff[2];
	y=i2cRXbuff[4];
	return true;
}

This is only example code and for change flip simply rewrite two lines x=XMAX-x; ...

6 replies

Romain DIELEMAN
ST Employee
February 7, 2022

Hi,

Within TouchGFX Designer you can set the display orientation to either Landscape or Portrait mode, so a 90degree rotation. To do so, go to the Config tab in the bottom left of TouchGFX Designer and go to the Display section.

Otherwise you can do this as you said within STM32CubeMX where you set the display to 480*800.

/Romain

Freedom_Neo
Senior
February 7, 2022

I rotated 90 degree. But Letters rotated 180 degrees. How can I it solve this problem.

Romain DIELEMAN
ST Employee
February 7, 2022

What option did you use to rotate 90 degrees in the end ? That issue is unusual I never faced it. Could you try to delete that TextArea widget and create another one to see if you still face it ? Did you by any chance added some user code before where you would change the text rotation :grinning_face_with_sweat:?

MM..1
Chief III
February 7, 2022

TouchGFX rotate 90 change communication width and heigth , other rotations you need create mechanicaly rotate LCD or by LCD setup config registers. Try search and change MADCTL

Freedom_Neo
Senior
February 8, 2022

There is no MADCTL parameter. You can see the pin configuration of the screen below.

MM..1
Chief III
February 9, 2022

MADCTL isnt pin, this is register in display controller if your display have one.

Freedom_Neo
Senior
February 10, 2022

The screen should rotate to the right but the screen rotates to the left. I think there should be an option to rotate left or right in the TouchGFX interface. It only has a left rotation feature.

0693W00000JPFGKQA5.png

Romain DIELEMAN
ST Employee
February 10, 2022

Hi,

I agree, but it is actually harder than it seems and impacting the performances. It would be a 270degree rotation and not a 90degree rotation. It is still in our backlog to make this available, but I do not know for which version it will be released. To be honest in most real life cases you just need to manually put upside down the display to "resolve" this.

/Romain

Freedom_Neo
Senior
February 10, 2022

Special molds are designed for screens and PCBs are designed accordingly. Manually rotating the screen is a simple solution, but it challenges manufacturers mechanically and manufacturably. I think this should be in the TouchGFX interface. When are you planning to release this feature in the near future?

MM..1
MM..1Best answer
Chief III
February 11, 2022

You dont need for touch register setup (maybe controller IC have one but simpler way is)

edit in target file TouchGFX\target\STM32TouchController.cpp

bool STM32TouchController::sampleTouch(int32_t& x, int32_t& y)
{
 /**
 * By default sampleTouch returns false,
 * return true if a touch has been detected, otherwise false.
 *
 * Coordinates are passed to the caller by reference by x and y.
 *
 * This function is called by the TouchGFX framework.
 * By default sampleTouch is called every tick, this can be adjusted by HAL::setTouchSampleRate(int8_t);
 *
 */
	if(i2cRXbuff[0]==0) return false;
	x=i2cRXbuff[2];
	y=i2cRXbuff[4];
	return true;
}

This is only example code and for change flip simply rewrite two lines x=XMAX-x; ...

Freedom_Neo
Senior
February 11, 2022

@MM..1​ It worked. I hope it won't cause any problems in the future.