3.5" ST9976U TFT LCD library problem

Hello, I bought a 3.5" ST9976U TFT LCD display. I'm trying to get the display working and so far no luck. I'm trying to use the TFT_eSPI library. And so far no luck. I even define the pins for the display and the same thing comes up.

This is my display: here.

This is my code:

#include <TFT_eSPI.h>
TFT_eSPI tft = TFT_eSPI();

#define TFT_MOSI 11
#define TFT_MISO 12
#define TFT_SCLK 13
#define TFT_CS   10
#define TFT_RS   9   // RS pin
#define TFT_RST  8

#define ST7796_DRIVER

void setup() {
  tft.init();
  tft.setRotation(1);
  tft.fillScreen(TFT_BLACK);

  tft.setCursor(20, 40);
  tft.setTextColor(TFT_YELLOW, TFT_BLACK);
  tft.setTextSize(3);
  tft.println("ST7796U SPI + RS");

  tft.drawTriangle(50,200,150,200,100,100,TFT_RED);
}

void loop() {}

This is the output:

In file included from C:\Users\Jester\AppData\Local\Temp\.arduinoIDE-unsaved20251021-23216-1u5fbu3.7xmd\sketch_nov21d\sketch_nov21d.ino:1:
c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/TFT_eSPI.h:973:8: warning: #warning >>>>------>> TOUCH_CS pin not defined, TFT_eSPI touch functions will not be available! [-Wcpp]
  973 |       #warning >>>>------>> TOUCH_CS pin not defined, TFT_eSPI touch functions will not be available!
      |        ^~~~~~~
C:\Users\Jester\AppData\Local\Temp\.arduinoIDE-unsaved20251021-23216-1u5fbu3.7xmd\sketch_nov21d\sketch_nov21d.ino:4: warning: "TFT_MOSI" redefined
    4 | #define TFT_MOSI 11
      | 
In file included from c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/User_Setup_Select.h:27,
                 from c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/TFT_eSPI.h:69,
                 from C:\Users\Jester\AppData\Local\Temp\.arduinoIDE-unsaved20251021-23216-1u5fbu3.7xmd\sketch_nov21d\sketch_nov21d.ino:1:
c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/User_Setup.h:171: note: this is the location of the previous definition
  171 | #define TFT_MOSI  PIN_D7  // Automatically assigned with ESP8266 if not defined
      | 
C:\Users\Jester\AppData\Local\Temp\.arduinoIDE-unsaved20251021-23216-1u5fbu3.7xmd\sketch_nov21d\sketch_nov21d.ino:5: warning: "TFT_MISO" redefined
    5 | #define TFT_MISO 12
      | 
In file included from c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/User_Setup_Select.h:27,
                 from c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/TFT_eSPI.h:69,
                 from C:\Users\Jester\AppData\Local\Temp\.arduinoIDE-unsaved20251021-23216-1u5fbu3.7xmd\sketch_nov21d\sketch_nov21d.ino:1:
c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/User_Setup.h:170: note: this is the location of the previous definition
  170 | #define TFT_MISO  PIN_D6  // Automatically assigned with ESP8266 if not defined
      | 
C:\Users\Jester\AppData\Local\Temp\.arduinoIDE-unsaved20251021-23216-1u5fbu3.7xmd\sketch_nov21d\sketch_nov21d.ino:6: warning: "TFT_SCLK" redefined
    6 | #define TFT_SCLK 13
      | 
In file included from c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/User_Setup_Select.h:27,
                 from c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/TFT_eSPI.h:69,
                 from C:\Users\Jester\AppData\Local\Temp\.arduinoIDE-unsaved20251021-23216-1u5fbu3.7xmd\sketch_nov21d\sketch_nov21d.ino:1:
c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/User_Setup.h:172: note: this is the location of the previous definition
  172 | #define TFT_SCLK  PIN_D5  // Automatically assigned with ESP8266 if not defined
      | 
C:\Users\Jester\AppData\Local\Temp\.arduinoIDE-unsaved20251021-23216-1u5fbu3.7xmd\sketch_nov21d\sketch_nov21d.ino:7: warning: "TFT_CS" redefined
    7 | #define TFT_CS   10
      | 
In file included from c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/User_Setup_Select.h:27,
                 from c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/TFT_eSPI.h:69,
                 from C:\Users\Jester\AppData\Local\Temp\.arduinoIDE-unsaved20251021-23216-1u5fbu3.7xmd\sketch_nov21d\sketch_nov21d.ino:1:
c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/User_Setup.h:174: note: this is the location of the previous definition
  174 | #define TFT_CS    PIN_D8  // Chip select control pin D8
      | 
C:\Users\Jester\AppData\Local\Temp\.arduinoIDE-unsaved20251021-23216-1u5fbu3.7xmd\sketch_nov21d\sketch_nov21d.ino:9: warning: "TFT_RST" redefined
    9 | #define TFT_RST  8
      | 
In file included from c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/User_Setup_Select.h:27,
                 from c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/TFT_eSPI.h:69,
                 from C:\Users\Jester\AppData\Local\Temp\.arduinoIDE-unsaved20251021-23216-1u5fbu3.7xmd\sketch_nov21d\sketch_nov21d.ino:1:
c:\Users\Jester\Documents\Arduino\libraries\TFT_eSPI/User_Setup.h:176: note: this is the location of the previous definition
  176 | #define TFT_RST   PIN_D4  // Reset pin (could connect to NodeMCU RST, see next line)
      | 
Sketch uses 51048 bytes (10%) of program storage space. Maximum is 507904 bytes.
Device       : ATSAMD51x19
Version      : v1.1 [Arduino:XYZ] Apr  8 2018 16:27:40
Address      : 0x0
Pages        : 1024
Page Size    : 512 bytes
Total Size   : 512KB
Planes       : 1
Lock Regions : 32
Locked       : none
Security     : false
BOD          : false
BOR          : true
Write 52704 bytes to flash (103 pages)

[                              ] 0% (0/103 pages)
[==                            ] 7% (8/103 pages)
[====                          ] 15% (16/103 pages)
[======                        ] 23% (24/103 pages)
[=========                     ] 31% (32/103 pages)
[===========                   ] 38% (40/103 pages)
[=============                 ] 46% (48/103 pages)
[================              ] 54% (56/103 pages)
[==================            ] 62% (64/103 pages)
[====================          ] 69% (72/103 pages)
[=======================       ] 77% (80/103 pages)
[=========================     ] 85% (88/103 pages)
[===========================   ] 93% (96/103 pages)
[==============================] 100% (103/103 pages)
Done in 0.923 seconds
Verify 52704 bytes of flash

[=                             ] 3% (4/103 pages)
[=                             ] 4% (5/103 pages)
[=                             ] 5% (6/103 pages)
[==                            ] 6% (7/103 pages)
[==                            ] 7% (8/103 pages)
[==                            ] 8% (9/103 pages)
[==                            ] 9% (10/103 pages)
[===                           ] 10% (11/103 pages)
[===                           ] 11% (12/103 pages)
[===                           ] 12% (13/103 pages)
[====                          ] 13% (14/103 pages)
[====                          ] 14% (15/103 pages)
[====                          ] 15% (16/103 pages)
[====                          ] 16% (17/103 pages)
[=====                         ] 17% (18/103 pages)
[=====                         ] 18% (19/103 pages)
[=====                         ] 19% (20/103 pages)
[======                        ] 20% (21/103 pages)
[======                        ] 21% (22/103 pages)
[======                        ] 22% (23/103 pages)
[======                        ] 23% (24/103 pages)
[=======                       ] 24% (25/103 pages)
[=======                       ] 25% (26/103 pages)
[=======                       ] 26% (27/103 pages)
[========                      ] 27% (28/103 pages)
[========                      ] 28% (29/103 pages)
[========                      ] 29% (30/103 pages)
[=========                     ] 30% (31/103 pages)
[=========                     ] 31% (32/103 pages)
[=========                     ] 32% (33/103 pages)
[=========                     ] 33% (34/103 pages)
[==========                    ] 33% (35/103 pages)
[==========                    ] 34% (36/103 pages)
[==========                    ] 35% (37/103 pages)
[===========                   ] 36% (38/103 pages)
[===========                   ] 37% (39/103 pages)
[===========                   ] 38% (40/103 pages)
[===========                   ] 39% (41/103 pages)
[============                  ] 40% (42/103 pages)
[============                  ] 41% (43/103 pages)
[============                  ] 42% (44/103 pages)
[=============                 ] 43% (45/103 pages)
[=============                 ] 44% (46/103 pages)
[=============                 ] 45% (47/103 pages)
[=============                 ] 46% (48/103 pages)
[==============                ] 47% (49/103 pages)
[==============                ] 48% (50/103 pages)
[==============                ] 49% (51/103 pages)
[===============               ] 50% (52/103 pages)
[===============               ] 51% (53/103 pages)
[===============               ] 52% (54/103 pages)
[================              ] 53% (55/103 pages)
[================              ] 54% (56/103 pages)
[================              ] 55% (57/103 pages)
[================              ] 56% (58/103 pages)
[=================             ] 57% (59/103 pages)
[=================             ] 58% (60/103 pages)
[=================             ] 59% (61/103 pages)
[==================            ] 60% (62/103 pages)
[==================            ] 61% (63/103 pages)
[==================            ] 62% (64/103 pages)
[==================            ] 63% (65/103 pages)
[===================           ] 64% (66/103 pages)
[===================           ] 65% (67/103 pages)
[===================           ] 66% (68/103 pages)
[====================          ] 66% (69/103 pages)
[====================          ] 67% (70/103 pages)
[====================          ] 68% (71/103 pages)
[====================          ] 69% (72/103 pages)
[=====================         ] 70% (73/103 pages)
[=====================         ] 71% (74/103 pages)
[=====================         ] 72% (75/103 pages)
[======================        ] 73% (76/103 pages)
[======================        ] 74% (77/103 pages)
[======================        ] 75% (78/103 pages)
[=======================       ] 76% (79/103 pages)
[=======================       ] 77% (80/103 pages)
[=======================       ] 78% (81/103 pages)
[=======================       ] 79% (82/103 pages)
[========================      ] 80% (83/103 pages)
[========================      ] 81% (84/103 pages)
[========================      ] 82% (85/103 pages)
[=========================     ] 83% (86/103 pages)
[=========================     ] 84% (87/103 pages)
[=========================     ] 85% (88/103 pages)
[=========================     ] 86% (89/103 pages)
[==========================    ] 87% (90/103 pages)
[==========================    ] 88% (91/103 pages)
[==========================    ] 89% (92/103 pages)
[===========================   ] 90% (93/103 pages)
[===========================   ] 91% (94/103 pages)
[===========================   ] 92% (95/103 pages)
[===========================   ] 93% (96/103 pages)
[============================  ] 94% (97/103 pages)
[============================  ] 95% (98/103 pages)
[============================  ] 96% (99/103 pages)
[============================= ] 97% (100/103 pages)
[============================= ] 98% (101/103 pages)
[============================= ] 99% (102/103 pages)
[==============================] 100% (103/103 pages)
Verify successful
Done in 0.386 seconds

I thought the Display was bad and I upload a different different library for a small display with a different driver on it and the Display lights up with a bunch of pixels. So i know the display is working. I just don't know what I'm doing wrong or is this the wrong library, missing code. Not sure what to do next. I need help please?

Joseph

These definitions are seen only within your .ino file and are not passed to the library. Since you don't use them anywhere in your code, there's no point in including these lines.

You need to check which pin numbers the library uses for the corresponding signals and connect the display accordingly or correct the pin numbers in the library code.

Addition:
According to the error message, the default library pins are:

#define TFT_MOSI  PIN_D7
#define TFT_MISO  PIN_D6
#define TFT_SCLK  PIN_D5
#define TFT_CS    PIN_D8
#define TFT_RST   PIN_D4

Also the touch pin is not defined.
Did you edit al the setups in the Library , I think there is 3 Setups that you must edit for your screen driver.

@mikedb I'm not using touch. I just need the screen.

@b707 This is the my first time working with a display in over 7 years. This is code I found online. I haven't modify anything but what pins go to what. Other then that the code is the same. Not sure how to pass it through?

Edit: I did fine I need to add something like this as an example #include <User_Setups/Setup42_ILI9341_ESP32.h> But sinse I'm not using a esp32. I looked in the user setup folder and everyone in there is esp, stm or a rp2040. There is a custom one below in the library trying to look over that now.

There is a diagnostic Example sketch in the library , replying from my phone .. so I cannot confirm the exact name, that will print the pins setup , you dont need the screen connected.

When you edit a setup , you must SAVE , not save as!

@mikedb Thank you I will trying it and report back.

Edit: Just an update. This is the results of that test.

[code]
TFT_eSPI ver = 2.5.43
Processor    = Generic
Transactions = Yes
Interface    = SPI
Display driver = 9341
Display width  = 240
Display height = 320

MOSI    = GPIO 13
MISO    = GPIO 12
SCK     = GPIO 14
TFT_CS   = GPIO 15
TFT_DC   = GPIO 0
TFT_RST  = GPIO 2

Font GLCD   loaded
Font 2      loaded
Font 4      loaded
Font 6      loaded
Font 7      loaded
Font 8      loaded
Smooth font enabled

Display SPI frequency = 27.00
[/code]

This is wrong my screen is 480x320 and it says 240x320. I'm also using the arduino zero board I forgot the say.

Your display driver is 9341 in the library is wrong .

@mikedb my driver is ST7796U. In my first port is an Amazon link with my display I bought from the same Amazon page.

Edit: I'm reding the code and this is setup for a ESP processor.

Did you correct the pin numbers in your code or in the library in order that it became consistent to each other? If you not corrected the connection or not connected the screen at all - the test results means nothing.

@b707 I define the pins in my code. Not sure how to change that in the library. Are you referring to the diagnostic example @mikedb ask me to do or my own code?

As I already wrote to you in #2, defining the pins in the code is a pointless thing. If you can't to change pins in the library, so you need to rewire your connection ito be consistent with pins in the library.

@b707 It's not that. I don't know where in the library to do that.

In that case you need to connect the screen to the pins that used in the library.

@b707 it’s set for an esp pinout with gpio puns.

As @707 said the diagnostic test only show what pins is setup in the Library.

In the screenshot you posted the Screen is ILI9341 which is not correct then the MOSI , MISO , CLK pins is 12,13 ,14 this is also wrong.

What ESP are you using?

In user_setups you will see these pins for example setup 27.

#define USER_SETUP_ID 27

// ##################################################################################
//
// Section 0. Call up the right driver file and any options for it
//
// ##################################################################################

// Display type -  only define if RPi display
#define RPI_DISPLAY_TYPE

// Only define one driver
#define ST7796_DRIVER

// ##################################################################################
//
// Section 1. Define the pins that are used to interface with the display here
//
// ##################################################################################

// >>>>> EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP32 SETUP   <<<<<

// The ESP32 hardware SPI can be mapped to any pins, these are the recommended default

#define TFT_MISO 19
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS   15   // Chip select control pin
#define TFT_DC    2   // Data Command control pin
#define TFT_RST   4   // Reset pin (could connect to RST pin)
//#define TFT_RST  -1 // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST

In user_setup , comment everything out and un comment your Driver.


// Only define one driver, the other ones must be commented out
#define ILI9341_DRIVER       // Generic driver for common displays
//#define ILI9341_2_DRIVER     // Alternative ILI9341 driver, see https://github.com/Bodmer/TFT_eSPI/issues/1172
//#define ST7735_DRIVER      // Define additional parameters below for this display
//#define ILI9163_DRIVER     // Define additional parameters below for this display
//#define S6D02A1_DRIVER
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
//#define HX8357D_DRIVER
//#define ILI9481_DRIVER
//#define ILI9486_DRIVER
//#define ILI9488_DRIVER     // WARNING: Do not connect ILI9488 display SDO to MISO if other devices share the SPI bus (TFT SDO does NOT tristate when CS is high)
//#define ST7789_DRIVER      // Full configuration option, define additional parameters below for this display
//#define ST7789_2_DRIVER    // Minimal configuration option, define additional parameters below for this display
//#define R61581_DRIVER
//#define RM68140_DRIVER
//#define ST7796_DRIVER
//#define SSD1351_DRIVER
//#define SSD1963_480_DRIVER
//#define SSD1963_800_DRIVER
//#define SSD1963_800ALT_DRIVER
//#define ILI9225_DRIVER
//#define GC9A01_DRIVER

In user_setup_select for example setup 27.

//#include <User_Setups/Setup20_ILI9488.h>           // Setup file for ESP8266 and ILI9488 SPI bus TFT
//#include <User_Setups/Setup21_ILI9488.h>           // Setup file for ESP32 and ILI9488 SPI bus TFT

//#include <User_Setups/Setup22_TTGO_T4.h>           // Setup file for ESP32 and TTGO T4 version 1.2
//#include <User_Setups/Setup22_TTGO_T4_v1.3.h>      // Setup file for ESP32 and TTGO T4 version 1.3
//#include <User_Setups/Setup23_TTGO_TM.h>           // Setup file for ESP32 and TTGO TM ST7789 SPI bus TFT
//#include <User_Setups/Setup24_ST7789.h>            // Setup file for DSTIKE/ESP32/ESP8266 configured for ST7789 240 x 240
//#include <User_Setups/Setup25_TTGO_T_Display.h>    // Setup file for ESP32 and TTGO T-Display ST7789V SPI bus TFT
//#include <User_Setups/Setup26_TTGO_T_Wristband.h>  // Setup file for ESP32 and TTGO T-Wristband ST7735 SPI bus TFT

#include <User_Setups/Setup27_RPi_ST7796_ESP32.h>    // ESP32   RPi MHS-4.0 inch Display-B
//#include <User_Setups/Setup28_RPi_ST7796_ESP8266.h>  // ESP8266 RPi MHS-4.0 inch Display-B

//#include <User_Setups/Setup29_ILI9341_STM32.h>          // Setup for Nucleo board
//#include <User_Setups/Setup30_ILI9341_Parallel_STM32.h> // Setup for Nucleo board and parallel display
//#include <User_Setups/Setup31_ST7796_Parallel_STM32.h>  // Setup for Nucleo board and parallel display
//#include <User_Setups/Setup32_ILI9341_STM32F103.h>      // Setup for "Blue/Black Pill"

SAVE every screen after you change something.

Now run the diagnostic test again and check if your pins and screen is correct , hope this helps.

Edit.Your topic description is wrong I could not find ST9976 in the Library took me a while realize ...

@mikedb I'm not using any ESP board. I'm using the arduino zero board. I'm miss understanding something and sorry about that. Let me read this all again.

Are you sure Zero board is supported by TFT_eSPI library?

You now have two potential sources of problems: the new display and the rare board. This is a disadvantageous situation. If something doesn't work, you don't know whether it's the display or the Zero board.
I would recommend that you first test the display on a board whose support is clearly indicated in the library, such as the ESP8266 or ESP32. Once you've determined all the settings the display works with, it will be easier to transfer them to the Zero.

@b707 To be honest I looked up the model of the display with that drivers and one of the few results it gave me was this library in google. But looking at it now It seems like that this library is the wrong one. I'm unsure of what library I really need.

Just an update. I'm giving up on the whole eSPI library. Finding that I was wrong about this is the library is the one for my screen. I search more online and everything is pointing to the MCUFRIEND_kbv library. I'm looking into the library for test.

I'm testing the graphictest_kbv example. One thing I ran across is the define pinout. There are two pins that doesn't match up in the example LCD_WR A1, LCD_RD A0 and LCD_CD A2 There is no WR, RD or CD pins on my screen. Do I just ignore them or comment out pins?

Here is the sketch unmidify.

// All the mcufriend.com UNO shields have the same pinout.
// i.e. control pins A0-A4.  Data D2-D9.  microSD D10-D13.
// Touchscreens are normally A1, A2, D7, D6 but the order varies
//
// This demo should work with most Adafruit TFT libraries
// If you are not using a shield,  use a full Adafruit constructor()
// e.g. Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

#include <SPI.h>          // f.k. for Arduino-1.5.2
#include "Adafruit_GFX.h"// Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
//#include <Adafruit_TFTLCD.h>
//Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

// Assign human-readable names to some common 16-bit color values:
#define	BLACK   0x0000
#define	BLUE    0x001F
#define	RED     0xF800
#define	GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif

void setup(void);
void loop(void);
unsigned long testFillScreen();
unsigned long testText();
unsigned long testLines(uint16_t color);
unsigned long testFastLines(uint16_t color1, uint16_t color2);
unsigned long testRects(uint16_t color);
unsigned long testFilledRects(uint16_t color1, uint16_t color2);
unsigned long testFilledCircles(uint8_t radius, uint16_t color);
unsigned long testCircles(uint8_t radius, uint16_t color);
unsigned long testTriangles();
unsigned long testFilledTriangles();
unsigned long testRoundRects();
unsigned long testFilledRoundRects();
void progmemPrint(const char *str);
void progmemPrintln(const char *str);

void runtests(void);

uint16_t g_identifier;

extern const uint8_t hanzi[];
void showhanzi(unsigned int x, unsigned int y, unsigned char index)
{
    uint8_t i, j, c, first = 1;
    uint8_t *temp = (uint8_t*)hanzi;
    uint16_t color;
    tft.setAddrWindow(x, y, x + 31, y + 31); //设置区域
    temp += index * 128;
    for (j = 0; j < 128; j++)
    {
        c = pgm_read_byte(temp);
        for (i = 0; i < 8; i++)
        {
            if ((c & (1 << i)) != 0)
            {
                color = RED;
            }
            else
            {
                color = BLACK;
            }
            tft.pushColors(&color, 1, first);
            first = 0;
        }
        temp++;
    }
}

void setup(void) {
    Serial.begin(9600);
    uint32_t when = millis();
    //    while (!Serial) ;   //hangs a Leonardo until you connect a Serial
    if (!Serial) delay(5000);           //allow some time for Leonardo
    Serial.println("Serial took " + String((millis() - when)) + "ms to start");
    //    tft.reset();                 //hardware reset
    uint16_t ID = tft.readID(); //
    Serial.print("ID = 0x");
    Serial.println(ID, HEX);
    if (ID == 0xD3D3) ID = 0x9481; // write-only shield
//    ID = 0x9329;                             // force ID
    tft.begin(ID);
}

#if defined(MCUFRIEND_KBV_H_)
uint16_t scrollbuf[320];    // my biggest screen is 320x480
#define READGRAM(x, y, buf, w, h)  tft.readGRAM(x, y, buf, w, h)
#else
uint16_t scrollbuf[320];    // Adafruit only does 240x320
// Adafruit can read a block by one pixel at a time
int16_t  READGRAM(int16_t x, int16_t y, uint16_t *block, int16_t w, int16_t h)
{
    uint16_t *p;
    for (int row = 0; row < h; row++) {
        p = block + row * w;
        for (int col = 0; col < w; col++) {
            *p++ = tft.readPixel(x + col, y + row);
        }
    }
}
#endif

void windowScroll(int16_t x, int16_t y, int16_t wid, int16_t ht, int16_t dx, int16_t dy, uint16_t *buf)
{
    if (dx) for (int16_t row = 0; row < ht; row++) {
            READGRAM(x, y + row, buf, wid, 1);
            tft.setAddrWindow(x, y + row, x + wid - 1, y + row);
            tft.pushColors(buf + dx, wid - dx, 1);
            tft.pushColors(buf + 0, dx, 0);
        }
    if (dy) for (int16_t col = 0; col < wid; col++) {
            READGRAM(x + col, y, buf, 1, ht);
            tft.setAddrWindow(x + col, y, x + col, y + ht - 1);
            tft.pushColors(buf + dy, ht - dy, 1);
            tft.pushColors(buf + 0, dy, 0);
        }
}

void printmsg(int row, const char *msg)
{
    tft.setTextColor(YELLOW, BLACK);
    tft.setCursor(0, row);
    tft.println(msg);
}

void loop(void) {
    uint8_t aspect;
    uint16_t pixel;
    const char *aspectname[] = {
        "PORTRAIT", "LANDSCAPE", "PORTRAIT_REV", "LANDSCAPE_REV"
    };
    const char *colorname[] = { "BLUE", "GREEN", "RED", "GRAY" };
    uint16_t colormask[] = { 0x001F, 0x07E0, 0xF800, 0xFFFF };
    uint16_t dx, rgb, n, wid, ht, msglin;
    tft.setRotation(0);
    runtests();
    delay(2000);
    if (tft.height() > 64) {
        for (uint8_t cnt = 0; cnt < 4; cnt++) {
            aspect = (cnt + 0) & 3;
            tft.setRotation(aspect);
            wid = tft.width();
            ht = tft.height();
            msglin = (ht > 160) ? 200 : 112;
            testText();
            dx = wid / 32;
            for (n = 0; n < 32; n++) {
                rgb = n * 8;
                rgb = tft.color565(rgb, rgb, rgb);
                tft.fillRect(n * dx, 48, dx, 63, rgb & colormask[aspect]);
            }
            tft.drawRect(0, 48 + 63, wid, 1, WHITE);
            tft.setTextSize(2);
            tft.setTextColor(colormask[aspect], BLACK);
            tft.setCursor(0, 72);
            tft.print(colorname[aspect]);
            tft.setTextColor(WHITE);
            tft.println(" COLOR GRADES");
            tft.setTextColor(WHITE, BLACK);
            printmsg(184, aspectname[aspect]);
            delay(1000);
            tft.drawPixel(0, 0, YELLOW);
            pixel = tft.readPixel(0, 0);
            tft.setTextSize((ht > 160) ? 2 : 1); //for messages
#if defined(MCUFRIEND_KBV_H_)
#if 1
            extern const uint8_t penguin[];
            tft.setAddrWindow(wid - 40 - 40, 20 + 0, wid - 1 - 40, 20 + 39);
            tft.pushColors(penguin, 1600, 1);
#elif 1
            extern const uint8_t wifi_full[];
            tft.setAddrWindow(wid - 40 - 40, 20 + 0, wid - 40 - 40 + 31, 20 + 31);
            tft.pushColors(wifi_full, 1024, 1, true);
#elif 1
            extern const uint8_t icon_40x40[];
            tft.setAddrWindow(wid - 40 - 40, 20 + 0, wid - 1 - 40, 20 + 39);
            tft.pushColors(icon_40x40, 1600, 1);
#endif
            tft.setAddrWindow(0, 0, wid - 1, ht - 1);
            if (aspect & 1) tft.drawRect(wid - 1, 0, 1, ht, WHITE);
            else tft.drawRect(0, ht - 1, wid, 1, WHITE);
            printmsg(msglin, "VERTICAL SCROLL UP");
            uint16_t maxscroll;
            if (tft.getRotation() & 1) maxscroll = wid;
            else maxscroll = ht;
            for (uint16_t i = 1; i <= maxscroll; i++) {
                tft.vertScroll(0, maxscroll, i);
                delay(10);
            }
            delay(1000);
			printmsg(msglin, "VERTICAL SCROLL DN");
            for (uint16_t i = 1; i <= maxscroll; i++) {
                tft.vertScroll(0, maxscroll, 0 - (int16_t)i);
                delay(10);
            }
			tft.vertScroll(0, maxscroll, 0);
            printmsg(msglin, "SCROLL DISABLED   ");

            delay(1000);
            if ((aspect & 1) == 0) { //Portrait
                tft.setTextColor(BLUE, BLACK);
                printmsg(msglin, "ONLY THE COLOR BAND");
                for (uint16_t i = 1; i <= 64; i++) {
                    tft.vertScroll(48, 64, i);
                    delay(20);
                }
                delay(1000);
            }
#endif
            tft.setTextColor(YELLOW, BLACK);
            if (pixel == YELLOW) {
                printmsg(msglin, "SOFTWARE SCROLL    ");
#if 0
                // diagonal scroll of block
                for (int16_t i = 45, dx = 2, dy = 1; i > 0; i -= dx) {
                    windowScroll(24, 8, 90, 40, dx, dy, scrollbuf);
                }
#else
                // plain horizontal scroll of block
                n = (wid > 320) ? 320 : wid;
                for (int16_t i = n, dx = 4, dy = 0; i > 0; i -= dx) {
                    windowScroll(0, 200, n, 16, dx, dy, scrollbuf);
                }
#endif
            }
            else if (pixel == CYAN)
                tft.println("readPixel() reads as BGR");
            else if ((pixel & 0xF8F8) == 0xF8F8)
                tft.println("readPixel() should be 24-bit");
            else {
                tft.print("readPixel() reads 0x");
                tft.println(pixel, HEX);
            }
            delay(5000);
        }
    }
    printmsg(msglin, "INVERT DISPLAY ");
    tft.invertDisplay(true);
    delay(2000);
    tft.invertDisplay(false);
}

typedef struct {
    PGM_P msg;
    uint32_t ms;
} TEST;
TEST result[12];

#define RUNTEST(n, str, test) { result[n].msg = PSTR(str); result[n].ms = test; delay(500); }

void runtests(void)
{
    uint8_t i, len = 24, cnt;
    uint32_t total;
    RUNTEST(0, "FillScreen               ", testFillScreen());
    RUNTEST(1, "Text                     ", testText());
    RUNTEST(2, "Lines                    ", testLines(CYAN));
    RUNTEST(3, "Horiz/Vert Lines         ", testFastLines(RED, BLUE));
    RUNTEST(4, "Rectangles (outline)     ", testRects(GREEN));
    RUNTEST(5, "Rectangles (filled)      ", testFilledRects(YELLOW, MAGENTA));
    RUNTEST(6, "Circles (filled)         ", testFilledCircles(10, MAGENTA));
    RUNTEST(7, "Circles (outline)        ", testCircles(10, WHITE));
    RUNTEST(8, "Triangles (outline)      ", testTriangles());
    RUNTEST(9, "Triangles (filled)       ", testFilledTriangles());
    RUNTEST(10, "Rounded rects (outline)  ", testRoundRects());
    RUNTEST(11, "Rounded rects (filled)   ", testFilledRoundRects());

    tft.fillScreen(BLACK);
    tft.setTextColor(GREEN);
    tft.setCursor(0, 0);
    uint16_t wid = tft.width();
    if (wid > 176) {
        tft.setTextSize(2);
#if defined(MCUFRIEND_KBV_H_)
        tft.print("MCUFRIEND ");
#if MCUFRIEND_KBV_H_ != 0
        tft.print(0.01 * MCUFRIEND_KBV_H_, 2);
#else
        tft.print("for");
#endif
        tft.println(" UNO");
#else
        tft.println("Adafruit-Style Tests");
#endif
    } else len = wid / 6 - 8;
    tft.setTextSize(1);
    total = 0;
    for (i = 0; i < 12; i++) {
        PGM_P str = result[i].msg;
        char c;
        if (len > 24) {
            if (i < 10) tft.print(" ");
            tft.print(i);
            tft.print(": ");
        }
        uint8_t cnt = len;
        while ((c = pgm_read_byte(str++)) && cnt--) tft.print(c);
        tft.print(" ");
        tft.println(result[i].ms);
        total += result[i].ms;
    }
    tft.setTextSize(2);
    tft.print("Total:");
    tft.print(0.000001 * total);
    tft.println("sec");
    g_identifier = tft.readID();
    tft.print("ID: 0x");
    tft.println(tft.readID(), HEX);
//    tft.print("Reg(00):0x");
//    tft.println(tft.readReg(0x00), HEX);
    tft.print("F_CPU:");
    tft.print(0.000001 * F_CPU);
#if defined(__OPTIMIZE_SIZE__)
    tft.println("MHz -Os");
#else
    tft.println("MHz");
#endif

    delay(10000);
}

// Standard Adafruit tests.  will adjust to screen size

unsigned long testFillScreen() {
    unsigned long start = micros();
    tft.fillScreen(BLACK);
    tft.fillScreen(RED);
    tft.fillScreen(GREEN);
    tft.fillScreen(BLUE);
    tft.fillScreen(BLACK);
    return micros() - start;
}

unsigned long testText() {
    unsigned long start;
    tft.fillScreen(BLACK);
    start = micros();
    tft.setCursor(0, 0);
    tft.setTextColor(WHITE);  tft.setTextSize(1);
    tft.println("Hello World!");
    tft.setTextColor(YELLOW); tft.setTextSize(2);
    tft.println(123.45);
    tft.setTextColor(RED);    tft.setTextSize(3);
    tft.println(0xDEADBEEF, HEX);
    tft.println();
    tft.setTextColor(GREEN);
    tft.setTextSize(5);
    tft.println("Groop");
    tft.setTextSize(2);
    tft.println("I implore thee,");
    tft.setTextSize(1);
    tft.println("my foonting turlingdromes.");
    tft.println("And hooptiously drangle me");
    tft.println("with crinkly bindlewurdles,");
    tft.println("Or I will rend thee");
    tft.println("in the gobberwarts");
    tft.println("with my blurglecruncheon,");
    tft.println("see if I don't!");
    return micros() - start;
}

unsigned long testLines(uint16_t color) {
    unsigned long start, t;
    int           x1, y1, x2, y2,
                  w = tft.width(),
                  h = tft.height();

    tft.fillScreen(BLACK);

    x1 = y1 = 0;
    y2    = h - 1;
    start = micros();
    for (x2 = 0; x2 < w; x2 += 6) tft.drawLine(x1, y1, x2, y2, color);
    x2    = w - 1;
    for (y2 = 0; y2 < h; y2 += 6) tft.drawLine(x1, y1, x2, y2, color);
    t     = micros() - start; // fillScreen doesn't count against timing

    tft.fillScreen(BLACK);

    x1    = w - 1;
    y1    = 0;
    y2    = h - 1;
    start = micros();
    for (x2 = 0; x2 < w; x2 += 6) tft.drawLine(x1, y1, x2, y2, color);
    x2    = 0;
    for (y2 = 0; y2 < h; y2 += 6) tft.drawLine(x1, y1, x2, y2, color);
    t    += micros() - start;

    tft.fillScreen(BLACK);

    x1    = 0;
    y1    = h - 1;
    y2    = 0;
    start = micros();
    for (x2 = 0; x2 < w; x2 += 6) tft.drawLine(x1, y1, x2, y2, color);
    x2    = w - 1;
    for (y2 = 0; y2 < h; y2 += 6) tft.drawLine(x1, y1, x2, y2, color);
    t    += micros() - start;

    tft.fillScreen(BLACK);

    x1    = w - 1;
    y1    = h - 1;
    y2    = 0;
    start = micros();
    for (x2 = 0; x2 < w; x2 += 6) tft.drawLine(x1, y1, x2, y2, color);
    x2    = 0;
    for (y2 = 0; y2 < h; y2 += 6) tft.drawLine(x1, y1, x2, y2, color);

    return micros() - start;
}

unsigned long testFastLines(uint16_t color1, uint16_t color2) {
    unsigned long start;
    int           x, y, w = tft.width(), h = tft.height();

    tft.fillScreen(BLACK);
    start = micros();
    for (y = 0; y < h; y += 5) tft.drawFastHLine(0, y, w, color1);
    for (x = 0; x < w; x += 5) tft.drawFastVLine(x, 0, h, color2);

    return micros() - start;
}

unsigned long testRects(uint16_t color) {
    unsigned long start;
    int           n, i, i2,
                  cx = tft.width()  / 2,
                  cy = tft.height() / 2;

    tft.fillScreen(BLACK);
    n     = min(tft.width(), tft.height());
    start = micros();
    for (i = 2; i < n; i += 6) {
        i2 = i / 2;
        tft.drawRect(cx - i2, cy - i2, i, i, color);
    }

    return micros() - start;
}

unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
    unsigned long start, t = 0;
    int           n, i, i2,
                  cx = tft.width()  / 2 - 1,
                  cy = tft.height() / 2 - 1;

    tft.fillScreen(BLACK);
    n = min(tft.width(), tft.height());
    for (i = n; i > 0; i -= 6) {
        i2    = i / 2;
        start = micros();
        tft.fillRect(cx - i2, cy - i2, i, i, color1);
        t    += micros() - start;
        // Outlines are not included in timing results
        tft.drawRect(cx - i2, cy - i2, i, i, color2);
    }

    return t;
}

unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
    unsigned long start;
    int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;

    tft.fillScreen(BLACK);
    start = micros();
    for (x = radius; x < w; x += r2) {
        for (y = radius; y < h; y += r2) {
            tft.fillCircle(x, y, radius, color);
        }
    }

    return micros() - start;
}

unsigned long testCircles(uint8_t radius, uint16_t color) {
    unsigned long start;
    int           x, y, r2 = radius * 2,
                        w = tft.width()  + radius,
                        h = tft.height() + radius;

    // Screen is not cleared for this one -- this is
    // intentional and does not affect the reported time.
    start = micros();
    for (x = 0; x < w; x += r2) {
        for (y = 0; y < h; y += r2) {
            tft.drawCircle(x, y, radius, color);
        }
    }

    return micros() - start;
}

unsigned long testTriangles() {
    unsigned long start;
    int           n, i, cx = tft.width()  / 2 - 1,
                        cy = tft.height() / 2 - 1;

    tft.fillScreen(BLACK);
    n     = min(cx, cy);
    start = micros();
    for (i = 0; i < n; i += 5) {
        tft.drawTriangle(
            cx    , cy - i, // peak
            cx - i, cy + i, // bottom left
            cx + i, cy + i, // bottom right
            tft.color565(0, 0, i));
    }

    return micros() - start;
}

unsigned long testFilledTriangles() {
    unsigned long start, t = 0;
    int           i, cx = tft.width()  / 2 - 1,
                     cy = tft.height() / 2 - 1;

    tft.fillScreen(BLACK);
    start = micros();
    for (i = min(cx, cy); i > 10; i -= 5) {
        start = micros();
        tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
                         tft.color565(0, i, i));
        t += micros() - start;
        tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
                         tft.color565(i, i, 0));
    }

    return t;
}

unsigned long testRoundRects() {
    unsigned long start;
    int           w, i, i2, red, step,
                  cx = tft.width()  / 2 - 1,
                  cy = tft.height() / 2 - 1;

    tft.fillScreen(BLACK);
    w     = min(tft.width(), tft.height());
    start = micros();
    red = 0;
    step = (256 * 6) / w;
    for (i = 0; i < w; i += 6) {
        i2 = i / 2;
        red += step;
        tft.drawRoundRect(cx - i2, cy - i2, i, i, i / 8, tft.color565(red, 0, 0));
    }

    return micros() - start;
}

unsigned long testFilledRoundRects() {
    unsigned long start;
    int           i, i2, green, step,
                  cx = tft.width()  / 2 - 1,
                  cy = tft.height() / 2 - 1;

    tft.fillScreen(BLACK);
    start = micros();
    green = 256;
    step = (256 * 6) / min(tft.width(), tft.height());
    for (i = min(tft.width(), tft.height()); i > 20; i -= 6) {
        i2 = i / 2;
        green -= step;
        tft.fillRoundRect(cx - i2, cy - i2, i, i, i / 8, tft.color565(0, green, 0));
    }

    return micros() - start;
}

I change the define to match my screen and this is what I got.

#define LCD_CS 10 // Chip Select goes to Analog 3
//#define LCD_CD A2 // Command/Data goes to Analog 2
//#define LCD_WR A1 // LCD Write goes to Analog 1
//#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET 9 // Can alternately just connect to Arduino's reset pin
#define LCD_RS 8

Is there anything else that I'm missing? I have no clue.