Configuration to use the TFT_eSPI library

Hello everyone!
I will need help on my project. I use the NUCLEO-L452RE-P development board and a GFX01M2 lcd screen (which uses the ILI9341 driver).
I want to use the TFT_eSPI library (which I have already used with the NUCLEO-G071RB board) in order to display different things on the screen.
Can you help me to correctly configure the library parameters for this microcontroller? You will also see in the comments the configuration I used for the G071RB.

If you need more information, do not hesitate to ask me!

; [env:nucleo_g071rb]
; platform = ststm32
; board = nucleo_g071rb
; framework = arduino

[env:nucleo_l452re]
platform = ststm32
board = nucleo_l452re
framework = arduino

lib_deps = 
    TFT_eSPI
    TFT_eWidget

build_flags =
        -D USER_SETUP_LOADED=1
        -D STM32=1
        -D NUCLEO_64_TFT=1
        -D TFT_INVERSION_OFF=1
        -D ILI9341_DRIVER=1
        -D TFT_WIDTH=240
        -D TFT_HEIGHT=320

        -D SPI_FREQUENCY=80000000
        -D TFT_RGB_ORDER=TFT_BGR ; Colour order Red-Green-Blue
        -D LOAD_GLCD=1   ; Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
        -D LOAD_FONT2=1  ; Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
        -D LOAD_FONT4=1  ; Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
        -D LOAD_FONT6=1  ; Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
        -D LOAD_FONT7=1  ; Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
        -D LOAD_FONT8=1  ; Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
        -D LOAD_GFXFF=1  ; FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
        -D SMOOTH_FONT=1
        -D TOUCH_CS=1

        ; Configuration for NUCLEO G071RB
        ;-D TFT_MISO=PA6
        ;-D TFT_MOSI=PA7
        ;-D TFT_SCLK=PA5
        ;-D TFT_CS=PA9   
        ;-D TFT_DC=PB14
        ;-D TFT_RST=PA1

        ; Configuration for NUCLEO L452RE
        -D TFT_MISO=PB14
        -D TFT_MOSI=PB15
        -D TFT_SCLK=PB13
        -D TFT_CS=PB6
        -D TFT_DC=PB10
        -D TFT_RST=PA1```

I fixed my problem, for those who have the same problem as me. You need to have the following configuration:

-D TFT_MISO=PB14
-D TFT_MOSI=PB15
-D TFT_SCLK=PB13
-D TFT_CS=PB6
-D TFT_DC=PB10
-D TFT_RST=PA1

And add this parameter:
-D TFT_SPI_PORT=2

Hello!

I'd be happy to help you configure the TFT_eSPI library for your NUCLEO-L452RE-P development board and GFX01M2 LCD screen. Below is a step-by-step guide on how to set up the library parameters.

Step-by-Step Configuration for TFT_eSPI Library

  1. Install the TFT_eSPI Library: Make sure you have installed the TFT_eSPI library in your Arduino IDE. You can install it from the Library Manager.
  2. Locate the User_Setup.h File: Navigate to the TFT_eSPI library folder and find the User_Setup.h file. This is where you will define the parameters for your specific hardware.
  3. Define the Display Driver: Add the following line to define the ILI9341 driver, which is used by the GFX01M2 screen:

cpp

Copy code

#define ILI9341_DRIVER
  1. Pin Definitions: Define the pin connections between your NUCLEO-L452RE-P board and the GFX01M2 screen. Update the following lines with your actual pin numbers:

cpp

Copy code

#define TFT_CS   PA4   // Chip select control pin
#define TFT_DC   PA1   // Data Command control pin
#define TFT_RST  PA0   // Reset pin (could connect to Arduino RESET pin)
#define TFT_MOSI PA7   // SPI MOSI
#define TFT_SCLK PA5   // SPI Clock
#define TFT_MISO PA6   // SPI MISO (not used by most displays)
  1. SPI Frequency: Set the SPI frequency to match your hardware capabilities. For example:

cpp

Copy code

#define SPI_FREQUENCY  27000000 // 27 MHz
  1. Additional Settings: Depending on your setup, you might need to adjust the following parameters:

cpp

Copy code

#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:.
#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
  1. Verify and Upload: After updating the User_Setup.h file, verify the configuration by compiling and uploading a simple TFT_eSPI example sketch to your NUCLEO-L452RE-P board.

Example Configuration

Here’s an example User_Setup.h configuration for your NUCLEO-L452RE-P and GFX01M2:

cpp

Copy code

// Setup for NUCLEO-L452RE-P with GFX01M2 (ILI9341 driver)

#define ILI9341_DRIVER

#define TFT_CS   PA4   // Chip select control pin
#define TFT_DC   PA1   // Data Command control pin
#define TFT_RST  PA0   // Reset pin (could connect to Arduino RESET pin)
#define TFT_MOSI PA7   // SPI MOSI
#define TFT_SCLK PA5   // SPI Clock
#define TFT_MISO PA6   // SPI MISO (not used by most displays)

#define SPI_FREQUENCY  27000000 // 27 MHz

#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:.
#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts

If you encounter any issues or need further assistance, feel free to ask!

Good luck with your project!

Best Regards - Emily James | Foxedo Sports

Hello!
Thanks for your help, I found my problem you have to specify the SPI port:
-D TFT_SPI_PORT=2

There are some configuration errors in the code you sent. The correct hardware configuration is:

-D TFT_MISO=PB14
-D TFT_MOSI=PB15
-D TFT_SCLK=PB13
-D TFT_CS=PB6
-D TFT_DC=PB10
-D TFT_RST=PA1

Doc here :
https://www.st.com/en/evaluation-tools/x-nucleo-gfx01m2.html
This will help other people not to make mistakes.

Best regards,