STM32H7 Arduino 로 TFTLCD ST7789 모듈을 제어 해 보자
TFT LCD 라이브러리는 FTF_eSPI 를 사용하여 테스트 했다.
https://github.com/Bodmer/TFT_eSPI
셋업 방법
Arduino\libraries\TFT_eSPI
폴더에 User_Setup_Select.h 파일에 보드에 따른 설정파일을 지정해 주어야 한다.
#ifndef USER_SETUP_LOADED // Lets PlatformIO users define settings in
// platformio.ini, see notes in "Tools" folder.
// Only ONE line below should be uncommented. Add extra lines and files as needed.
//#include <User_Setup.h> // Default setup is root library folder
//#include <../TFT_eSPI_Setups/Setup24_ST7789_rp2040_riexp.h>
#include <../TFT_eSPI_Setups/Setup_ST7789_stm32h7_evm.h>
Arduino\libraries\TFT_eSPI\User_Setups
폴더에 Setup_ST7789_stm32h7_evm.h 파일을 만들어서 작성했다.
#define ST7789_DRIVER // Configure all registers
#define TFT_WIDTH 240
#define TFT_HEIGHT 240
#define TFT_CS 9 // Define as not used
#define TFT_DC 10 // Data Command control pin
#define TFT_RST -1 // TFT reset pin (could connect to NodeMCU RST, see next line)
#ifndef TFT_MOSI
#define TFT_MOSI 19
#endif
#ifndef TFT_SCLK
#define TFT_SCLK 18
#endif
#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_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
#define SMOOTH_FONT
//#define SPI_FREQUENCY 27000000
#define SPI_FREQUENCY 4000000
TFT_eSPI 라이브러리에서 제공하는 다양한 예제를 테스트 해 보면 잘 동작하는것을 확인 할 수 있다.
반응형