Library 18- ILI9341 with LTDC on STM32F429 Discovery
It’s been a while when I first got ILI9341 lcd working on discovery, but without LTDC driver. Yesterday I decided to make a new library. With LTDC, you can actually display movies, because it uses parallel communication and support 2 layers simultaneously what gives you a high refresh rate.
I used my old ILI9341 library and just add/modify some things to get LTDC to work.
LTDC also supports 2 layers, so this means that while one layer is displayed, other layer can be filled with data.
Note: This library only works on STM32F429 Discovery, it’s not for STM32F4 Discovery.
ILI9341 | DISCOVERY | DESCRIPTION |
---|---|---|
B5 | PA3 | Blue 5 |
VSYNC | PA4 | VYSNC |
G2 | PA6 | Green 2 |
R4 | PA11 | Red 4 |
R5 | PA12 | Red 5 |
R3 | PB0 | Red 3 |
R6 | PB1 | Red 6 |
B6 | PB8 | Blue 6 |
B7 | PB9 | Blue 7 |
G4 | PB10 | Green 4 |
G5 | PB11 | Green 5 |
HSYNC | PC6 | HSYNC |
G6 | PC7 | Green 6 |
R2 | PC10 | Red 2 |
G7 | PD3 | Green 7 |
B2 | PD6 | Blue 2 |
E | PF10 | Enable |
R7 | PG6 | Red 7 |
DOTCLK | PG7 | Dot clock |
G3 | PG10 | Green 3 |
B3 | PG11 | Blue 3 |
B4 | PG12 | Blue 4 |
MOSI | PF9 | SPI5 MOSI pin |
MISO | PF8 | SPI5 MISO pin |
SCK | PF7 | SPI5 SCK pin |
CS | PC2 | CS pin for SPI5 |
RESET | Reset pin | |
WRX | PD13 | Data/Command selection |
Library
Features
- Supports LTDC peripheral on STM32F429 Discovery
- Supports fonts
- Uses SDRAM on STM32F429 Discovery board
- Rotation to all 4 directions
- 2 layers support
- Supported layer opacity
- High speed refresh rate
- Graphic support
- Support for LCD display on or off
Dependencies
- STM32F4xx
- STM32F4xx RCC
- STM32F4xx DMA2D
- STM32F4xx GPIO
- STM32F4xx FMC
- STM32F4xx LTDC
- STM32F4xx SPI
- TM
- TM DMA2D
- TM SPI
- TM FONTS
- TM SDRAM
- TM GPIO
- defines.h
- TM DMA2D
Functions
There are some modifications to functions. Other functions are the same as if you use my ILI9341 using SPI. They are listed below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
/** * Set layer 1 to drive data on it * * */ extern void TM_ILI9341_SetLayer1(void); /** * Set layer 2 to drive data on it * * */ extern void TM_ILI9341_SetLayer2(void); /** * Set layer 1 opacity * * Parameters: * uint8_t opacity: 0 to 255, 0 is no opacity, 255 is no transparent */ extern void TM_ILI9341_SetLayer1Opacity(uint8_t opacity); /** * Set layer 2 opacity * * Parameters: * uint8_t opacity: 0 to 255, 0 is no opacity, 255 is no transparency */ extern void TM_ILI9341_SetLayer2Opacity(uint8_t opacity); /** * This changes current active layer. * * If current layer is Layer1, than now will be Layer2 and vice versa * * It set transparency to 0 and 255 dependency to which layer is selected */ extern void TM_ILI9341_ChangeLayers(void); /** * Copy content of layer 2 to layer 1 * */ extern void TM_ILI9341_Layer2To1(void); /** * Copy content of layer 1 to layer 2 * */ extern void TM_ILI9341_Layer1To2(void); /** * @brief Enable display * @note After initialization, LCD is enabled and you don't need to call this function * @retval None */ extern void TM_ILI9341_DisplayOn(void); /** * @brief Disable display * @retval None */ extern void TM_ILI9341_DisplayOff(void); |
For other functions look at my old ILI9341 library.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
/** * Keil project for ILI9341 LTDC LCD example * * @author Tilen Majerle * @email tilen@majerle.eu * @website http://majerle.eu * @ide Keil uVision 5 */ #include "stm32f4xx.h" #include "stm32f4xx_spi.h" #include "defines.h" #include "tm_stm32f4_ili9341_ltdc.h" #include "tm_stm32f4_fonts.h" #include "tm_stm32f4_delay.h" #include <stdio.h> 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.net", &TM_Font_7x10, ILI9341_COLOR_BLACK, ILI9341_COLOR_ORANGE); 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.net", &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); */ } } |
View project on Github, download library below.
LTDC support for ILI9341 LCD
Recent comments