int main(void) { /* Initialize system */ SystemInit(); /* Initialize delay */ TM_DELAY_Init(); /* Initialize ILI9341 with LTDC */ /* By default layer 1 is used */ TM_ILI9341_Init(); /* Rotate LCD for 90 degrees */ TM_ILI9341_Rotate(TM_ILI9341_Orientation_Landscape_2); TM_ILI9341_SetLayer1(); /* Fill data on layer 1 */ TM_ILI9341_Fill(ILI9341_COLOR_WHITE); /* Show text */ TM_ILI9341_Puts(65, 30, "Layer 1", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_BLUE2); TM_ILI9341_Puts(20, 130, "STM32F429 Discovery ONLY!", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_BLUE2); TM_ILI9341_Puts(60, 150, "ILI9341 LCD Module", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_BLUE2); TM_ILI9341_Puts(70, 170, "with LTDC support", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_BLUE2); TM_ILI9341_Puts(170, 230, "stm32f4-discovery.com", &TM_Font_7x10, ILI9341_COLOR_BLACK, ILI9341_COLOR_ORANGE); /* Go to layer 2 */ TM_ILI9341_SetLayer2(); /* Fill data on layer 2 */ TM_ILI9341_Fill(ILI9341_COLOR_GREEN2); /* Show text */ TM_ILI9341_Puts(65, 30, "Layer 2", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_BLUE); TM_ILI9341_Puts(20, 130, "STM32F429 Discovery ONLY!", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_RED); TM_ILI9341_Puts(60, 150, "ILI9341 LCD Module", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_BLUE2); TM_ILI9341_Puts(70, 170, "with LTDC support", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_BLUE2); TM_ILI9341_Puts(170, 230, "stm32f4-discovery.com", &TM_Font_7x10, ILI9341_COLOR_BLACK, ILI9341_COLOR_ORANGE); /* Draw circle on layer 2 */ TM_ILI9341_DrawCircle(150, 150, 140, ILI9341_COLOR_BLACK); while (1) { /* This will set opacity of one layer to 0, other to max (255) each time */ /* This is like toggle function */ TM_ILI9341_ChangeLayers(); Delayms(500); /* //Bottom code works the same as one before inside while loop //Turn on Layer1 and turn off Layer2 TM_ILI9341_SetLayer1Opacity(255); TM_ILI9341_SetLayer2Opacity(0); Delayms(500); //Turn on Layer2 and turn off Layer1 TM_ILI9341_SetLayer1Opacity(0); TM_ILI9341_SetLayer2Opacity(255); Delayms(500); */ } }
void TM_ILI9341_ChangeLayers(void) { if (ILI9341_Opts.CurrentLayer == 0) { TM_ILI9341_SetLayer2(); TM_ILI9341_SetLayer1Opacity(0); TM_ILI9341_SetLayer2Opacity(255); } else { TM_ILI9341_SetLayer1(); TM_ILI9341_SetLayer1Opacity(255); TM_ILI9341_SetLayer2Opacity(0); } }
void TM_ILI9341_Init() { //Initialize pins used TM_ILI9341_InitPins(); //SPI chip select high ILI9341_CS_SET; //Init SPI TM_SPI_Init(ILI9341_SPI, ILI9341_SPI_PINS); //Init SDRAM TM_DISCO_LedInit(); if (!TM_SDRAM_Init()) { TM_DISCO_LedOn(LED_RED); } //Initialize LCD for LTDC TM_ILI9341_InitLCD(); //Initialize LTDC TM_LCD9341_InitLTDC(); //Initialize LTDC layers TM_ILI9341_InitLayers(); //Set cursor X and Y ILI9341_x = ILI9341_y = 0; ILI9341_Opts.Width = ILI9341_WIDTH; ILI9341_Opts.Height = ILI9341_HEIGHT; ILI9341_Opts.Orientation = TM_ILI9341_Portrait; ILI9341_Opts.Orient = TM_ILI9341_Orientation_Portrait_1; ILI9341_Opts.CurrentLayer = 0; ILI9341_Opts.CurrentLayerOffset = 0; ILI9341_Opts.Layer1Opacity = 255; ILI9341_Opts.Layer2Opacity = 0; TM_ILI9341_SetLayer1(); TM_ILI9341_Fill(ILI9341_COLOR_WHITE); TM_ILI9341_SetLayer2(); TM_ILI9341_Fill(ILI9341_COLOR_WHITE); TM_ILI9341_SetLayer1(); }