Arduino TFT 128X160 display (ST7735) Red-Blue color fix

If you have a clone LCD SPI TFT 128X160 display (ST7735) from “wide.hk” or others, you may have noticed that the red and blue colour channels are reversed!

FYI, this display is essentially the same as the “official” Arduino TFT display used on the Esplora, and can be used on any Arduino board. See: http://arduino.cc/en/Guide/TFTtoBoards

The “wide.hk” board is very inexpensive and quite nice, but the colour swap makes it awkward to use, and the pinout labeling is non-standard (just use their hook-up chart)

Apparently, the colour-swap is a fairly common occurrence, and some developers have adapted Raspberry Pi and other libraries to account for this, but the “TFT” library in Arduino 1.0.5 does not.

Luckily, it’s an easy fix, you only need to make one minor change to one of the library files. Find this file: arduino-1.0.5\libraries\TFT\utility\Adafruit_GFX.cpp

Line 478 should read:

uint16_t Adafruit_GFX::newColor(uint8_t r, uint8_t g, uint8_t b)

change to:

uint16_t Adafruit_GFX::newColor(uint8_t b, uint8_t g, uint8_t r)

Notice that all you’re doing is swapping the “b” and “r” positions.

Comments are closed.