RP2040을 이용하여 ST7789 TFT LCD 모듈을 테스트 해보자
라이브러리는 TFT_eSPI를 사용 하였다.
간단한 예제로 동작 테스트를 해 보자
#include <TFT_eSPI.h> // Include the graphics library
TFT_eSPI tft = TFT_eSPI(); // Create object "tft"
// -------------------------------------------------------------------------
// Setup
// -------------------------------------------------------------------------
void setup(void) {
tft.init();
tft.setRotation(1);
tft.fillScreen(TFT_DARKGREY);
tft.setTextFont(2);
}
// -------------------------------------------------------------------------
// Main loop
// -------------------------------------------------------------------------
void loop()
{
tft.fillRectHGradient(0, 0, 160, 50, TFT_MAGENTA, TFT_BLUE);
tft.setCursor(10,10);
tft.print("Horizontal gradient");
tft.fillRectVGradient(0, 60, 160, 50, TFT_ORANGE, TFT_RED);
tft.setCursor(10,70);
tft.print("Vertical gradient");
while(1) delay(100); // Wait here
}
컴파일 시 에러가 발생 한다.
c:\Users\nexp7\OneDrive\????\Arduino\libraries\TFT_eSPI\Processors/TFT_eSPI_RP2040.c:24:62: error: 'TFT_SCLK' was not declared in this scope
24 | SPIClassRP2040 spi = SPIClassRP2040(SPI_X, TFT_MISO, -1, TFT_SCLK, TFT_MOSI);
| ^~~~~~~~
c:\Users\nexp7\OneDrive\????\Arduino\libraries\TFT_eSPI\Processors/TFT_eSPI_RP2040.c:24:72: error: 'TFT_MOSI' was not declared in this scope; did you mean 'TFT_MISO'?
24 | SPIClassRP2040 spi = SPIClassRP2040(SPI_X, TFT_MISO, -1, TFT_SCLK, TFT_MOSI);
| ^~~~~~~~
| TFT_MISO
Using library TFT_eSPI at version 2.4.2 in folder: C:\Users\nexp7\OneDrive\문서\Arduino\libraries\TFT_eSPI
Using library SPI at version 1.0 in folder: C:\Users\nexp7\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\1.9.7\libraries\SPI
Compilation error: exit status 1}
라이브러리 초기 설정은 TFT_eSPI\User_Setup_Select.h 파일에서 하면 된다.
C:\Users\nexp7\OneDrive\문서\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> // Setup file configured for my ILI9341
//#include <User_Setups/Setup1_ILI9341.h> // Setup file configured for my ILI9341
//#include <User_Setups/Setup2_ST7735.h> // Setup file configured for my ST7735
//#include <User_Setups/Setup3_ILI9163.h> // Setup file configured for my ILI9163
//#include <User_Setups/Setup4_S6D02A1.h> // Setup file configured for my S6D02A1
라이브러리 폴더가 변경되거나 업데이트 되었을 경우 설정파일이 삭제될 수 있기 때문에 새로운 폴더를 하나 만들어서 관리 하도록 했다.
RP2040에서 설정한 값은 Setup24_ST7789_rp2040_riexp.h 로 관리 할수 있도록 했다.
C:\Users\nexp7\OneDrive\문서\Arduino\libraries\TFT_eSPI_Setups\Setup24_ST7789_rp2040_riexp.h
// For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation
#define TFT_CS 17 // Define as not used
#define TFT_DC 26 // Data Command control pin
#define TFT_RST -1 // TFT reset pin (could connect to NodeMCU RST, see next line)
//#define TFT_RST -1 // TFT reset pin connect to NodeMCU RST, must also then add 10K pull down to TFT SCK
#ifndef TFT_MOSI
#define TFT_MOSI 19
#endif
#ifndef TFT_SCLK
#define TFT_SCLK 18
#endif
반응형