Colour Functions - Ambercroft/TFT_eSPI GitHub Wiki

Colour functions

setTextColor(uint_16 FG, uint_16 BG);

  • FG >> FOREGROUND required
  • BG >> BACKGROUND optional Adding background colour overwrites existing text automatically

pushColor(uint16_t COLOUR, uint32_t LEN);

Push a single pixel.

  • COLOUR >> Standard colour.
  • LEN >> Optional push to more than one pixel.

pushColors(uint16_t *data, uint32_t LEN, bool SWAP);

Push an array of pixels. Assumed that setAddrWindow() has been called.

  • *data >> Array
  • LEN >> Number of bytes.
  • SWAP >> Optional byte order ??
    REF setAddrWindow()

writeColor() KEYWORD2

color565(R,G,B); ?

  • 5 bits for Red from #FF
  • 6 bits for Green from #FF
  • 5 bits for Blue from #FF

color8to16(uint_8 COLOUR);

Convert 8 bit colour to 16 bit.

  • 8 Bits > 3 bits red, 3 bits green, 2 bits blue
  • 16 Bits > 5 bits red, 6 bits green, 5 bits blue

color16to8(uint_16 COLOUR);

Convert 16 bit colour to 8 bit.

  • 8 Bits > 3 bits red, 3 bits green, 2 bits blue
  • 16 Bits > 5 bits red, 6 bits green, 5 bits blue

color16to24(uint_16 COLOUR);

Convert 16 bit colour to 24 bit.

  • 16 Bits > 5 bits red, 6 bits green, 5 bits blue
  • 24 Bits > 8 bits red, 8 bits green, 8 bits blue

color24to16(uint_32 COLOUR); ?? Does this handle Alpha ??

Convert 24 bit colour to 16 bit.

  • 16 Bits > 5 bits red, 6 bits green, 5 bits blue
  • 24 Bits > 8 bits red, 8 bits green, 8 bits blue

alphaBlend(int a, uint_16 FG, uint_16 BG);

  • a >> Alpha 0 = 100% Background, 255 = 100% Forground
  • FG >> Foreground colour
  • BG >> Background colour

alphaBlend24(int a, uint_32 FG, uint_32 BG);

  • a >> Alpha 0 = 100% Background, 255 = 100% Forground
  • FG >> Foreground colour
  • BG >> Background colour

Colours

Predefined

  1. Insert in Alphabetical order.
  2. Put modified colours ie. 'dark' with base colour.

Default colour definitions

  • TFT_BLACK 0x0000 /* 0, 0, 0 */

  • TFT_BLUE 0x001F /* 0, 0, 255 */

  • TFT_SKYBLUE 0x867D /* 135, 206, 235 */

  • TFT_BROWN 0x9A60 /* 150, 75, 0 */

  • TFT_CYAN 0x07FF /* 0, 255, 255 */

  • TFT_DARKCYAN 0x03EF /* 0, 128, 128 */

  • TFT_GOLD 0xFEA0 /* 255, 215, 0 */

  • TFT_GREEN 0x07E0 /* 0, 255, 0 */

  • TFT_GREENYELLOW 0xB7E0 /* 180, 255, 0 */

  • TFT_DARKGREY 0x7BEF /* 128, 128, 128 */

  • TFT_LIGHTGREY 0xD69A /* 211, 211, 211 */

  • TFT_DARKGREEN 0x03E0 /* 0, 128, 0 */

  • TFT_MAGENTA 0xF81F /* 255, 0, 255 */

  • TFT_MAROON 0x7800 /* 128, 0, 0 */

  • TFT_NAVY 0x000F /* 0, 0, 128 */

  • TFT_OLIVE 0x7BE0 /* 128, 128, 0 */

  • TFT_ORANGE 0xFDA0 /* 255, 180, 0 */

  • TFT_PINK 0xFE19 /* 255, 192, 203 */ //Lighter pink, was 0xFC9F

  • TFT_PURPLE 0x780F /* 128, 0, 128 */

  • TFT_RED 0xF800 /* 255, 0, 0 */

  • TFT_SILVER 0xC618 /* 192, 192, 192 */

  • TFT_VIOLET 0x915C /* 180, 46, 226 */

  • TFT_WHITE 0xFFFF /* 255, 255, 255 */

  • TFT_YELLOW 0xFFE0 /* 255, 255, 0 */

  • TFT_GREY ?

User defined < From code : Verify before use >

  • #define NAME 0x0000
  • 0x0000 >> BLACK
  • 0x1F00 >> BLUE
  • 0x38E0 >> BROWN
  • 0x79E0 >> BROWN ish?
  • 0x7FF0 >> CYAN
  • 0x5AEB >> GRAY
  • 0x7BEF >> GRAY DARK
  • 0xBDF7 >> GRAY LIGHT
  • 0x7E00 >> GREEN
  • 0xFBE0 >> ORANGE
  • 0xF81F >> PINK
  • 0xF800 >> RED
  • 0xFFFF >> WHITE
  • 0xFFE0 >> YELLOW

SORT ME

Put function here if uncertain the position to be placed on page.

` // Next is a special 16 bit colour value that encodes to 8 bits // and will then decode back to the same 16 bit value. // Convenient for 8 bit and 16 bit transparent sprites. #define TFT_TRANSPARENT 0x0120 // This is actually a dark green

// Default palette for 4 bit colour sprites
static const uint16_t default_4bit_palette[] PROGMEM = {
TFT_BLACK, // 0 ^
TFT_BROWN, // 1 |
TFT_RED, // 2 |
TFT_ORANGE, // 3 |
TFT_YELLOW, // 4 Colours 0-9 follow the resistor colour code!
TFT_GREEN, // 5 |
TFT_BLUE, // 6 |
TFT_PURPLE, // 7 |
TFT_DARKGREY, // 8 |
TFT_WHITE, // 9 v
TFT_CYAN, // 10 Blue+green mix
TFT_MAGENTA, // 11 Blue+red mix
TFT_MAROON, // 12 Darker red colour
TFT_DARKGREEN,// 13 Darker green colour
TFT_NAVY, // 14 Darker blue colour
TFT_PINK // 15
`