/** * @brief Main program * @param None * @retval None */ int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup files (startup_stm32f429_439xx.s) before to branch to application main. */ /* Configure LCD : Configure 2 layers w/ Blending and CLUT loading for layer 1 */ LCD_Config(); /* Enable CLUT for Layer 1 */ LTDC_CLUTCmd(LTDC_Layer1, ENABLE); /* Enable Layer 1 */ LTDC_LayerCmd(LTDC_Layer1, ENABLE); /* Enable Layer 2 */ LTDC_LayerCmd(LTDC_Layer2, ENABLE); /* Reload LTDC configuration */ LTDC_ReloadConfig(LTDC_IMReload); /* Enable The LCD */ LTDC_Cmd(ENABLE); while (1) { } }
void MainTask_ColorKeying(void) { uint32_t lastMiliseconds = 0; LCD_Init(); SDRAM_Init(); while(!tamperPushed) { LCD_ReSetColorKeying(); LTDC_DitherCmd(ENABLE); DrawText((uint8_t*)" Color Keying OFF"); DMA2D_CopySTLogo(LOGO_OFFSET); LCD_BackgroundLayerInit(); /* wait 2s */ lastMiliseconds = getMiliseconds(); while (!tamperPushed && ((getMiliseconds()-lastMiliseconds)<2000)) { } LCD_SetColorKeying(0xFFFFFF); DrawText((uint8_t*)" Color Keying ON"); DMA2D_CopySTLogo(LOGO_OFFSET); /* wait 2s */ lastMiliseconds = getMiliseconds(); while (!tamperPushed && ((getMiliseconds()-lastMiliseconds)<2000)) { } LTDC_CLUTCmd(LTDC_Layer1, DISABLE); LTDC_CLUTCmd(LTDC_Layer2, DISABLE); LCD_ReSetColorKeying(); LTDC_ReloadConfig(LTDC_IMReload); } }
void MainTask_ColorFormat(void) { uint32_t lastMiliseconds = 0; LCD_Init(); SDRAM_Init(); /* LTDC configuration reload */ LTDC_ReloadConfig(LTDC_IMReload); while(!tamperPushed) { DMA2D_CopyPicture(DMA2D_RGB888); LTDC_DitherCmd(ENABLE); DrawText((uint8_t*)" RGB888 Dither"); LCD_RGB888LayerInit(); /* wait 2s */ lastMiliseconds = getMiliseconds(); while (!tamperPushed && ((getMiliseconds()-lastMiliseconds)<2000)) { } LTDC_DitherCmd(DISABLE); DrawText((uint8_t*)" RGB888"); LCD_RGB888LayerInit(); /* wait 2s */ lastMiliseconds = getMiliseconds(); while (!tamperPushed && ((getMiliseconds()-lastMiliseconds)<2000)) { } LTDC_DitherCmd(ENABLE); DMA2D_CopyPicture(DMA2D_RGB565); DrawText((uint8_t*)" RGB565"); LCD_RGB565LayerInit(); /* wait 2s */ lastMiliseconds = getMiliseconds(); while (!tamperPushed && ((getMiliseconds()-lastMiliseconds)<2000)) { } DrawText((uint8_t*)" L8 CLUT"); LCD_OptCLUTLayerInit(); /* wait 2s */ lastMiliseconds = getMiliseconds(); while (!tamperPushed && ((getMiliseconds()-lastMiliseconds)<2000)) { } DrawText((uint8_t*)" L8 CLUT Dither"); LCD_DithCLUTLayerInit(); /* wait 2s */ lastMiliseconds = getMiliseconds(); while (!tamperPushed && ((getMiliseconds()-lastMiliseconds)<2000)) { } LTDC_CLUTCmd(LTDC_Layer1, DISABLE); LTDC_CLUTCmd(LTDC_Layer2, DISABLE); LCD_ReSetColorKeying(); LTDC_ReloadConfig(LTDC_IMReload); } }
static void LCD_DithCLUTLayerInit(void) { uint32_t uwCounter; LTDC_CLUT_InitTypeDef LTDC_CLUT_InitStruct; LTDC_LayerCmd(LTDC_Layer1, DISABLE); /* Windowing configuration */ /* In this case all the active display area is used to display a picture then : Horizontal start = horizontal synchronization + Horizontal back porch = 30 Horizontal stop = Horizontal start + window width -1 = 30 + 240 -1 Vertical start = vertical synchronization + vertical back porch = 4 Vertical stop = Vertical start + window height -1 = 4 + 320 -1 */ LTDC_Layer_InitStruct.LTDC_HorizontalStart = 30; LTDC_Layer_InitStruct.LTDC_HorizontalStop = (LCD_PIXEL_WIDTH + 30 - 1); LTDC_Layer_InitStruct.LTDC_VerticalStart = 4; LTDC_Layer_InitStruct.LTDC_VerticalStop = (LCD_PIXEL_HEIGHT + 4 - 1); /* Pixel Format configuration*/ LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_L8; /* Alpha constant (255 totally opaque) */ LTDC_Layer_InitStruct.LTDC_ConstantAlpha = 255; /* Default Color configuration (configure A,R,G,B component values) */ LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = 0; LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = 0; LTDC_Layer_InitStruct.LTDC_DefaultColorRed = 0; LTDC_Layer_InitStruct.LTDC_DefaultColorAlpha = 0; /* Configure blending factors */ LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA; LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA; /* the length of one line of pixels in bytes + 3 then : Line Lenth = Active width x number of bytes per pixel + 3 Active width = LCD_PIXEL_WIDTH number of bytes per pixel = 1 (pixel_format : L8) */ LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD_PIXEL_WIDTH * 1) + 3); /* the pitch is the increment from the start of one line of pixels to the start of the next line in bytes, then : Pitch = Active high width x number of bytes per pixel */ LTDC_Layer_InitStruct.LTDC_CFBPitch = (ImageDithCLUT_width * 1); /* Configure the number of lines */ LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD_PIXEL_HEIGHT; /* Start Address configuration : the LCD Frame buffer is defined in Flash memory*/ LTDC_Layer_InitStruct.LTDC_CFBStartAdress = (uint32_t)ImageDithCLUT; /* Initialize LTDC layer 1 */ LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct); /* CLUT loading --------------------------------------------------------------*/ /* Load 256 colors in CLUT address for Layer 1 */ for(uwCounter = 0; (uwCounter < 256); uwCounter++) { LTDC_CLUT_InitStruct.LTDC_CLUTAdress = uwCounter; LTDC_CLUT_InitStruct.LTDC_BlueValue = (ImageDithCLUT_CLUT[uwCounter] & 0xFF); LTDC_CLUT_InitStruct.LTDC_GreenValue = (ImageDithCLUT_CLUT[uwCounter] & 0xFF00) >> 8; LTDC_CLUT_InitStruct.LTDC_RedValue = (ImageDithCLUT_CLUT[uwCounter] & 0xFF0000) >> 16; LTDC_CLUTInit(LTDC_Layer1, <DC_CLUT_InitStruct); } /* CLUT loading end ----------------------------------------------------------*/ /* Enable CLUT for Layer 1 */ LTDC_CLUTCmd(LTDC_Layer1, ENABLE); /* LTDC configuration reload */ LTDC_ReloadConfig(LTDC_SRCR_VBR); /* Enable backgrounf layers */ LTDC_LayerCmd(LTDC_Layer1, ENABLE); /* LTDC configuration reload */ LTDC_ReloadConfig(LTDC_SRCR_VBR); }