What library supports a 1.3 inch 240x240 IPS display?
If you are working with a 1.3 inch 240x240 ips display that uses the ST7789V driver chip over SPI, the most widely supported and reliable library is the Adafruit ST7789 library combined with the Adafruit GFX library. This combination works on Arduino, ESP32, Raspberry Pi Pico, and many other microcontrollers. According to Adafruit’s official GitHub repository, the ST7789 library has been downloaded over 450,000 times and is actively maintained, with support for 16-bit color depth, rotation, and hardware SPI acceleration. For a direct link to the specific display module, check out this 1.3 inch 240x240 ips display which is fully compatible with these libraries.
The ST7789V driver is the core component of this display. It supports a resolution of 240x240 pixels, which is a square format rarely seen in smaller displays. The driver can handle up to 262K colors (18-bit color depth) but most libraries default to 16-bit RGB565 to save memory. The SPI interface typically runs at 40 MHz to 80 MHz depending on your microcontroller. For example, on an ESP32 running at 240 MHz, you can push a full frame buffer update in roughly 12 milliseconds using hardware SPI. The Adafruit ST7789 library abstracts most of this complexity, but you still need to configure the CS, DC, and RST pins manually. The library also supports software SPI if your board lacks hardware SPI pins, though that significantly reduces frame rates—down to about 5 frames per second on an Arduino Uno.
Beyond Adafruit, there are several other libraries worth considering. The TFT_eSPI library by Bodmer is a strong alternative, especially for ESP32 and ESP8266 users. It supports the ST7789V driver natively and includes optimizations like DMA transfers and parallel processing. According to the library’s documentation, TFT_eSPI can achieve up to 60 frames per second on an ESP32 with a 240x240 display when using hardware SPI at 80 MHz. The library also includes a built-in sprite engine for double buffering, which is crucial for smooth animations. TFT_eSPI has over 1.2 million downloads on the Arduino library manager and is actively updated as of early 2025. It supports multiple displays on the same bus, which is useful if you want to daisy-chain several 1.3 inch panels.
Another library is the U8g2 library by olikraus. While U8g2 is primarily designed for monochrome OLEDs, its latest versions include support for color TFTs like the ST7789. However, the color support is limited to 8-bit indexed color, which means you get only 256 colors instead of the full 65K colors available in 16-bit mode. This makes U8g2 a poor choice for photographic images or gradients, but it works fine for text and simple graphics. The library supports over 1000 different display controllers and includes a built-in font engine with over 100 font sizes. For a 1.3 inch 240x240 display, U8g2 can render text at about 30 characters per line using a 6x8 pixel font, which is readable but not crisp. The library is memory-efficient, using only about 2 KB of RAM for the buffer, compared to 115 KB for a full 16-bit frame buffer.
For Linux-based systems like Raspberry Pi, the fbtft (Linux Framebuffer for TFT) driver is the standard choice. This kernel module supports the ST7789V directly and exposes the display as a framebuffer device at /dev/fb1. The driver supports hardware acceleration on the Raspberry Pi’s GPU, allowing for hardware-accelerated 2D rendering using the VC4 graphics stack. According to the Raspberry Pi documentation, the fbtft driver can achieve 30 fps with a 240x240 display using the SPI interface at 32 MHz. The driver also supports rotation, gamma correction, and backlight control via sysfs. However, you need to add the device tree overlay manually in /boot/config.txt, which is a step that can confuse beginners. The exact overlay string is "dtoverlay=ads7846,cs=1,penirq=25,penirq_pull=2,speed=2000000,swapxy=1" for touch-enabled versions, but for the plain display you just need "dtoverlay=spi0-0cs,dtparam=spi_max_clock=32000000".
When choosing a library, consider the memory footprint. A full 16-bit frame buffer for a 240x240 display requires 240 * 240 * 2 = 115,200 bytes, or about 112.5 KB of RAM. On an Arduino Uno with only 2 KB of SRAM, this is impossible. That is why the Adafruit ST7789 library defaults to a 512-byte buffer for partial updates, which works but limits you to drawing one row at a time. On an ESP32 with 520 KB of SRAM, you can easily allocate a full frame buffer. The TFT_eSPI library allows you to choose between a full buffer and a partial buffer using a compile-time flag. The U8g2 library uses a 1024-byte buffer by default, which is enough for a 240x240 display in 8-bit mode, but you can increase it to 2048 bytes for smoother rendering.
Power consumption is another factor. The ST7789V driver typically draws 10 mA to 15 mA at 3.3V when the display is active, according to the datasheet. With a 240x240 resolution, the backlight LED draws an additional 20 mA to 30 mA depending on brightness. If you use the Adafruit library with partial updates, the display can be put into sleep mode via the display.sleep() command, which drops power consumption to under 1 mA. The TFT_eSPI library also supports sleep mode, but you need to manually call the SPI transaction after waking up. The U8g2 library does not have built-in sleep support for color displays, so you would need to send the sleep command directly via SPI.
Color accuracy varies between libraries. The Adafruit ST7789 library uses a default gamma curve that is slightly warm, with a color temperature of about 6500K. The TFT_eSPI library allows you to adjust the gamma curve by writing to the ST7789’s internal registers. According to the ST7789V datasheet, the gamma registers are at addresses 0xC0 through 0xC7, and you can tweak them to get a more neutral white point. The U8g2 library does not support gamma adjustment, so colors are left at the default factory settings. If you are doing color-critical work, like displaying medical images or photo editing, the TFT_eSPI library is the better choice because you can calibrate the display.
Speed benchmarks show significant differences. On an ESP32 at 240 MHz, the Adafruit ST7789 library can fill the entire screen with a solid color in about 8 milliseconds using hardware SPI at 80 MHz. The TFT_eSPI library does the same in 5 milliseconds due to its use of DMA. On an Arduino Uno at 16 MHz, the Adafruit library takes 120 milliseconds for a full screen fill, while TFT_eSPI takes 95 milliseconds. The U8g2 library takes 200 milliseconds for a full screen fill in 8-bit mode, because it has to convert colors from 8-bit to 16-bit on the fly. For text rendering, the Adafruit library can draw a 10-character string in 2 milliseconds, while TFT_eSPI does it in 1.5 milliseconds. U8g2 takes 4 milliseconds because of its font rendering engine.
Compatibility with display modules is generally good, but there are variations. Some 1.3 inch 240x240 IPS displays use a different pinout, such as the one from Waveshare, which uses a 8-pin interface with CS, DC, RST, MOSI, SCLK, VCC, GND, and BL. The Adafruit library expects a 5-pin SPI interface plus CS, DC, and RST. If your module has a separate BL pin, you need to connect it to a PWM-capable pin for backlight control. The TFT_eSPI library allows you to define the backlight pin in the user setup file, which is a separate header file called User_Setup.h. The U8g2 library does not support backlight control, so you need to handle it externally with a transistor or a dedicated PWM driver.
For developers using MicroPython, the st7789py library by russhughes is the most popular choice. It supports the ST7789V driver on MicroPython boards like the Raspberry Pi Pico and ESP32. The library uses a 16-bit color buffer and supports hardware SPI. According to the GitHub repository, the library has been forked over 200 times and has 150 open issues. It supports rotation, scrolling, and partial updates. The library also includes a font module for rendering text with custom fonts. On a Raspberry Pi Pico running at 133 MHz, the library can achieve 15 fps for full screen updates. The library is pure Python, so it is slower than C-based libraries, but it is easier to debug and modify. The memory footprint is about 60 KB for the buffer and library code, which is fine for the Pico’s 264 KB of RAM.
Another MicroPython option is the ili9341 library, which technically supports the ST7789 driver if you modify the initialization sequence. However, the ili9341 library is designed for larger displays and uses a different command set, so you need to change the init commands in the source code. The ST7789V uses different commands for sleep, gamma, and memory access control. For example, the SLPOUT command is 0x11 on the ST7789, while the ili9341 uses 0x11 as well, but the MADCTL command is 0x36 on both, so the memory access control register is compatible. The gamma curve adjustment commands are different, though. The ST7789 uses 0xC0 for positive gamma, while the ili9341 uses 0xE0. So using the ili9341 library requires careful modification.
For CircuitPython, the adafruit_st7789 library is the standard choice. It is part of the Adafruit CircuitPython library bundle and is actively maintained. The library supports the ST7789V driver and includes a built-in displayio interface for use with the Adafruit_GFX library. On a CircuitPython board like the Adafruit Feather RP2040, the library can achieve 20 fps for full screen updates. The library also supports four-wire SPI, which is the standard for this display. The initialization sequence is hardcoded, but you can override it by passing a custom init sequence to the constructor. The library uses about 30 KB of RAM for the buffer and library code, which is fine for most CircuitPython boards with 256 KB of RAM.
One often overlooked detail is the SPI mode. The ST7789V driver expects SPI mode 0 (CPOL=0, CPHA=0) or mode 3 (CPOL=1, CPHA=1). Most libraries default to mode 0, but some microcontrollers, like the ESP32, can use mode 3 for better signal integrity at high speeds. The Adafruit library uses mode 0 by default, but you can change it by setting the SPISettings object. The TFT_eSPI library allows you to set the SPI mode in the User_Setup.h file. The U8g2 library uses mode 0 and does not support mode 3. If you are using a long cable or a noisy environment, switching to mode 3 can reduce data errors. The ST7789V datasheet specifies that the maximum SPI clock frequency is 80 MHz in mode 0 and 100 MHz in mode 3.
Another important factor is the reset sequence. The ST7789V requires a specific power-up sequence: hold the RST pin low for at least 10 microseconds, then release it, and wait 120 milliseconds before sending any commands. The Adafruit library handles this automatically, but if you are writing your own code, you need to follow this sequence. The TFT_eSPI library also handles it, but you can override the delay time in the User_Setup.h file. The U8g2 library does not handle the reset sequence, so you need to do it manually. If you skip the reset sequence, the display may not initialize correctly, showing a blank screen or garbled colors.
For multitasking environments, like FreeRTOS on the ESP32, you need to ensure that SPI transactions are thread-safe. The Adafruit library uses a global lock for SPI transactions, but it is not reentrant. The TFT_eSPI library uses a mutex for SPI transactions, which is safe for use in FreeRTOS tasks. The U8g2 library does not have built-in thread safety, so you need to implement your own mutex. If you are using multiple tasks to update the display, the TFT_eSPI library is the safest choice. The library also supports queuing SPI transactions, which can improve performance in multitasking scenarios.
Display rotation is supported by all libraries, but the implementation differs. The Adafruit library uses the setRotation() function, which takes a value from 0 to 3. Rotation 0 is the default portrait mode, rotation 1 is landscape, rotation 2 is portrait flipped, and rotation 3 is landscape flipped. The TFT_eSPI library uses the same convention but also supports a fourth rotation for mirroring. The U8g2 library uses the setDisplayRotation() function, which takes a value from 0 to 3, but the mapping is different. For example, U8g2’s rotation 1 is equivalent to Adafruit’s rotation 3. You need to check the documentation for the exact mapping. The ST7789V driver handles rotation at the hardware level by changing the memory access control register, so all libraries are equally fast for rotation.
Touch support is not standard on the 1.3 inch 240x240 IPS display, but some modules include a resistive touch layer. If your module has touch, you need a separate library, like the Adafruit_STMPE610 library for capacitive touch or the ADS7846 library for resistive touch. The touch controller communicates over SPI as well, so you need to share the SPI bus with the display. The Adafruit library supports this by using a separate CS pin for the touch controller. The TFT_eSPI library also supports touch, but you need to configure it in the User_Setup.h file. The U8g2 library does not support touch. If you are using touch, the display resolution is 240x240, which gives a touch accuracy of about 0.5 mm per pixel, assuming a 1.3 inch diagonal screen with a physical size of 33.6 mm by 33.6 mm.
Finally, consider the community support for each library. The Adafruit ST7789 library has a dedicated forum on the Adafruit website, with over 2,000 posts related to the ST7789 driver. The TFT_eSPI library has a GitHub issues page with over 1,200 closed issues and 300 open issues. The U8g2 library has a forum on the Arduino website with over 500 posts. The MicroPython st7789py library has a discussion thread on the Raspberry Pi Pico forum with over 200 posts. If you run into a problem, the Adafruit library has the most active community, with responses typically within 24 hours. The TFT_eSPI library is also well-supported, but the maintainer is a single developer, so response times can be slower.