TFT_eSPI represents every pixel color as a 16-bitDocumentation 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 in the RGB565 format. Understanding this encoding helps you work confidently with the predefined color constants, convert between color spaces, and handle transparency in sprites.
The RGB565 Color Format
RGB565 packs a full color into 16 bits by allocating:- 5 bits for Red (values 0 – 31, mapped to 0 – 255)
- 6 bits for Green (values 0 – 63, mapped to 0 – 255 — one extra bit because the human eye is most sensitive to green)
- 5 bits for Blue (values 0 – 31, mapped to 0 – 255)
Predefined Color Constants
TFT_eSPI ships with 25 ready-to-use color constants. All of them areint32_t values expressed as 16-bit RGB565 words.
| 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 section below |
TFT_TRANSPARENT Special Value
TFT_TRANSPARENT (0x0120) is a reserved sentinel color used with sprites. It is not a true color in the artistic sense — it is a carefully chosen 16-bit value that:
- Encodes to the same 8-bit representation when stored in an 8-bit sprite.
- Decodes back to the identical 16-bit value, making round-trips lossless.
- Visually appears as a very dark green, which is unlikely to clash with real UI content.
TFT_TRANSPARENT as the transparent color key, any pixel with this value is skipped rather than drawn, producing true sprite transparency without a dedicated alpha channel.
Use
TFT_TRANSPARENT only as a color key for sprite transparency. Avoid it as an intentional dark-green fill color, or transparency detection will misfire.Default 4-Bit Palette for Sprites
TFT_eSprite supports 4-bit (16-color) sprites using a fixed palette stored in flash as default_4bit_palette[]. The 16 entries follow the classic resistor color-code sequence for indices 0 – 9:
| Index | Color Constant | Notes |
|---|---|---|
0 | TFT_BLACK | Resistor color code start ↑ |
1 | TFT_BROWN | |
2 | TFT_RED | |
3 | TFT_ORANGE | |
4 | TFT_YELLOW | |
5 | TFT_GREEN | |
6 | TFT_BLUE | |
7 | TFT_PURPLE | |
8 | TFT_DARKGREY | Resistor color code end ↓ |
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 |
Color Conversion Functions
TFT_eSPI provides several helper methods for converting between color spaces. All are members of theTFT_eSPI class:
color565()
Convert 8-bit R, G, B components to a 16-bit RGB565 value.
color8to16()
Expand a packed 8-bit
RGB332 color to 16-bit RGB565.color16to24()
Convert a 16-bit
RGB565 value to a 24-bit RGB888 uint32_t.alphaBlend()
Alpha-blend a foreground color over a background color with an 8-bit alpha (0 = fully transparent, 255 = fully opaque).