If you are working with a 2.4 inch resistive TFT display that uses the ST7789V driver, the best library is the Adafruit ST7789 library combined with the Adafruit GFX library. This combination is the most widely used, well-documented, and actively maintained solution for driving 240x320 pixel resistive TFT displays. It supports both hardware SPI and software SPI, offers a rich set of graphics primitives, and is compatible with Arduino, ESP32, STM32, and many other platforms. The library is optimized for the ST7789V controller, which is the most common driver for these displays, and it handles the initialization sequence, color mapping (16-bit RGB565), and touch overlay integration with minimal overhead. For a plug-and-play experience, you can also use the TFT_eSPI library by Bodmer, which is faster and more flexible for advanced users, but the Adafruit pair remains the gold standard for beginners and intermediate projects due to its extensive tutorials and community support.
Let me break down the hardware specifics first. A typical 2.4 inch resistive TFT display, like the one found at 2.4 inch resistive tft display, uses the ST7789V driver IC, which supports a 240x320 pixel resolution with 262K colors (18-bit color depth, but usually driven in 16-bit RGB565 mode). The resistive touch panel is a 4-wire analog interface, separate from the display driver, and requires an ADC (like the one on an Arduino or ESP32) or a dedicated touch controller (like the XPT2046) to read the touch coordinates. The display module typically has a 14-pin or 16-pin interface, including pins for SPI (SCK, MOSI, MISO, CS, DC, RST), backlight (LED), and touch (T_IRQ, T_DO, T_DIN, T_CS, T_CLK). The resistive touch layer is not integrated into the ST7789V; it is a separate analog resistive film that requires a separate library for touch reading, such as the Adafruit TouchScreen library or the XPT2046_Touchscreen library.
Now, let’s dive into the library options. The Adafruit ST7789 library (version 1.10.1 as of early 2025) is built on top of the Adafruit GFX library, which provides a consistent API for drawing pixels, lines, rectangles, circles, text, and bitmaps. The library uses hardware SPI by default, which can achieve refresh rates of up to 60 FPS on a 240x320 display with an 80 MHz SPI clock on an ESP32. On an Arduino Uno (16 MHz), the SPI clock is limited to 8 MHz, resulting in a full-screen fill time of about 30 ms. The library supports both 4-wire and 3-wire SPI modes, and it includes a built-in initialization sequence for the ST7789V that sets the display to 240x320 mode, configures the color format, and adjusts the gamma curve for better contrast. The library also handles the MADCTL register for rotation (0°, 90°, 180°, 270°), which is critical for portrait or landscape orientation. The memory footprint is about 8 KB of flash and 200 bytes of RAM on an Arduino Uno, making it lightweight enough for most microcontrollers.
In contrast, the TFT_eSPI library (version 2.5.43) by Bodmer is a performance-oriented alternative. It is written in optimized C++ and uses direct register manipulation for the SPI transactions, which can double the frame rate compared to the Adafruit library. For example, on an ESP32 at 240 MHz, TFT_eSPI can achieve a full-screen fill in 8 ms using 80 MHz SPI, while Adafruit’s library takes about 15 ms. TFT_eSPI also includes a built-in sprite engine for double buffering, which is useful for animations or games. However, the library requires manual configuration of the pin assignments in a user setup file (User_Setup.h), which can be intimidating for beginners. It also supports the ST7789V driver, but it does not include a separate touch library; you need to combine it with a touch library like XPT2046_Touchscreen or TouchScreen. The memory footprint is larger, around 12 KB of flash and 300 bytes of RAM, but it offers more features like anti-aliased fonts and JPEG decoding.
For resistive touch integration, the Adafruit TouchScreen library (version 1.1.5) is the simplest option. It reads the 4-wire resistive touch panel by measuring the voltage on the X and Y axes using analog pins. The library requires calibration, which involves mapping the raw ADC values (typically 0-1023 on a 10-bit ADC) to the display coordinates (240x320). The calibration process involves reading the touch coordinates at the four corners of the display and computing a scaling factor. For example, if the raw X value at the left edge is 100 and at the right edge is 900, the scaling factor is 240 / (900 - 100) = 0.3. The library also includes a pressure threshold to filter out accidental touches. The XPT2046_Touchscreen library (version 1.4.0) is more advanced and uses a dedicated SPI touch controller IC (XPT2046) that is often integrated into the module. This library provides higher accuracy (12-bit resolution) and includes a built-in filtering algorithm to reduce noise. It also supports interrupt-driven touch detection, which is more efficient for battery-powered devices.
Let’s compare the libraries in a table:
| Library | Version | SPI Speed (max) | Full-screen fill time (ESP32, 80 MHz SPI) | Memory (Flash/RAM on Uno) | Touch support | Learning curve |
|---|---|---|---|---|---|---|
| Adafruit ST7789 + GFX | 1.10.1 / 1.11.9 | 80 MHz | 15 ms | 8 KB / 200 bytes | External (TouchScreen library) | Low |
| TFT_eSPI | 2.5.43 | 80 MHz | 8 ms | 12 KB / 300 bytes | External (XPT2046_Touchscreen) | Medium |
| MCUFRIEND_kbv | 2.9.9 | 40 MHz | 25 ms | 10 KB / 250 bytes | Built-in (touch calibration) | Medium |
The MCUFRIEND_kbv library is another option, but it is less optimized for the ST7789V specifically. It is designed for generic TFT displays and includes a touch calibration routine, but it lacks the performance and community support of the Adafruit or TFT_eSPI libraries. On an ESP32, the MCUFRIEND_kbv library can only achieve 40 MHz SPI, resulting in a full-screen fill time of 25 ms, which is 60% slower than TFT_eSPI. The library also has a larger code footprint and is less actively maintained, with the last update in 2023.
For real-world performance, consider the SPI clock speed. The ST7789V supports a maximum SPI clock of 80 MHz, but the actual speed depends on the microcontroller. On an Arduino Uno, the hardware SPI is limited to 8 MHz, so the full-screen fill time is about 30 ms with the Adafruit library and 25 ms with TFT_eSPI (due to optimized code). On an ESP32 at 240 MHz, the SPI clock can be set to 80 MHz, and the Adafruit library achieves 15 ms, while TFT_eSPI achieves 8 ms. The difference is due to TFT_eSPI’s use of DMA (Direct Memory Access) on the ESP32, which offloads the SPI transactions from the CPU. However, DMA is only available on certain microcontrollers like the ESP32 and STM32, not on the Arduino Uno.
Now, let’s talk about the resistive touch calibration. The resistive touch panel on a 2.4 inch display has a typical resolution of 1024x1024 (10-bit ADC), but the actual touch area is 240x320 pixels. The touch panel is linear, but the edges may have a nonlinear response due to the resistive film’s construction. The calibration process involves reading the touch coordinates at the four corners and computing a linear transformation. For example, if the raw X values range from 150 to 850, the scaling factor is 240 / (850 - 150) = 0.342. The Y values range from 200 to 800, with a scaling factor of 320 / (800 - 200) = 0.533. The Adafruit TouchScreen library includes a calibration function that stores these values in EEPROM, so you only need to calibrate once. The XPT2046_Touchscreen library has a similar calibration routine but uses a 12-bit ADC (0-4095), which provides finer resolution but requires more memory for the calibration data.
For power consumption, the display itself draws about 50 mA at full brightness (backlight on), and the touch panel draws about 1 mA when idle. The ST7789V driver has a sleep mode that reduces current to 5 µA, which is useful for battery-powered projects. The Adafruit library includes a sleep function (displaySleep()) that puts the display into low-power mode, while TFT_eSPI has a similar function (sleep()). The touch library does not affect power consumption significantly, but the XPT2046_Touchscreen library has a low-power mode that disables the touch controller when not in use.
Compatibility is another factor. The Adafruit ST7789 library works with Arduino, ESP32, ESP8266, STM32 (via the STM32duino core), and Teensy. It also supports the Raspberry Pi Pico (via the Arduino-Pico core). The TFT_eSPI library is compatible with the same platforms but also supports the ESP32-S3, ESP32-C3, and RP2040. The MCUFRIEND_kbv library is primarily for AVR-based Arduinos and may not work well with ESP32 or STM32 due to timing issues. For the 2.4 inch resistive TFT display, I recommend the Adafruit ST7789 library for most users because of its ease of use, extensive documentation, and active community. The library is available in the Arduino Library Manager, and you can install it with a single click. The TFT_eSPI library is better for advanced users who need maximum performance, but it requires manual configuration of the User_Setup.h file, which can be error-prone if you don’t know the pin assignments.
Let’s look at a typical wiring example for the 2.4 inch resistive TFT display with an Arduino Uno. The display module has 14 pins: VCC (5V), GND, CS (chip select), RESET, DC (data/command), MOSI, SCK, LED (backlight), and the touch pins (T_IRQ, T_DO, T_DIN, T_CS, T_CLK). The touch pins are connected to the analog pins on the Arduino for the 4-wire resistive touch (if no XPT2046 controller is present). The SPI pins are: MOSI to pin 11, SCK to pin 13, CS to pin 10, DC to pin 9, RESET to pin 8, LED to pin 6 (with a 220 ohm resistor). The touch pins are: T_IRQ to pin 2 (interrupt), T_DO to pin 12 (MISO), T_DIN to pin 11 (MOSI), T_CS to pin 7, T_CLK to pin 13 (SCK). If the module has an XPT2046 touch controller, the touch pins are connected to the hardware SPI pins, and you use the XPT2046_Touchscreen library instead of the TouchScreen library.
For the software setup, you need to include the libraries and initialize the display. The code for the Adafruit library looks like this: #include , #include , #include . Then, define the pins: #define TFT_CS 10, #define TFT_DC 9, #define TFT_RST 8. Create an instance: Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);. In the setup function, initialize the display: tft.init(240, 320);, set the rotation: tft.setRotation(1);, and fill the screen: tft.fillScreen(ST77XX_BLACK);. For the touch, include the TouchScreen library: #include , define the touch pins: #define YP A2, #define XM A3, #define YM 8, #define XP 9, and create an instance: TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);. The 300 is the resistance value for the touch panel, which you can adjust based on the module’s specifications.
For the TFT_eSPI library, the setup is different. You need to edit the User_Setup.h file to define the pins: #define TFT_CS 10, #define TFT_DC 9, #define TFT_RST 8, #define TFT_MOSI 11, #define TFT_SCLK 13, #define TFT_BL 6. Then, include the library: #include , create an instance: TFT_eSPI tft = TFT_eSPI();, and initialize: tft.init();, tft.setRotation(1);, tft.fillScreen(TFT_BLACK);. For touch, include the XPT2046_Touchscreen library: #include , define the touch CS pin: #define TOUCH_CS 7, create an instance: XPT2046_Touchscreen ts(TOUCH_CS);, and initialize: ts.begin();, ts.setRotation(1);. The XPT2046 library automatically handles the touch calibration, but you can also manually set the calibration values using the setCalibration() function.
Performance benchmarks show that the Adafruit library is sufficient for most applications, such as displaying sensor data, menus, or simple graphics. For example, drawing a 100x100 pixel rectangle takes 2 ms on an ESP32 with the Adafruit library, while TFT_eSPI takes 1.2 ms. Drawing text (e.g., a 20-character string) takes 5 ms with Adafruit and 3 ms with TFT_eSPI. The difference is noticeable in animations or real-time updates, but for static displays, it is negligible. The Adafruit library also supports the drawRGBBitmap() function for displaying images from a SD card, which is useful for GUI applications. The TFT_eSPI library has a pushImage() function that is faster for large images, but it requires the image data to be in 16-bit RGB565 format.
For the resistive touch accuracy, the XPT2046 library provides better precision than the TouchScreen library. The XPT2046 has a 12-bit ADC, which gives 4096 possible values per axis, compared to the 10-bit ADC (1024 values) on the Arduino. The XPT2046 also includes a built-in voltage reference and a low-pass filter, which reduces noise from the resistive film. The typical touch accuracy is within 2 pixels for the XPT2046, while the TouchScreen library can have errors of up to 5 pixels due to the analog noise. The XPT2046 library also supports multi-touch (two fingers) on some resistive panels, but this is rare on 2.4 inch displays. The touch response time is about 10 ms for the XPT2046 and 20 ms for the TouchScreen library, due to the software filtering in the latter.
Now, let’s discuss the display’s color accuracy. The ST7789V driver supports 18-bit color (262K colors), but the Adafruit library uses 16-bit RGB565 (65K colors) by default. This is because the library maps the 18-bit color space to 16-bit by dropping the two least significant bits for each color channel. The result is a slight loss of color depth, but it is not noticeable to the human eye. The TFT_eSPI library also uses 16-bit color, but it includes a gamma correction function that improves the color accuracy for certain display modules. The gamma correction adjusts the brightness curve of the LED backlight