Skip to main content

Documentation 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 represents colors as 16-bit RGB565 values. In this encoding, the upper 5 bits hold red (0–31), the middle 6 bits hold green (0–63), and the lower 5 bits hold blue (0–31). Because the human eye is most sensitive to green, it receives the extra bit. A raw uint16_t value such as 0xF800 therefore means pure red: 11111 000000 00000 in binary. TFT_eSPI ships with 25 named color constants covering the most common UI colors, so you rarely need to calculate raw hex values yourself.

Named color constants

The table below lists every constant defined in TFT_eSPI.h, its 16-bit hexadecimal value, and the approximate 8-bit per-channel RGB components that the value encodes.
ConstantHex valueRedGreenBlueNotes
TFT_BLACK0x0000000
TFT_NAVY0x000F00128
TFT_DARKGREEN0x03E001280
TFT_DARKCYAN0x03EF0128128
TFT_MAROON0x780012800
TFT_PURPLE0x780F1280128
TFT_OLIVE0x7BE01281280
TFT_LIGHTGREY0xD69A211211211
TFT_DARKGREY0x7BEF128128128
TFT_BLUE0x001F00255
TFT_GREEN0x07E002550
TFT_CYAN0x07FF0255255
TFT_RED0xF80025500
TFT_MAGENTA0xF81F2550255
TFT_YELLOW0xFFE02552550
TFT_WHITE0xFFFF255255255
TFT_ORANGE0xFDA02551800
TFT_GREENYELLOW0xB7E01802550
TFT_PINK0xFE19255192203Lighter pink (was 0xFC9F)
TFT_BROWN0x9A60150750
TFT_GOLD0xFEA02552150
TFT_SILVER0xC618192192192
TFT_SKYBLUE0x867D135206235
TFT_VIOLET0x915C18046226
TFT_TRANSPARENT0x0120Special value — see below

TFT_TRANSPARENT

TFT_TRANSPARENT (0x0120) is a special sentinel value chosen because it round-trips cleanly between 8-bit and 16-bit color representations. When TFT_eSPI converts a 16-bit color down to 8 bits for indexed-color sprites and then expands it back to 16 bits, most values do not survive the trip exactly. 0x0120 is mathematically guaranteed to encode and decode to the same value, making it a reliable marker for “this pixel should be transparent.” The color itself renders as a very dark green, which is rarely found in real UI artwork and therefore safe to use as a chroma-key.
// Create a sprite with transparent background
TFT_eSprite spr = TFT_eSprite(&tft);
spr.createSprite(60, 30);
spr.fillSprite(TFT_TRANSPARENT);   // mark all pixels transparent
// … draw only the parts you want visible …
spr.pushSprite(x, y, TFT_TRANSPARENT); // skip transparent pixels on push

Default 4-bit palette for color sprites

4-bit sprites store a palette index (0–15) per pixel rather than a full color value, keeping memory usage low. TFT_eSPI defines a default 16-entry palette in default_4bit_palette[]. Indices 0–9 follow the resistor color code (black, brown, red, orange, yellow, green, blue, purple/violet, grey, white), making the mapping easy to memorise.
static const uint16_t default_4bit_palette[];
IndexColor constantNotes
0TFT_BLACK↑ Resistor color code (indices 0–9)
1TFT_BROWN
2TFT_RED
3TFT_ORANGE
4TFT_YELLOW
5TFT_GREEN
6TFT_BLUE
7TFT_PURPLE↓ Resistor color code (indices 0–9)
8TFT_DARKGREY
9TFT_WHITE
10TFT_CYANBlue + green mix
11TFT_MAGENTABlue + red mix
12TFT_MAROONDarker red
13TFT_DARKGREENDarker green
14TFT_NAVYDarker blue
15TFT_PINK
You can supply a custom palette array when calling pushSprite() on a 4-bit sprite. The default palette only applies when no custom palette is specified.

Creating custom colors with color565()

When you need a color not in the predefined list, use the static helper TFT_eSPI::color565() to convert standard 8-bit-per-channel RGB values into the 16-bit RGB565 format:
// Syntax
uint16_t TFT_eSPI::color565(uint8_t r, uint8_t g, uint8_t b);

// Examples
uint16_t coral     = tft.color565(255, 127, 80);
uint16_t teal      = tft.color565(0,   128, 128);
uint16_t lavender  = tft.color565(230, 230, 250);

tft.fillScreen(coral);
tft.drawString("Hello!", 10, 10, 4);
Because RGB565 has only 5 or 6 bits per channel, the converted value is a close approximation of the requested color, not an exact match. color565(255, 128, 0) and color565(255, 132, 0) may produce the same 16-bit output.

Build docs developers (and LLMs) love