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 rawDocumentation 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.
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 inTFT_eSPI.h, its 16-bit hexadecimal value, and the approximate 8-bit per-channel RGB components that the value encodes.
| Constant | Hex value | Red | Green | Blue | Notes |
|---|---|---|---|---|---|
TFT_BLACK | 0x0000 | 0 | 0 | 0 | |
TFT_NAVY | 0x000F | 0 | 0 | 128 | |
TFT_DARKGREEN | 0x03E0 | 0 | 128 | 0 | |
TFT_DARKCYAN | 0x03EF | 0 | 128 | 128 | |
TFT_MAROON | 0x7800 | 128 | 0 | 0 | |
TFT_PURPLE | 0x780F | 128 | 0 | 128 | |
TFT_OLIVE | 0x7BE0 | 128 | 128 | 0 | |
TFT_LIGHTGREY | 0xD69A | 211 | 211 | 211 | |
TFT_DARKGREY | 0x7BEF | 128 | 128 | 128 | |
TFT_BLUE | 0x001F | 0 | 0 | 255 | |
TFT_GREEN | 0x07E0 | 0 | 255 | 0 | |
TFT_CYAN | 0x07FF | 0 | 255 | 255 | |
TFT_RED | 0xF800 | 255 | 0 | 0 | |
TFT_MAGENTA | 0xF81F | 255 | 0 | 255 | |
TFT_YELLOW | 0xFFE0 | 255 | 255 | 0 | |
TFT_WHITE | 0xFFFF | 255 | 255 | 255 | |
TFT_ORANGE | 0xFDA0 | 255 | 180 | 0 | |
TFT_GREENYELLOW | 0xB7E0 | 180 | 255 | 0 | |
TFT_PINK | 0xFE19 | 255 | 192 | 203 | Lighter pink (was 0xFC9F) |
TFT_BROWN | 0x9A60 | 150 | 75 | 0 | |
TFT_GOLD | 0xFEA0 | 255 | 215 | 0 | |
TFT_SILVER | 0xC618 | 192 | 192 | 192 | |
TFT_SKYBLUE | 0x867D | 135 | 206 | 235 | |
TFT_VIOLET | 0x915C | 180 | 46 | 226 | |
TFT_TRANSPARENT | 0x0120 | — | — | — | Special 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.
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 indefault_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.
| Index | Color constant | Notes |
|---|---|---|
| 0 | TFT_BLACK | ↑ Resistor color code (indices 0–9) |
| 1 | TFT_BROWN | |
| 2 | TFT_RED | |
| 3 | TFT_ORANGE | |
| 4 | TFT_YELLOW | |
| 5 | TFT_GREEN | |
| 6 | TFT_BLUE | |
| 7 | TFT_PURPLE | ↓ Resistor color code (indices 0–9) |
| 8 | TFT_DARKGREY | |
| 9 | TFT_WHITE | |
| 10 | TFT_CYAN | Blue + green mix |
| 11 | TFT_MAGENTA | Blue + red mix |
| 12 | TFT_MAROON | Darker red |
| 13 | TFT_DARKGREEN | Darker green |
| 14 | TFT_NAVY | Darker blue |
| 15 | TFT_PINK |
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:
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.