cancel
Showing results for 
Search instead for 
Did you mean: 

REPOST: Change LCD orientation in 180 degree

QUESTION - TouchGFX Community repost - Eyal goltzman - July 2016

Hello,

Following Yossi question from today and Martin reference to Soren answer in https://touchgfx.zendesk.com/hc/en-us/community/posts/206708899--orientation-180-degree

We are using LCD without SPI interface, only parallel RGB interface through the LCD-TFT Controller peripheral, so controlling the LCD as describe in your answer to the above link is not an option.

Since our customers have a mechanical issue with the display orientation (the flat cable position) we are trying to address it with SW solution.

As I see it, there is an option to rotate the frame buffer just before calling swapFrameBuffers, what do you think? It could be done? performance issues? Can we do it ourselves? How?

Thanks,

Eyal

ANSWER - TouchGFX Community repost - Soren Pingel Dalsgaard - July 2016

Hi Eyal,

How unfortunate! You could do the rotation manually, but the performance penalty will be very significant, to the extent that only very simple UIs can be realized.

This is due to two things:

  1. If anything changes on screen then you must invalidate() the entire screen. Otherwise it will not have properly "undone" the rotation from last time, causing the widgets to appear in both normal and rotated positions.
  2. The rotation algorithm must invert both X and Y axis. This means that you must either read or write each and every pixel of the screen non-sequentially to SDRAM, which is very expensive.

I think the right place to do such a rotation would be by overriding HAL::endFrame. Something like this:

void MyHAL::endFrame()
{
  dma.flush(); //wait for all dma operations to have completed
  rotateFb(getClientFrameBuffer()); //apply rotation on the fb
  HAL::endFrame(); //call base impl when rotation is done.}

Apart from this you would need also to invert the coordinates in your touch controller driver.

You can give it a shot, but I am not too optimistic to be honest. Hopefully you could convince your customer to switch to another display that can either be mounted normally or supports scan direction swap.

36 REPLIES 36

You can create this example yourself easily. It's so simple i deleted it.

  1. Create an application based on STM32F746G-DISCO in the designer
  2. Add a background box.
  3. Add a smaller box in a corner
  4. Copy in the mirror.hpp file and add it to the view (in gui/, like you've done here)
  5. Press "Run on target" from the designer.

It would probably be good for you to see it with a simple example, yeah. And sure, the non-rotated stuff you're seeing could be the hardfault

/Martin

I tried it but didn't get it working. It's the same as before. I get in a hardfault.

I've attached the STM32F746G-DISCO example. (Atollic Project)

I've done the following steps:

  • copied the Mirror.hpp to the project
  • added the draw function to FrontendApplication.hpp (as described by you 8 months ago)
  • set the position of the mirror screen and add it as a child in Screen1View.cpp
  • include the Mirror.hpp and declare the mirror screen in Screen1View.hpp

Maybe you can see what I've done wrong.

But you can get other examples running no problem?

/Martin

Yes, other examples are running like it should. I'm only getting trouble with the screeen mirroring.

Regards

Dejan

I'm having some issues with the mirror.hpp file from your project. I have no problems with the original Mirror.hpp i posted - Follow the instructions in the original post. I'll repost it here.

Actually, just scroll up and check the post that was edited January 2. It has the original Mirror.hpp and a guide for how to add it. I forgot to mention you need to add some code in FrontEndApplication.hpp to redraw the entire screen always (Lack of this should not cause a fault, though) and make some modifications to your touch controller.

/Martin

I've already seen the post from January. It was my fault, I had a wrong width in DISP_WIDTH. That's why i got the hardfault.

Now it mirrors the display correctly. When I press on the touchscreen to select a checkbox it changes the rotation to 0 degress. The other time I press on this checkbox it changes the rotation back to 180 degrees.

Do you have any idea why it's changing the rotation everytime the checkboxes are pressed?

Regards

Dejan

@Martin KJELDSEN​ 

It's working now. I just had to refresh and rebuild the project in atollic.

Thank you very much for your support.

Regards Dejan

That's great, @Dejan Nedeljkovic​,

No problem!

/Martin

Hi , Martin

Did you mean that now only some MCU which take GFXMMU module like STM32L4R9 can support 180 degree rotation display ?