cancel
Showing results for 
Search instead for 
Did you mean: 

Rotation of STM32F429I-Disco LCD

ejanuska
Associate II
Posted on February 11, 2016 at 21:18

So I've been through the HAL, the CubeF4, and the StdPeriph library. 

There are many functions to do many things to the LCD but I cannot for the life of me find one to rotate the LCD or initialize it in with a landscape or portrait type orientation.

I have seen some parameters such as LTDC_VerticalStart but what exactly the parameter controls is unknown and not documented.

I have discovered that by manipulating the MADCTL bits in the ili9341.c the orientation can be changed. But then then I have width and sync issues.

I just don't get why ST went through all that trouble to create an interface for the LCD and touchscreen, then left out something so simple. Or is it there and I just don't see it?

BTW I don't want to use SPI to control the LCD, so please don't suggest using a third party SPI library. I want to use the LTDC lib.

I've read the ili9341 datasheet, its not very helpful either. 

#lcd-tft-ltdc-stm32f429
2 REPLIES 2
Overnature
Associate II
Posted on March 01, 2016 at 13:57

Simple way is to change DrawPixel function instm32f429i_discovery_lcd.c

Default, no rotataion:

void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code)
{
/* Write data value to all SDRAM memory */
*(__IO uint32_t*) (LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (4*(Ypos*BSP_LCD_GetXSize() + Xpos))) = RGB_Code; 
}

180 rotation:

*(__IO uint32_t*) (LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + 4 * (76800 - Xpos - BSP_LCD_GetXSize() * Ypos)) = RGB_Code;

90 rotation:

uint32_t temp = Xpos;
Xpos = Ypos;
Ypos = BSP_LCD_GetXSize() - 1 - temp;
*(__IO uint32_t*) (LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + 4 * (Xpos + BSP_LCD_GetXSize() * Ypos)) = RGB_Code;

-90 rotation:

uint32_t temp = Ypos;
Ypos = Xpos;
Xpos = BSP_LCD_GetYSize() - 1 - temp;
*(__IO uint32_t*) (LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + 4 * (Xpos + BSP_LCD_GetXSize() * Ypos)) = RGB_Code;

hbarta2
Associate III
Posted on March 07, 2016 at 17:46

We are using very similar H/W on a custom board and find that the STemWin API call

GUI_SetOrientation(GUI_SWAP_XY|GUI_MIRROR_X);

does the job for us. I do need to track screen orientation and remap touch coordinates relative to orientation but that's separate from rotating the screen. Our system switches back and forth between portrait and landscape with no apparent difficulty. There is another thread presently on the front page about screen orientation and bugs and I do not understand that one at all. Maybe I'm just lucky. 😉