forked for landscape mode text
Dependents: DISCO-F429ZI_LCDTS_demo_richard
Fork of BSP_DISCO_F429ZI by
Revision 5:a76cfea518cc, committed 2018-03-16
- Comitter:
- pierrebizouard
- Date:
- Fri Mar 16 09:50:17 2018 +0000
- Parent:
- 4:b7f549f2845c
- Commit message:
- final version 1.0
Changed in this revision
diff -r b7f549f2845c -r a76cfea518cc Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_lcd.c --- a/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_lcd.c Fri Mar 09 13:25:12 2018 +0000 +++ b/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_lcd.c Fri Mar 16 09:50:17 2018 +0000 @@ -73,7 +73,10 @@ /* Includes ------------------------------------------------------------------*/ #include "stm32f429i_discovery_lcd.h" +#include "stm32f429i_discovery_sdram.h" + #include "../Fonts/fonts.h" +#include <cstdlib> //#include "../Fonts/font24.c" //#include "../Fonts/font20.c" //#include "../Fonts/font16.c" @@ -479,9 +482,9 @@ * - LCD_RELOAD_VERTICAL_BLANKING * @retval None */ -void BSP_LCD_Relaod(uint32_t ReloadType) +void BSP_LCD_Reload(uint32_t ReloadType) { - HAL_LTDC_Relaod (&LtdcHandler, ReloadType); + HAL_LTDC_Relaod(&LtdcHandler, ReloadType); } /** @@ -635,7 +638,7 @@ /* Characters number per line */ #ifdef LANDSCAPE_MODE - xsize = (BSP_LCD_GetYSize()/DrawProp[ActiveLayer].pFont->Width); + xsize = 0; #else xsize = (BSP_LCD_GetXSize()/DrawProp[ActiveLayer].pFont->Width); #endif @@ -937,10 +940,14 @@ height = pBmp[22] + (pBmp[23] << 8) + (pBmp[24] << 16) + (pBmp[25] << 24); /* Read bit/pixel */ - bitpixel = pBmp[28] + (pBmp[29] << 8); + bitpixel = pBmp[28] + (pBmp[29] << 8); /* Set Address */ - address = LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (FRAMEBUFFER_POS(X,Y)); + #ifdef LANDSCAPE_MODE + address = LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (FRAMEBUFFER_POS(X-height,Y)); + #else + address = LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + FRAMEBUFFER_POS(X,Y); + #endif /* Get the Layer pixel format */ if ((bitpixel/8) == 4) @@ -973,6 +980,81 @@ } } +void BSP_LCD_CopyLayer(uint16_t SourceLayer, uint16_t DestLayer, int16_t PixelShift) +{ + uint32_t src_address = LtdcHandler.LayerCfg[SourceLayer].FBStartAdress; + uint32_t dest_address = LtdcHandler.LayerCfg[DestLayer].FBStartAdress; + + if ((PixelShift == 0) && (SourceLayer == DestLayer)) + { + return; + } + Dma2dHandler.Init.Mode = DMA2D_M2M_PFC; + Dma2dHandler.Init.ColorMode = DMA2D_ARGB8888; + Dma2dHandler.Init.OutputOffset = 0; + + /* Foreground Configuration */ + Dma2dHandler.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA; + Dma2dHandler.LayerCfg[1].InputAlpha = 0xFF; + Dma2dHandler.LayerCfg[1].InputColorMode = CM_ARGB8888; + Dma2dHandler.LayerCfg[1].InputOffset = 0; + + Dma2dHandler.Instance = DMA2D; + + if (PixelShift<0) { + src_address += (BSP_LCD_GetXSize()*4)*abs(PixelShift); + } else { + dest_address += (BSP_LCD_GetXSize()*4)*PixelShift; + } + + /* DMA2D Initialization */ + if(HAL_DMA2D_Init(&Dma2dHandler) == HAL_OK) + { + if(HAL_DMA2D_ConfigLayer(&Dma2dHandler, 1) == HAL_OK) + { + if (HAL_DMA2D_Start(&Dma2dHandler, (uint32_t)src_address, (uint32_t)dest_address, BSP_LCD_GetXSize(), BSP_LCD_GetYSize()-PixelShift) == HAL_OK) + { + /* Polling For DMA transfer */ + HAL_DMA2D_PollForTransfer(&Dma2dHandler, 10); + } + } + } + /* + for (int i=0; i<BSP_LCD_GetYSize(); i++) { + if (i<abs(PixelShift)) { + if (PixelShift<0) { + src_address += (BSP_LCD_GetXSize()*4); + //BSP_LCD_ClearStringLine(i) + } else { + dest_address += (BSP_LCD_GetXSize()*4); + } + } else { + ConvertLineToARGB8888((uint32_t *)src_address, (uint32_t *)dest_address, BSP_LCD_GetXSize(), CM_ARGB8888); + src_address += (BSP_LCD_GetXSize()*4); + dest_address += (BSP_LCD_GetXSize()*4); + } + } + */ + +} + +void BSP_LCD_CopyLayerSdram(uint16_t SourceLayer, uint32_t SdramLayerAddress, uint16_t offset) +{ + uint32_t src_address = LtdcHandler.LayerCfg[SourceLayer].FBStartAdress + (BSP_LCD_GetXSize()*offset*4); + BSP_SDRAM_WriteData(SdramLayerAddress, (uint32_t*)src_address, + (BSP_LCD_GetXSize()*(BSP_LCD_GetYSize()-offset))*4); + +} + + +void BSP_LCD_CopySdramLayer(uint32_t SdramAddress, uint16_t DestLayer, uint16_t offset) +{ + uint32_t dst_address = LtdcHandler.LayerCfg[DestLayer].FBStartAdress; + BSP_SDRAM_ReadData(SdramAddress + (BSP_LCD_GetXSize()*offset*4), (uint32_t*)dst_address, + (BSP_LCD_GetXSize()*(BSP_LCD_GetYSize()-offset))*4); + +} + /** * @brief Displays a full rectangle. * @param Xpos: the X position
diff -r b7f549f2845c -r a76cfea518cc Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_lcd.h --- a/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_lcd.h Fri Mar 09 13:25:12 2018 +0000 +++ b/Drivers/BSP/STM32F429I-Discovery/stm32f429i_discovery_lcd.h Fri Mar 16 09:50:17 2018 +0000 @@ -38,6 +38,8 @@ #ifndef __STM32F429I_DISCOVERY_LCD_H #define __STM32F429I_DISCOVERY_LCD_H +#define LANDSCAPE_MODE + #ifdef __cplusplus extern "C" { #endif @@ -106,8 +108,13 @@ /** * @brief LCD status structure definition */ -#define MAX_LAYER_NUMBER 2 -#define LCD_FRAME_BUFFER ((uint32_t)0xD0000000) + +/* LCD buffer is on SDRAM */ +/* so for 320x240*4 bits per pixels 400ko per frame */ +/* with 8 MB you can do a lot more frame than 2 */ + +#define MAX_LAYER_NUMBER 5 +#define LCD_FRAME_BUFFER ((uint32_t)0xD0000000) /*this is SDRAM address */ #define BUFFER_OFFSET ((uint32_t)0x50000) /** @@ -200,7 +207,7 @@ void BSP_LCD_SelectLayer(uint32_t LayerIndex); void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState state); void BSP_LCD_SetLayerVisible_NoReload(uint32_t LayerIndex, FunctionalState State); -void BSP_LCD_Relaod(uint32_t ReloadType); +void BSP_LCD_Reload(uint32_t ReloadType); void BSP_LCD_SetTextColor(uint32_t Color); void BSP_LCD_SetBackColor(uint32_t Color); @@ -232,6 +239,7 @@ void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount); void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius); +void BSP_LCD_CopyLayer(uint16_t SourceLayer, uint16_t DestLayer, int16_t PixelShift); void BSP_LCD_DisplayOff(void); void BSP_LCD_DisplayOn(void); @@ -239,6 +247,9 @@ for specific application needs */ void BSP_LCD_MspInit(void); +void BSP_LCD_CopyLayerSdram(uint16_t SourceLayer, uint32_t SdramLayerAddress, uint16_t offset); +void BSP_LCD_CopySdramLayer(uint32_t SdramAddress, uint16_t DestLayer, uint16_t offset); + /** * @} */