TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Marcussacapuces91/doc-TFT_eSPI/llms.txt
Use this file to discover all available pages before exploring further.
TFT_eSPI class is a hardware-accelerated TFT graphics library targeting ESP8266, ESP32, RP2040, and STM32 boards. It provides a comprehensive set of drawing primitives, text rendering, color utilities, viewport clipping, and DMA-assisted pixel pushing — all in a single unified class. The current release is identified by the constant TFT_ESPI_VERSION "2.5.43", and the library’s feature flag TFT_ESPI_FEATURES 1 signals that viewport/clipping capability is compiled in.
TFT_eSPI inherits from the Arduino Print class, which means the familiar print() and println() methods are available for streaming text to the display at the current cursor position, in addition to the purpose-built draw string methods. TFT_eSprite is declared as a friend class and shares internal state for off-screen sprite rendering.
Library Constants
Key Public Member Variables
| Variable | Type | Description |
|---|---|---|
textcolor | uint32_t | Current text foreground colour |
textbgcolor | uint32_t | Current text background colour |
bitmap_fg | uint32_t | Bitmap foreground colour (bit = 1) |
bitmap_bg | uint32_t | Bitmap background colour (bit = 0) |
textfont | uint8_t | Currently selected font number |
textsize | uint8_t | Current font size multiplier |
textdatum | uint8_t | Text reference datum (alignment) |
rotation | uint8_t | Display rotation (0–3) |
DMA_Enabled | bool | true when DMA transfers are active |
API Method Groups
Constructor & Init
Construct the TFT object, call
begin() or init(), set rotation, retrieve setup diagnostics, and verify the setup ID.Drawing Shapes
Draw outlines of pixels, lines, rectangles, circles, ellipses, triangles, arcs, bitmaps, and anti-aliased smooth shapes.
Filling Shapes
Fill the screen or any closed shape — rectangles, rounded rectangles, circles, ellipses, triangles — including gradient fills.
Text Methods
Render strings, characters, numbers, and floats; configure fonts, text size, colour, datum, padding, and wrapping.
Color & Pixel
Read pixels, convert between RGB colour spaces, alpha-blend colours, push images and pixel buffers to the display.
Cursor & Rotation
Manage the text cursor position, display rotation, drawing origin, colour push helpers, and SPI transaction control.
Viewport & Window
Define viewport clipping regions, draw frame borders, set low-level address windows, and clip draw commands.
setup_t Structure
Thesetup_t structure can be populated by calling getSetup() and is useful for diagnostic sketches to inspect the compiled library configuration at runtime.
Predefined Color Constants
TFT_eSPI ships with a palette of ready-to-use RGB565 colour constants:Text Datum Constants
Use these withsetTextDatum() to control text alignment relative to the x, y coordinate passed to draw functions:
| Constant | Value | Description |
|---|---|---|
TL_DATUM | 0 | Top left (default) |
TC_DATUM | 1 | Top centre |
TR_DATUM | 2 | Top right |
ML_DATUM | 3 | Middle left |
MC_DATUM | 4 | Middle centre |
MR_DATUM | 5 | Middle right |
BL_DATUM | 6 | Bottom left |
BC_DATUM | 7 | Bottom centre |
BR_DATUM | 8 | Bottom right |
L_BASELINE | 9 | Left character baseline |
C_BASELINE | 10 | Centre character baseline |
R_BASELINE | 11 | Right character baseline |