2019-01-04 12:02 PM
I started a project from scratch in CubeMX.
and the set TouchGFX for portrait as :
Middleware->Graphics->TouchGFX, changed width : 272 and Height : 480.
In TouchGFX designer it displays correctly as Portrait(see PortraitFromTouchGFX).PNG) but when I compiled using IAR and deployed it on the target bd, it doesn’t display correctly (see From STM32F746-Disco Display.jpg )
In Hal.hpp : It automatically sets the display orientation based on width/height, so I don't think I need to do anything else. (Changing LTDC etc)
HAL(DMA_Interface& dmaInterface, LCD& display, TouchController& touchCtrl, uint16_t width, uint16_t height) :
dma(dmaInterface),
lcdRef(display),
touchController(touchCtrl),
mcuInstrumentation(0),
buttonController(0),
taskDelayFunc(0),
frameBuffer0(0),
frameBuffer1(0),
frameBuffer2(0),
refreshStrategy(REFRESH_STRATEGY_DEFAULT),
fingerSize(1),
lockDMAToPorch(true),
touchSampleRate(1),
mcuLoadPct(0),
vSyncCnt(0),
vSyncForFrame(1),
vSyncCompensationEnabled(false),
clientDirty(false),
swapRequested(false),
lastTouched(false),
updateMCULoad(0),
cc_begin(0),
displayOrientationChangeRequested(false)
{
instance = this;
DISPLAY_WIDTH = width;
DISPLAY_HEIGHT = height;
DISPLAY_ROTATION = rotate0;
FRAME_BUFFER_WIDTH = DISPLAY_WIDTH;
FRAME_BUFFER_HEIGHT = DISPLAY_HEIGHT;
nativeDisplayOrientation = ((width >= height) ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT);
}
Solved! Go to Solution.
2019-01-11 01:28 AM
I'll just post it here for others see. Let me know if it helps!
http://ftp.draupnergraphics.com/TouchGFX/knowledgebase/f746grotation.zip
2019-01-04 03:21 PM
Hi @JJoha.2, can you tell me in your generated code what the ImageWidth and ImageHeight for your LTDC layer configuration is set to ?
Did you also ensure that your images are being rotated in the TouchGFX application configuration? (config/gcc/app.mk).
TouchGFX can be configured to render in portrait mode even if your hardware configuration is configured for landscape. That's why the image converter can be configured to rotate the images.
You can read more about rotating TouchGFX applications here:
https://touchgfx.zendesk.com/hc/en-us/articles/203563972-Display-Orientation
Let me know if this helps. If you're still having problems, i'll try to create an example on a disco board.
Thanks!
2019-01-05 02:06 PM
I did a few examples on an STM32F769-DISCO i have at home to exemplify how rotation generally works in TouchGFX.
The Canvas in your touchgfx application should match the native orientation of your display (in terms of where the first pixel is drawn and the direction subsequent pixels are drawn). If it doesn't because you either cannot change it or because you need to support a runtime change in display orientation you can do so in software with TouchGFX.
The LTDC layer configuration i'm running is 800x480 (landscape).
The following image shows the Button Example running correctly in portrait mode (Chose it because it's width is the same as the height of the display on stm32f769-disco). I'm doing this by configuring two things:
1) I'm telling the image converter to rotate all my images by changing the value of the scren_orientation property in the file config/gcc/app.mk.
screen_orientation := -rotate90
2) By forcing TouchGFX HAL into portrait mode. This mode will automatically translate touch coordinates as well. You were correct in assuming that, initially, HAL will determine the orientation as determined by the width and height of the display (Different from the width and height of the application canvas)
HAL::getInstance()->setDisplayOrientation(ORIENTATION_PORTRAIT);
The following image shows the application running incorrectly because i rotated my images but "forgot" to tell TouchGFX HAL that i wanted to render frames rotated 90 degrees by calling setDisplayOrientation()
The following image shows the application running incorrectly because i "forgot" to rotate the images, but correctly told HAL to render frames rotated 90 degrees.
2019-01-07 04:36 AM
Martin,
Thanks for your valuable response. Could you please share the source code with landscape and portrait that you have mentioned above?. In the meantime I'll try what you have suggested above
2019-01-07 05:01 AM
Here are my settings for LTDC
void MX_LCD_Init(void)
{
LTDC_LayerCfgTypeDef pLayerCfg;
/* De-Initialize LTDC */
HAL_LTDC_DeInit(&hltdc);
/* Configure LTDC */
hltdc.Instance = LTDC;
hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
hltdc.Init.HorizontalSync = 40;
hltdc.Init.VerticalSync = 9;
hltdc.Init.AccumulatedHBP = 53;
hltdc.Init.AccumulatedVBP = 11;
hltdc.Init.AccumulatedActiveW = 533;
hltdc.Init.AccumulatedActiveH = 283;
hltdc.Init.TotalWidth = 565;
hltdc.Init.TotalHeigh = 285;
hltdc.Init.Backcolor.Blue = 0;
hltdc.Init.Backcolor.Green = 0;
hltdc.Init.Backcolor.Red = 0;
if (HAL_LTDC_Init(&hltdc) != HAL_OK)
{
Error_Handler( );
}
pLayerCfg.WindowX0 = 0;
pLayerCfg.WindowX1 = 480;
pLayerCfg.WindowY0 = 0;
pLayerCfg.WindowY1 = 272;
pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
pLayerCfg.Alpha = 255;
pLayerCfg.Alpha0 = 0;
pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
pLayerCfg.FBStartAdress = 0xC0000000;
pLayerCfg.ImageWidth = 480;
pLayerCfg.ImageHeight = 272;
pLayerCfg.Backcolor.Blue = 0;
pLayerCfg.Backcolor.Green = 0;
pLayerCfg.Backcolor.Red = 0;
if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
{
Error_Handler( );
}
HAL_LTDC_SetPitch(&hltdc, 272, 0);
}
2019-01-07 05:52 AM
2019-01-07 05:53 AM
In LTDC may settings are still Landscape (that is native). I did two things as suggested in the article above:
(1) BoardConfiguration.hpp : Added hal.setDisplayOrientation(ORIENTATION_PORTRAIT), as shown below
void touchgfx_init()
{
uint16_t dispWidth = 272;
uint16_t dispHeight = 480;
HAL& hal = touchgfx_generic_init<STM32F7HAL>(dma, display, tc, dispWidth, dispHeight,(uint16_t*) 0,
0, 0);
hal.setDisplayOrientation(ORIENTATION_PORTRAIT);
(2) file config/gcc/app.mk.
# Settings for image converter screen orientation (empty string =
# default value, -rotate90 rotates the image 90 degrees)
screen_orientation := -rotate90
With above changes I see distorted image button (as compared to my earlier changes) but still is it is not in portrait yet.
2019-01-07 05:56 AM
Portrait image above is from the designer and other one from the target hardware. The canvas size is correct 272x480 in my TouchGFX application
2019-01-10 05:54 AM
Hi @Johan Andrade,
I created another example just to check.
My layer configuration differs from yours.
layer_cfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
layer_cfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
layer_cfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
.touchgfx
Modify the canvas dimensions.
config/gcc/app.mk:
screen_orientation := -rotate90
BoardConfiguration.cpp:
..
hal.lockDMAToFrontPorch(false);
hal.setDisplayOrientation(ORIENTATION_PORTRAIT);
..
Having some issues with my sharing service or i'd share the project. I thought i'd get this information to you asap. Let me know if this is not sufficient and i'll get you the actual project.
Best regards,
Martin
2019-01-10 06:27 AM
Hi Martin,
Thanks for your response. I think I am getting lost. could you please share your whole project, that way will be faster or send me sourced zip of your project at jjohal@fetco.com
Thanks