2025-09-11 7:25 AM
Hello i'm using touch GFX with STM32H7RS-DK And i need to evaluate for a future product if display rotation is possible.
I tried this implementation but drawCacheEnabled isn't reconize by software so i removed it and the widget is working but the screen flicker betwen 0 and 180° . Is there a more actual way of rotate a screen .
// Force redrawing entire screen
virtual void draw(Rect& rect)
{
if (drawCacheEnabled)
{
// Invalidate entire screen instead of requested rect.
Rect r(0, 0, HAL::DISPLAY_WIDTH, HAL::DISPLAY_HEIGHT);
Application::draw(r);
}
else
{
// Use original rect if we are *actually* drawing and not just invalidating.
Application::draw(rect);
}
}Thanks
Solved! Go to Solution.
2025-09-22 2:18 AM
Hi,
A big thanks for you hard work ,
Is there a toogle in the code to rotate the screen with user interaction (to show the rotation )
Thanks !!!
2025-09-23 6:01 AM
Hello @Hamady,
You are welcome, the project doesn't contain such a button, but it's implementation will mainly consist of a bypassing all the additional code (as rotations can be done in realtime). If the project answers your question, please mark it as best answer so other users can access it easily.
BR,
2025-10-08 7:17 AM
Dear @LouisB ,
Thanks you for your work, this is exactly what I was also looking for.
I have tried to integrate your work and adapt it to our project wich is based on the 24bpp example, with ARGB888 format, but I still have some difficulties to make it work as it should.
Would you mind having a look if I send you the complete project?
Thanks for your help
2025-10-10 5:06 AM
Hello @bluespark,
Since my project was made with a H7RS, and it doesnt support 24Bits Nema natively, check this thread GPU2D trouble on STM32H7S78-DK - STMicroelectronics Community and the doc TouchGFX on NeoChrom/NeoChromVG | TouchGFX Documentation before hand.
From a 16 bits to 24bits, you have to do few modifications as below from the project I gave:
in TouchGFXHAL.cpp:
// this
LOCATION_PRAGMA_NOLOAD("TouchGFX_Framebuffer")
uint32_t animationBuffer[(800 * 480 * 2 + 3) / 4] LOCATION_ATTRIBUTE_NOLOAD("TouchGFX_Framebuffer");
LOCATION_PRAGMA_NOLOAD("TouchGFX_Framebuffer")
uint32_t ltdcFrameBuf1[(800 * 480 * 2 + 3) / 4] LOCATION_ATTRIBUTE_NOLOAD("TouchGFX_Framebuffer");
LOCATION_PRAGMA_NOLOAD("TouchGFX_Framebuffer")
uint32_t ltdcFrameBuf2[(800 * 480 * 2 + 3) / 4] LOCATION_ATTRIBUTE_NOLOAD("TouchGFX_Framebuffer");
// becomes
LOCATION_PRAGMA_NOLOAD("TouchGFX_Framebuffer")
uint32_t animationBuffer[(800 * 480 * 3 + 3) / 4] LOCATION_ATTRIBUTE_NOLOAD("TouchGFX_Framebuffer");
LOCATION_PRAGMA_NOLOAD("TouchGFX_Framebuffer")
uint32_t ltdcFrameBuf1[(800 * 480 * 3 + 3) / 4] LOCATION_ATTRIBUTE_NOLOAD("TouchGFX_Framebuffer");
LOCATION_PRAGMA_NOLOAD("TouchGFX_Framebuffer")
uint32_t ltdcFrameBuf2[(800 * 480 * 3 + 3) / 4] LOCATION_ATTRIBUTE_NOLOAD("TouchGFX_Framebuffer");
Change all the NEMA_RGB565 to NEMA_RGB24 in the TouchGFXHAL.cpp.
Here in the example the screen is 800*480 so readapt the size to yours.
In CubeMX you have to put single frame buffer strategy.
I'm using a custom TouchGFXgeneratedhal also, you need to do the same in your project, in my project the custom code add is the below :
uint16_t* otherLTDCFB;
uint16_t* framebufferLTDC1;
uint16_t* framebufferLTDC2;
uint16_t* currentLTDCFB;
void initializeLTDCFB(uint32_t* framebuff,uint32_t* framebuff2) {
framebufferLTDC1 = (uint16_t*)framebuff;
framebufferLTDC2 = (uint16_t*)(framebuff2);
currentLTDCFB = framebufferLTDC1;
otherLTDCFB = framebufferLTDC2;
}
void swapLTDCFrameBuffer() {
otherLTDCFB = currentLTDCFB;
if (currentLTDCFB == framebufferLTDC1)
{
currentLTDCFB = framebufferLTDC2;
}
else{
currentLTDCFB = framebufferLTDC1;
}
}
[...]
// 180 Rotation
// We swap the ltdc framebuffers so the one we drew is shown
if (swapLTDC)
{
swapLTDCFrameBuffer();
LTDC_Layer1->CFBAR = (uint32_t)currentLTDCFB;
/* Reload immediate */
LTDC->SRCR = (uint32_t)LTDC_SRCR_IMR;
swapLTDC = false;
}
// 180 Rotation
Since this file is regenerated each time we do a code generation, you can do the same as the example I gave where, In designer Config->Build->Post generate target command, I do a copy of my custom file to the generated one.
BR,
2025-10-10 5:17 AM - edited 2025-10-10 5:27 AM
Hi @LouisB ,
Thanks for your answer. I adapted it with 32bpp as I didn't see the NEMA_RGB24 option, and used the ARGB888 format. I will make the modifications to avoid wasting RAM. My dsign is also based on a STM32H7R/S, and the 24bpp TouchGFX example. Maybe the solution is to use the GFXMMU to expose 24bpp virtual buffers based on the 32bpp calculated buffers?
I now face another problem: my display is 800x480, but is used in portait mode (so with a 90° rotation in TouchGFX designer). It works well when a full redraw is performed, but I have some strange behaviours with partial redraws: usually the first partial redraw after a full refresh is OK, but the subsequent ones are not OK. Part of the new redraw is OK, but with strange effect located on the first partial redraw.
I tried to investigate a little deeper but now I'm not really sure how the format and coordinates are handled between LTDC (setup with 800x480) and TouchGFX rectangle objects. Do you know how to translate the different coordinates? Or maybe is it related to the cache management?
I can share my project with you if you want to evaluate the problem, or we can even setup a call as I suspect we both are in France.
Thanks for your help
2025-10-15 12:36 AM
Hello @bluespark ,
1) Yes, H7R/S doesnt support 24bits, you have to use GFXMMU so the 32bits is mocked as a 24bits.
2) This has to be an issue with the coordinates, I dont think the cache is the problem and I dont know direct translation trial and error is my best bet.
3) In the forum we only offer free support but if you'd like to have a more complete support, you can also escalade the thread and be contacted by us.
Could you open a new thread ? There you share your project to me and I can take a look.
Br,