TFT_eSPI 预设颜色备查
TFT_eSPI 中的预定义色彩
// Default color definitions
#define TFT_BLACK 0x0000 /* 0, 0, 0 */
#define TFT_NAVY 0x000F /* 0, 0, 128 */
#define TFT_DARKGREEN 0x03E0 /* 0, 128, 0 */
#define TFT_DARKCYAN 0x03EF /* 0, 128, 128 */
#define TFT_MAROON 0x7800 /* 128, 0, 0 */
#define TFT_PURPLE 0x780F /* 128, 0, 128 */
#define TFT_OLIVE 0x7BE0 /* 128, 128, 0 */
#define TFT_LIGHTGREY 0xD69A /* 211, 211, 211 */
#define TFT_DARKGREY 0x7BEF /* 128, 128, 128 */
#define TFT_BLUE 0x001F /* 0, 0, 255 */
#define TFT_GREEN 0x07E0 /* 0, 255, 0 */
#define TFT_CYAN 0x07FF /* 0, 255, 255 */
#define TFT_RED 0xF800 /* 255, 0, 0 */
#define TFT_MAGENTA 0xF81F /* 255, 0, 255 */
#define TFT_YELLOW 0xFFE0 /* 255, 255, 0 */
#define TFT_WHITE 0xFFFF /* 255, 255, 255 */
#define TFT_ORANGE 0xFDA0 /* 255, 180, 0 */
#define TFT_GREENYELLOW 0xB7E0 /* 180, 255, 0 */
#define TFT_PINK 0xFE19 /* 255, 192, 203 */
#define TFT_BROWN 0x9A60 /* 150, 75, 0 */
#define TFT_GOLD 0xFEA0 /* 255, 215, 0 */
#define TFT_SILVER 0xC618 /* 192, 192, 192 */
#define TFT_SKYBLUE 0x867D /* 135, 206, 235 */
#define TFT_VIOLET 0x915C /* 180, 46, 226 */
TFT_eSPI RGB565 色彩模式
例如 蓝色 TFT_BLUE 对应色彩为四位16进制数 0x001F
TFT_eSPI 库使用 RGB565 色彩模式:其中 R 原色占用 5 bit ,G 原色占用 6 bit , B 原色占用 5 bit,即每像素点占用 5 + 6 + 5 = 16 bit ,对应一个 四位16进制数。
正常 RGB888 色彩模式
正常 RGB 由 R、G、B 各 8 位,一共 24 位 3 字节大小表示。
每字节占 8 bit,正好对应 0~255 的范围。
RGB888 与 RGB565 的转化
转换函数 color565() 定义如下:
uint16_t color565(uint8_t red, uint8_t green, uint8_t blue);
使用示例:
uint16_t red = tft.color565(255, 0, 0);
uint16_t green = tft.color565(0, 255, 0);
uint16_t blue = tft.color565(0, 0, 255);
uint16_t yellow = tft.color565(255, 255, 0);
其中(255,0,0)为正常 RGB 数值,tft 为对象名

颜色备查(自用)
浙公网安备 33010602011771号