/* * Set transparency of layer * * @param[in] layer layer to change * @param[in] transparency 0x00 is transparent, 0xFF is opaque */ void lcd_set_transparency (lcd_layers_t layer, uint8_t transparency) { switch (layer) { case LCD_BACKGROUND: LTDC_LayerAlpha (LTDC_Layer1, transparency); break; case LCD_FOREGROUND: LTDC_LayerAlpha (LTDC_Layer2, transparency); break; default: break; } if (lcd_vsync) { lcd_refreshed = false; LTDC_ITConfig (LTDC_IT_RR, ENABLE); /* reload shadow register on next vertical blank */ LTDC_ReloadConfig (LTDC_VBReload); /* wait for registers to be reloaded */ while (!lcd_refreshed); } else { /* immediately reload shadow registers */ LTDC_ReloadConfig (LTDC_IMReload); } }
static void LCD_RGB565LayerInit(void) { 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_RGB565; /* 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_PAxCA; LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA; /* 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 = 2 (pixel_format : RGB565) */ LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD_PIXEL_WIDTH * 2) + 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 = (ImageRGB888_width * 2); /* 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)frameBuffer; //LTDC_Layer_InitStruct.LTDC_CFBStartAdress = (uint32_t)ImageRGB565; /* Initialize LTDC layer 1 */ LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct); /* LTDC configuration reload */ LTDC_ReloadConfig(LTDC_IMReload); /* Enable foreground Layers */ LTDC_LayerCmd(LTDC_Layer1, ENABLE); /* LTDC configuration reload */ LTDC_ReloadConfig(LTDC_IMReload); }
void r3dfb_init(void) { LCD_Init(); LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct; LTDC_Layer_InitStruct.LTDC_HorizontalStart = 30; LTDC_Layer_InitStruct.LTDC_HorizontalStop = (R3DFB_PIXEL_WIDTH + 30 - 1); LTDC_Layer_InitStruct.LTDC_VerticalStart = 4; LTDC_Layer_InitStruct.LTDC_VerticalStop = (R3DFB_PIXEL_HEIGHT + 4 - 1); LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565; LTDC_Layer_InitStruct.LTDC_ConstantAlpha = 255; LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = 0; LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = 0; LTDC_Layer_InitStruct.LTDC_DefaultColorRed = 0; LTDC_Layer_InitStruct.LTDC_DefaultColorAlpha = 0; LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA; LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA; LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((R3DFB_PIXEL_WIDTH * 2) + 3); LTDC_Layer_InitStruct.LTDC_CFBPitch = (R3DFB_PIXEL_WIDTH * 2); LTDC_Layer_InitStruct.LTDC_CFBLineNumber = R3DFB_PIXEL_HEIGHT; LTDC_Layer_InitStruct.LTDC_CFBStartAdress = r3dfb_front_buffer; LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct); LTDC_LayerCmd(LTDC_Layer1, ENABLE); LTDC_LayerCmd(LTDC_Layer2, DISABLE); LTDC_ReloadConfig(LTDC_IMReload); LTDC_Cmd(ENABLE); }
/** * @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) { } }
int main(void) { LCD_Init(); LCD_LayerInit(); /* LTDC reload configuration */ LTDC_ReloadConfig(LTDC_IMReload); /* Enable the LTDC */ LTDC_Cmd(ENABLE); /* Set LCD foreground layer */ LCD_SetLayer(LCD_FOREGROUND_LAYER); LCD_SetTransparency(0); /* Set LCD background layer */ LCD_SetLayer(LCD_BACKGROUND_LAYER); /* LCD display message */ LCD_Clear(LCD_COLOR_RED); LCD_SetTextColor(LCD_COLOR_BLACK); LCD_DisplayStringLine(LCD_LINE_2,(uint8_t*)" YOU'LL "); LCD_DisplayStringLine(LCD_LINE_4,(uint8_t*)" NEVER "); LCD_DisplayStringLine(LCD_LINE_6,(uint8_t*)" TAKE "); LCD_DisplayStringLine(LCD_LINE_8,(uint8_t*)" ME "); LCD_DisplayStringLine(LCD_LINE_10,(uint8_t*)" ALIVE "); while(1) { } }
void LCDinit(){ LCD_Init(); LCD_LayerInit(); LCD_SetLayer(LCD_BACKGROUND_LAYER); LCD_SetTransparency(0); LCD_SetLayer(LCD_FOREGROUND_LAYER); LTDC_ReloadConfig(LTDC_IMReload); LTDC_Cmd(ENABLE); LCD_Clear(LCD_COLOR_BLACK); }
/* * initialize both layers to full screen */ static void lcd_layer_fullscreen (void) { LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct; // background layer LTDC_Layer_InitStruct.LTDC_HorizontalStart = 30; LTDC_Layer_InitStruct.LTDC_HorizontalStop = LCD_MAX_X + 30 - 1; LTDC_Layer_InitStruct.LTDC_VerticalStart = 4; LTDC_Layer_InitStruct.LTDC_VerticalStop = LCD_MAX_Y + 4 - 1; LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565; LTDC_Layer_InitStruct.LTDC_ConstantAlpha = 0xFF; // opaque LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = 0; LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = 0; LTDC_Layer_InitStruct.LTDC_DefaultColorRed = 0; LTDC_Layer_InitStruct.LTDC_DefaultColorAlpha = 0; LTDC_Layer_InitStruct.LTDC_CFBLineLength = (LCD_MAX_X * 2) + 3; LTDC_Layer_InitStruct.LTDC_CFBPitch = LCD_MAX_X * 2; LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD_MAX_Y; LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER; LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA; LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA; LTDC_LayerInit (LTDC_Layer1, <DC_Layer_InitStruct); // foreground layer LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER + LCD_FRAME_SIZE; LTDC_LayerInit (LTDC_Layer2, <DC_Layer_InitStruct); LTDC_ReloadConfig (LTDC_IMReload); LTDC_LayerCmd (LTDC_Layer1, ENABLE); LTDC_LayerCmd (LTDC_Layer2, ENABLE); LTDC_ReloadConfig (LTDC_IMReload); LTDC_DitherCmd (DISABLE); LTDC_Cmd (ENABLE); }
void LCDTFTConf::LCD_SetTransparency(uint8_t transparency) { if (CurrentLayer == LCD_BACKGROUND_LAYER) { LTDC_LayerAlpha(LTDC_Layer1, transparency); } else { LTDC_LayerAlpha(LTDC_Layer2, transparency); } LTDC_ReloadConfig(LTDC_IMReload); }
/*===========================================================================*/ static inline void init_board(GDisplay *g) { g->board = 0; /* Init LCD and LTCD. Enable layer1 only. */ LCD_Init(); LCD_LayerInit(); LTDC_LayerCmd(LTDC_Layer1, ENABLE); LTDC_LayerCmd(LTDC_Layer2, DISABLE); LTDC_ReloadConfig(LTDC_IMReload); LTDC_Cmd(ENABLE); LCD_SetLayer(LCD_BACKGROUND_LAYER); }
void ui_swap_layer() { LTDC_LayerAlpha(layer_buffers[hidden_layer].LTDC_Layer, 0xff); LTDC_LayerAlpha(layer_buffers[show_layer].LTDC_Layer, 0x00); LCD_SetLayer(layer_buffers[show_layer].LCD_Layer); LTDC_ReloadConfig(LTDC_IMReload); LCD_Clear(LCD_COLOR_WHITE); show_layer = !show_layer; hidden_layer = !hidden_layer; }
void r3dfb_swap_buffers(void) { uint32_t tmp = r3dfb_front_buffer; r3dfb_front_buffer = r3dfb_back_buffer; r3dfb_back_buffer = tmp; // hack for font rendering LCD_SetLayer(r3dfb_back_buffer == R3DFB_BUFFER0 ? LCD_BACKGROUND_LAYER : LCD_FOREGROUND_LAYER); LTDC_Cmd(DISABLE); LTDC_LayerAddress(LTDC_Layer1, r3dfb_front_buffer); LTDC_ReloadConfig(LTDC_IMReload); LTDC_Cmd(ENABLE); }
/** * @brief USBH_USR_Init * Displays the message on LCD for host lib initialization * @param None * @retval None */ void USBH_USR_Init(void) { static uint8_t startup = 0; if(startup == 0 ) { startup = 1; /* Configure the LEDs */ STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO); /* Initialize the LCD */ LCD_Init(); LCD_LayerInit(); /* Set LCD background layer */ LCD_SetLayer(LCD_BACKGROUND_LAYER); /* Set LCD transparency */ LCD_SetTransparency(0); /* Set LCD foreground layer */ LCD_SetLayer(LCD_FOREGROUND_LAYER); /* LTDC reload configuration */ LTDC_ReloadConfig(LTDC_IMReload); /* Enable the LTDC */ LTDC_Cmd(ENABLE); /* LCD Log initialization */ LCD_LOG_Init(); #ifdef USE_USB_OTG_HS LCD_LOG_SetHeader("PDF Create"); #else LCD_LOG_SetHeader(" USB OTG FS MSC Host"); #endif LCD_UsrLog("> USB Host library started.\n"); LCD_LOG_SetFooter (" USB Host Library v2.1.0" ); } }
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); } }
/** * @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 : Only one layer is used */ LCD_Config(); /* Enable Layer 1 */ LTDC_LayerCmd(LTDC_Layer1, ENABLE); /* Reload configuration of Layer 1 */ LTDC_ReloadConfig(LTDC_IMReload); /* Enable The LCD */ LTDC_Cmd(ENABLE); while (1) { } }
/** * @brief USBH_USR_MSC_Application * Demo application for mass storage * @param None * @retval Staus */ int USBH_USR_MSC_Application(void) { FRESULT res; uint8_t writeTextBuff[] = "BIG_MANTA FS/HS STM32 Connectivity line Host Demo application using FAT_FS "; uint16_t bytesWritten, bytesToWrite; /* Set LCD Layer size and pixel format */ LTDC_LayerPixelFormat(LTDC_Layer2, LTDC_Pixelformat_RGB565); LTDC_LayerSize(LTDC_Layer2, 240, 320); /* LTDC reload configuration */ LTDC_ReloadConfig(LTDC_IMReload); switch(USBH_USR_ApplicationState) { case USH_USR_FS_INIT: /* Initialises the File System*/ if ( f_mount( 0, &fatfs ) != FR_OK ) { /* efs initialisation fails*/ LCD_ErrLog("> Cannot initialize File System.\n"); return(-1); } LCD_UsrLog("> File System initialized.\n"); LCD_UsrLog("> Disk capacity : %d Bytes\n", USBH_MSC_Param.MSCapacity * \ USBH_MSC_Param.MSPageLength); if(USBH_MSC_Param.MSWriteProtect == DISK_WRITE_PROTECTED) { LCD_ErrLog((void *)MSG_WR_PROTECT); } USBH_USR_ApplicationState = USH_USR_FS_READLIST; break; case USH_USR_FS_READLIST: LCD_UsrLog((void *)MSG_ROOT_CONT); Explore_Disk("0:/", 1); line_idx = 0; USBH_USR_ApplicationState = USH_USR_FS_WRITEFILE; break; case USH_USR_FS_WRITEFILE: /*Key B3 in polling*/ while((HCD_IsDeviceConnected(&USB_OTG_Core)) && \ (STM_EVAL_PBGetState (BUTTON_USER) != RESET)) { Toggle_Leds(); } /* Writes a text file, STM32.TXT in the disk*/ LCD_UsrLog("> Writing File to disk flash ...\n"); if(USBH_MSC_Param.MSWriteProtect == DISK_WRITE_PROTECTED) { LCD_ErrLog ( "> Disk flash is write protected \n"); USBH_USR_ApplicationState = USH_USR_FS_DRAW; break; } /* Register work area for logical drives */ f_mount(0, &fatfs); if(f_open(&file, "0:STM32.TXT",FA_CREATE_ALWAYS | FA_WRITE) == FR_OK) { /* Write buffer to file */ bytesToWrite = sizeof(writeTextBuff); res= f_write (&file, writeTextBuff, bytesToWrite, (void *)&bytesWritten); if((bytesWritten == 0) || (res != FR_OK)) /*EOF or Error*/ { LCD_ErrLog("> STM32.TXT CANNOT be writen.\n"); } else { LCD_UsrLog("> 'STM32.TXT' file created\n"); } /*close file and filesystem*/ f_close(&file); f_mount(0, NULL); } else { LCD_UsrLog ("> STM32.TXT created in the disk\n"); } USBH_USR_ApplicationState = USH_USR_FS_PDFCREATE; LCD_SetTextColor(Green); LCD_DisplayStringLine(LCD_LINE_15,"To start PDF file Create "); LCD_DisplayStringLine(LCD_LINE_16,"Press Key "); LCD_SetTextColor(LCD_LOG_DEFAULT_COLOR); while(STM_EVAL_PBGetState (BUTTON_USER) != SET) { Toggle_Leds(); } break; case USH_USR_FS_DRAW: /*Key B3 in polling*/ while((HCD_IsDeviceConnected(&USB_OTG_Core)) && \ (STM_EVAL_PBGetState (BUTTON_USER) != RESET)) { Toggle_Leds(); } while(HCD_IsDeviceConnected(&USB_OTG_Core)) { if ( f_mount( 0, &fatfs ) != FR_OK ) { /* fat_fs initialisation fails*/ return(-1); } return Image_Browser("0:/"); } break; case USH_USR_FS_PDFCREATE: PdfCreate(); return(1); // break; default: break; } return(0); }
static void TM_LCD_INT_InitLayers(void) { LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct; /* Windowing configuration */ /* Horizontal start = horizontal synchronization + Horizontal back porch = 43 Vertical start = vertical synchronization + vertical back porch = 12 Horizontal stop = Horizontal start + LCD_PIXEL_WIDTH -1 Vertical stop = Vertical start + LCD_PIXEL_HEIGHT -1 */ LTDC_Layer_InitStruct.LTDC_HorizontalStart = 144; LTDC_Layer_InitStruct.LTDC_HorizontalStop = (LCD.Width + 144 - 1); LTDC_Layer_InitStruct.LTDC_VerticalStart = 35; LTDC_Layer_InitStruct.LTDC_VerticalStop = (LCD.Height + 35 - 1); /* Pixel Format configuration*/ LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565; /* 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 high width x number of bytes per pixel + 3 Active high width = LCD_PIXEL_WIDTH number of bytes per pixel = 2 (pixel_format : RGB565) */ LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD.Width * 2) + 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 = (LCD.Width * 2); /* Configure the number of lines */ LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD.Height; /* Start Address configuration : the LCD Frame buffer is defined on SDRAM */ LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD.FrameStart; LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct); /* Configure Layer2 */ /* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */ LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD.FrameStart + LCD.FrameOffset; /* Configure blending factors */ LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA; LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA; LTDC_LayerInit(LTDC_Layer2, <DC_Layer_InitStruct); LTDC_ReloadConfig(LTDC_IMReload); /* Enable foreground & background Layers */ LTDC_LayerCmd(LTDC_Layer1, ENABLE); LTDC_LayerCmd(LTDC_Layer2, ENABLE); LTDC_ReloadConfig(LTDC_IMReload); /* Enable dithering */ LTDC_DitherCmd(ENABLE); /* Set opacity */ LTDC_LayerAlpha(LTDC_Layer1, 255); LTDC_LayerAlpha(LTDC_Layer2, 0); /* Immediate reload */ LTDC_ReloadConfig(LTDC_IMReload); }
static void DrawText(uint8_t* text) { /* 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 + 10; LTDC_Layer_InitStruct.LTDC_VerticalStop = (ImageSTLogo_height + 4 + 10 + LOGO_OFFSET_LINES - 1); /* Pixel Format configuration*/ LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565; /* 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; /* 0 = transparent */ /* the length of one line of pixels in bytes + 3 then : Line Lenth = Active high width x number of bytes per pixel + 3 Active high width = LCD_PIXEL_WIDTH number of bytes per pixel = 2 (pixel_format : RGB565) */ LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD_PIXEL_WIDTH * 2) + 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 = (LCD_PIXEL_WIDTH * 2); /* Configure the number of lines */ LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD_PIXEL_HEIGHT; /* Configure Layer2 */ /* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */ LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER + BUFFER_OFFSET; /* Configure blending factors */ LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA; LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA; /* Initialize LTDC layer 2 */ LTDC_LayerInit(LTDC_Layer2, <DC_Layer_InitStruct); /* LTDC configuration reload */ LTDC_ReloadConfig(LTDC_IMReload); /* Enable foreground & background Layers */ LTDC_LayerCmd(LTDC_Layer2, ENABLE); /* Set default font */ LCD_SetFont(&LCD_DEFAULT_FONT); /* Set LCD foreground layer */ LCD_SetLayer(LCD_FOREGROUND_LAYER); /* LCD display message */ LCD_Clear(LCD_COLOR_WHITE); LCD_SetFont(&Font12x12); LCD_SetTextColor(LCD_COLOR_RED); LCD_SetBackColor(LCD_COLOR_WHITE); LCD_DisplayStringLine(LCD_LINE_1,(uint8_t*)text); }
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); }
/* ****************************************************************************** *函数:void LCD_GPIOInit(void) *输入:void *输出:void *描述:LCD初始化 ****************************************************************************** */ void LCD_Init(void) { LTDC_InitTypeDef LTDC_InitStruct; LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct; LTDC_Layer_TypeDef LTDC_Layerx; /* IO口初始化 */ LCD_GPIOInit(); LCD_DisplayOff(); /* 使能LCD时钟 */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE); /* 使能DMA失踪*/ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE); /* 水平同步信号---低电平有效 */ LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL; /* 垂直同步信号---低电平有效 */ LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL; /* 数据使能信号---低电平有效 */ LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL; /* 像素时钟配置--- */ LTDC_InitStruct.LTDC_PCPolarity = LTDC_DEPolarity_AL; /* LCD背光设置 */ LTDC_InitStruct.LTDC_BackgroundRedValue = 0; LTDC_InitStruct.LTDC_BackgroundGreenValue = 0; LTDC_InitStruct.LTDC_BackgroundBlueValue = 0; /* **************************************************************************** *PLLSAI_VCO = HSE*PLLSAI_N / PLL_M = 8 * 192 / 8 = 192MHz *PLLLCDCLK = PLLSAI_VCO / PLLSAI_R = 192 / 3 = 64 Mhz *LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 64 / 8 = 8 Mhz **************************************************************************** */ RCC_PLLSAIConfig(192, 7, 3); RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div4); /* 使能PLLSAI时钟 */ RCC_PLLSAICmd(ENABLE); /* 等待PLLSAI时钟 */ while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET){} /* */ LTDC_InitStruct.LTDC_HorizontalSync = 40; /* */ LTDC_InitStruct.LTDC_VerticalSync = 9; /* */ LTDC_InitStruct.LTDC_AccumulatedHBP = 42; /* */ LTDC_InitStruct.LTDC_AccumulatedVBP = 11; /* */ LTDC_InitStruct.LTDC_AccumulatedActiveW = 522; /* */ LTDC_InitStruct.LTDC_AccumulatedActiveH = 283; /* */ LTDC_InitStruct.LTDC_TotalWidth = 524; /* */ LTDC_InitStruct.LTDC_TotalHeigh = 285; LTDC_Init(<DC_InitStruct); LTDC_Layer_InitStruct.LTDC_HorizontalStart = 43; LTDC_Layer_InitStruct.LTDC_HorizontalStop = (480 + 43 - 1); LTDC_Layer_InitStruct.LTDC_VarticalStart = 12; LTDC_Layer_InitStruct.LTDC_VerticalStop = (272 + 12 - 1); /* Pixel Format configuration*/ LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565; /* 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 high width x number of bytes per pixel + 3 Active high width = LCD_PIXEL_WIDTH number of bytes per pixel = 2 (pixel_format : RGB565) */ LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((480 * 2) + 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 = (480 * 2); /* configure the number of lines */ LTDC_Layer_InitStruct.LTDC_CFBLineNumber = 272; /* Input Address configuration */ LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER; LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct); /* Configure Layer2 */ LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER + BUFFER_OFFSET; LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA; LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA; LTDC_LayerInit(LTDC_Layer2, <DC_Layer_InitStruct); LTDC_ReloadConfig(LTDC_IMReload); /* Enable foreground & background Layers */ LTDC_LayerCmd(LTDC_Layer1, ENABLE); // LTDC_LayerCmd(LTDC_Layer2, ENABLE); LTDC_ReloadConfig(LTDC_IMReload); LCD_DisplayOn(); }
/** * @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 file (startup_stm32f429_439xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ /* User button will be used */ STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO); /* LCD Configuration */ LCD_Config(); /* Enable Layer1 */ LTDC_LayerCmd(LTDC_Layer1, ENABLE); /* Reload configuration of Layer1 */ LTDC_ReloadConfig(LTDC_IMReload); /* Enable The LCD */ LTDC_Cmd(ENABLE); while (1) { /* Wait for User push-button is pressed */ while (STM_EVAL_PBGetState(BUTTON_USER) != Bit_RESET) { } /* Wait for User push-button is released */ while (STM_EVAL_PBGetState(BUTTON_USER) != Bit_SET) { } if(ubPressedButton == PRESSED_1) { /* Set Color Keying to red (RGB = 0xFF0000) */ LCD_SetColorKeying(0xFF0000); ubPressedButton = PRESSED_2; } else if(ubPressedButton == PRESSED_2) { /* Set Color Keying to blue (RGB = 0x0000FF) */ LCD_SetColorKeying(0xFF); ubPressedButton = PRESSED_3; } else if(ubPressedButton == PRESSED_3) { /* Set Color Keying to green (RGB = 0x00FF00) */ LCD_SetColorKeying(0xFF00); ubPressedButton = PRESSED_4; } else if(ubPressedButton == PRESSED_4) { /* Set Color Keying to blue and green (RGB = 0x00FFFF) */ LCD_SetColorKeying(0xFFFF); ubPressedButton = PRESSED_5; } else if(ubPressedButton == PRESSED_5) { /* Set Color Keying to red and green (RGB = 0x00FFFF) */ LCD_SetColorKeying(0xFFFF00); ubPressedButton = PRESSED_6; } else { /* Set Color Keying to blue and red (RGB = 0x00FFFF) */ LCD_SetColorKeying(0xFF00FF); ubPressedButton = PRESSED_1; } } }
LCDTFTConf::LCDTFTConf() { CurrentFrameBuffer = LCD_FRAME_BUFFER; CurrentLayer = LCD_BACKGROUND_LAYER; LTDC_InitTypeDef LTDC_InitStruct; /* Configure the LCD Control pins ------------------------------------------*/ LCD_CtrlLinesConfig(); LCD_ChipSelect(DISABLE); LCD_ChipSelect(ENABLE); /* Configure the LCD_SPI interface -----------------------------------------*/ LCD_SPIConfig(); /* Power on the LCD --------------------------------------------------------*/ LCD_PowerOn(); /* Enable the LTDC Clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE); /* Enable the DMA2D Clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE); /* Configure the LCD Control pins */ LCD_AF_GPIOConfig(); /* Configure the FMC Parallel interface : SDRAM is used as Frame Buffer for LCD */ SDRAM_Init(); /* LTDC Configuration *********************************************************/ /* Polarity configuration */ /* Initialize the horizontal synchronization polarity as active low */ LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL; /* Initialize the vertical synchronization polarity as active low */ LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL; /* Initialize the data enable polarity as active low */ LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL; /* Initialize the pixel clock polarity as input pixel clock */ LTDC_InitStruct.LTDC_PCPolarity = LTDC_PCPolarity_IPC; /* Configure R,G,B component values for LCD background color */ LTDC_InitStruct.LTDC_BackgroundRedValue = 0; LTDC_InitStruct.LTDC_BackgroundGreenValue = 0; LTDC_InitStruct.LTDC_BackgroundBlueValue = 0; /* Configure PLLSAI prescalers for LCD */ /* Enable Pixel Clock */ /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAI_N = 192 Mhz */ /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAI_R = 192/4 = 48 Mhz */ /* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 48/8 = 6 Mhz */ RCC_PLLSAIConfig(192, 7, 4); RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div8); /* Enable PLLSAI Clock */ RCC_PLLSAICmd(ENABLE); /* Wait for PLLSAI activation */ while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET); /* Timing configuration */ /* Configure horizontal synchronization width */ LTDC_InitStruct.LTDC_HorizontalSync = 9; /* Configure vertical synchronization height */ LTDC_InitStruct.LTDC_VerticalSync = 1; /* Configure accumulated horizontal back porch */ LTDC_InitStruct.LTDC_AccumulatedHBP = 29; /* Configure accumulated vertical back porch */ LTDC_InitStruct.LTDC_AccumulatedVBP = 3; /* Configure accumulated active width */ LTDC_InitStruct.LTDC_AccumulatedActiveW = 269; /* Configure accumulated active height */ LTDC_InitStruct.LTDC_AccumulatedActiveH = 323; /* Configure total width */ LTDC_InitStruct.LTDC_TotalWidth = 279; /* Configure total height */ LTDC_InitStruct.LTDC_TotalHeigh = 327; LTDC_Init(<DC_InitStruct); LCD_LayerInit(); /* LTDC reload configuration */ LTDC_ReloadConfig(LTDC_IMReload); /* Enable the LTDC */ LTDC_Cmd(ENABLE); }
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); } }
/** * @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 file (startup_stm32f429_439xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ /* LCD initiatization */ LCD_Init(); LCD_LayerInit(); /* LTDC reload configuration */ LTDC_ReloadConfig(LTDC_IMReload); /* Enable the LTDC */ LTDC_Cmd(ENABLE); /* Set LCD foreground layer */ LCD_SetLayer(LCD_FOREGROUND_LAYER); /* Initialize LEDs mounted on STM32F429I-DISCO */ STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); /* Initialize User Button mounted on STM32F429I-DISCO */ STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO); /* Display tset name on LCD */ LCD_Clear(LCD_COLOR_WHITE); LCD_SetBackColor(LCD_COLOR_BLUE); LCD_SetTextColor(LCD_COLOR_WHITE); LCD_DisplayStringLine(LCD_LINE_4,(uint8_t*)" Flash Write "); LCD_DisplayStringLine(LCD_LINE_5,(uint8_t*)"protection test"); LCD_DisplayStringLine(LCD_LINE_7,(uint8_t*)" Press User "); LCD_DisplayStringLine(LCD_LINE_8,(uint8_t*)" push-button "); while (1) { /* Wait for User push-button is pressed */ while (STM_EVAL_PBGetState(BUTTON_USER) != Bit_RESET) { } /* Wait for User push-button is released */ while (STM_EVAL_PBGetState(BUTTON_USER) != Bit_SET) { } /* Get FLASH_WRP_SECTORS write protection status */ SectorsWRPStatus = FLASH_OB_GetWRP() & FLASH_WRP_SECTORS; if (SectorsWRPStatus == 0x00) { /* If FLASH_WRP_SECTORS are write protected, disable the write protection */ /* Enable the Flash option control register access */ FLASH_OB_Unlock(); /* Disable FLASH_WRP_SECTORS write protection */ FLASH_OB_WRPConfig(FLASH_WRP_SECTORS, DISABLE); /* Start the Option Bytes programming process */ if (FLASH_OB_Launch() != FLASH_COMPLETE) { /* User can add here some code to deal with this error */ while (1) { } } /* Disable the Flash option control register access (recommended to protect the option Bytes against possible unwanted operations) */ FLASH_OB_Lock(); /* Get FLASH_WRP_SECTORS write protection status */ SectorsWRPStatus = FLASH_OB_GetWRP() & FLASH_WRP_SECTORS; /* Check if FLASH_WRP_SECTORS write protection is disabled */ if (SectorsWRPStatus == FLASH_WRP_SECTORS) { LCD_Clear(LCD_COLOR_GREEN); LCD_SetTextColor(LCD_COLOR_BLACK); LCD_DisplayStringLine(LCD_LINE_5,(uint8_t*)" Write "); LCD_DisplayStringLine(LCD_LINE_6,(uint8_t*)" protection is "); LCD_DisplayStringLine(LCD_LINE_7,(uint8_t*)" disabled "); } else { LCD_Clear(LCD_COLOR_RED); LCD_SetTextColor(LCD_COLOR_BLACK); LCD_DisplayStringLine(LCD_LINE_5,(uint8_t*)" Write "); LCD_DisplayStringLine(LCD_LINE_6,(uint8_t*)" protection is "); LCD_DisplayStringLine(LCD_LINE_7,(uint8_t*)" not disabled "); } } else { /* If FLASH_WRP_SECTORS are not write protected, enable the write protection */ /* Enable the Flash option control register access */ FLASH_OB_Unlock(); /* Enable FLASH_WRP_SECTORS write protection */ FLASH_OB_WRPConfig(FLASH_WRP_SECTORS, ENABLE); /* Start the Option Bytes programming process */ if (FLASH_OB_Launch() != FLASH_COMPLETE) { /* User can add here some code to deal with this error */ while (1) { } } /* Disable the Flash option control register access (recommended to protect the option Bytes against possible unwanted operations) */ FLASH_OB_Lock(); /* Get FLASH_WRP_SECTORS write protection status */ SectorsWRPStatus = FLASH_OB_GetWRP() & FLASH_WRP_SECTORS; /* Check if FLASH_WRP_SECTORS are write protected */ if (SectorsWRPStatus == 0x00) { LCD_Clear(LCD_COLOR_GREEN); LCD_SetTextColor(LCD_COLOR_BLACK); LCD_DisplayStringLine(LCD_LINE_5,(uint8_t*)" Write "); LCD_DisplayStringLine(LCD_LINE_6,(uint8_t*)" protection is "); LCD_DisplayStringLine(LCD_LINE_7,(uint8_t*)" enabled "); } else { LCD_Clear(LCD_COLOR_RED); LCD_SetTextColor(LCD_COLOR_BLACK); LCD_DisplayStringLine(LCD_LINE_5,(uint8_t*)" Write "); LCD_DisplayStringLine(LCD_LINE_6,(uint8_t*)" protection is "); LCD_DisplayStringLine(LCD_LINE_7,(uint8_t*)" not enabled "); } } } }
void TM_ILI9341_UpdateLayerOpacity(void) { LTDC_LayerAlpha(LTDC_Layer1, ILI9341_Opts.Layer1Opacity); LTDC_LayerAlpha(LTDC_Layer2, ILI9341_Opts.Layer2Opacity); LTDC_ReloadConfig(LTDC_IMReload); }
void TM_ILI9341_InitLayers(void) { LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct; /* Windowing configuration */ /* Horizontal start = horizontal synchronization + Horizontal back porch = 43 Vertical start = vertical synchronization + vertical back porch = 12 Horizontal stop = Horizontal start + LCD_PIXEL_WIDTH - 1 Vertical stop = Vertical start + LCD_PIXEL_HEIGHT - 1 */ LTDC_Layer_InitStruct.LTDC_HorizontalStart = 30; LTDC_Layer_InitStruct.LTDC_HorizontalStop = 269; LTDC_Layer_InitStruct.LTDC_VerticalStart = 4; LTDC_Layer_InitStruct.LTDC_VerticalStop = 323; /* Pixel Format configuration*/ LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565; /* 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 high width x number of bytes per pixel + 3 Active high width = LCD_PIXEL_WIDTH number of bytes per pixel = 2 (pixel_format : RGB565) */ LTDC_Layer_InitStruct.LTDC_CFBLineLength = 240 * 2 + 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 = 240 * 2; /* Configure the number of lines */ LTDC_Layer_InitStruct.LTDC_CFBLineNumber = 320; /* Start Address configuration : the LCD Frame buffer is defined on SDRAM */ LTDC_Layer_InitStruct.LTDC_CFBStartAdress = ILI9341_FRAME_BUFFER; /* Initialize Layer 1 */ LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct); /* Configure Layer2 */ /* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */ LTDC_Layer_InitStruct.LTDC_CFBStartAdress = ILI9341_FRAME_BUFFER + ILI9341_FRAME_OFFSET; /* Configure blending factors */ LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA; LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA; /* Initialize Layer 2 */ LTDC_LayerInit(LTDC_Layer2, <DC_Layer_InitStruct); LTDC_ReloadConfig(LTDC_IMReload); /* Enable foreground & background Layers */ LTDC_LayerCmd(LTDC_Layer1, ENABLE); LTDC_LayerCmd(LTDC_Layer2, ENABLE); LTDC_ReloadConfig(LTDC_IMReload); LTDC_DitherCmd(ENABLE); /* Display On */ LTDC_Cmd(ENABLE); LTDC_LayerAlpha(LTDC_Layer1, 255); LTDC_LayerAlpha(LTDC_Layer2, 0); LTDC_ReloadConfig(LTDC_IMReload); }
void GAME_Render() { LCD_SetTextColor( LCD_COLOR_WHITE ); draw_me(me1[0]); draw_boss(boss1[0]); LCD_SetTextColor( LCD_COLOR_RED ); draw_bossbullet(boss_bullet[0]); draw_gun(boss1[0]); LCD_SetTextColor( LCD_COLOR_BLUE ); draw_mybullet(my_bullet[0]); LTDC_LayerAlpha(LTDC_Layer1, SHOW); LTDC_LayerAlpha(LTDC_Layer2, HIDE); LTDC_ReloadConfig(LTDC_VBReload); vTaskDelay( 2.5 ); LCD_SetLayer(LCD_BACKGROUND_LAYER); LCD_SetTextColor( LCD_COLOR_BLACK ); draw_me(me1[1]); draw_boss(boss1[1]); draw_gun(boss1[1]); draw_mybullet(my_bullet[1]); draw_bossbullet(boss_bullet[1]); LCD_SetTextColor( LCD_COLOR_WHITE ); draw_me(me1[0]); draw_boss(boss1[0]); LCD_SetTextColor( LCD_COLOR_RED ); draw_bossbullet(boss_bullet[0]); draw_gun(boss1[0]); LCD_SetTextColor( LCD_COLOR_BLUE ); draw_mybullet(my_bullet[0]); LTDC_LayerAlpha(LTDC_Layer2, SHOW); LTDC_LayerAlpha(LTDC_Layer1, HIDE); LTDC_ReloadConfig(LTDC_VBReload); vTaskDelay( 2.5 ); LCD_SetLayer(LCD_FOREGROUND_LAYER); LCD_SetTextColor( LCD_COLOR_BLACK ); draw_me(me1[0]); draw_boss(boss1[0]); draw_gun(boss1[0]); draw_mybullet(my_bullet[0]); draw_bossbullet(boss_bullet[0]); boss_bullet[1]=boss_bullet[0]; my_bullet[1]=my_bullet[0]; me1[1]=me1[0]; boss1[1]=boss1[0]; }