9 years, 3 months ago.

Red/Blue seem to be swapped...user error?

Hi Chris,

I'm using your library with my Outrageous Circuits RETRO game console, which includes the DisplayN18 display module, which uses the ST7735 controller. After a bit of confusion on my part in terms of updating the initialization, I got it working well with displaying rectangles and text. I also got some bitmaps to display, using code like the following:

bitmap code

static const uint16_t shipBmp[] = {8, 8, Color565::Black, Color565::Black, Color565::Black, Color565::Red, Color565::Red, Color565::Black, Color565::Black, Color565::Black, Color565::Black, Color565::Black, Color565::Black, Color565::Red, Color565::Red, Color565::Black, Color565::Black, Color565::Black, Color565::Black, Color565::Black, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Black, Color565::Black, Color565::Black, Color565::Red, Color565::Red, Color565::Blue, Color565::Blue, Color565::Red, Color565::Red, Color565::Black, Color565::Black, Color565::Red, Color565::Red, Color565::Blue, Color565::Blue, Color565::Red, Color565::Red, Color565::Black, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Red, Color565::Black, Color565::Black, Color565::Red, Color565::Red, Color565::Black, Color565::Black, Color565::Red };
...
void Ship::draw(LCD_ST7735 &disp) {
    disp.drawBitmap(this->x, this->y, shipBmp);
}

The bitmap displays fine, but the red and blue colors are reversed. So everywhere that I've got Color565::Red, it displays blue, and vice-versa.

Is this user error on my part, or a known issue?

Question relating to:

SPI based library for the ST7735 LCD controller.

1 Answer

9 years, 3 months ago.

The library supports both RGB and BGR panels, depending on the type of panel connected to the ST7735 controller you need to select the appropriate color format. The selection is passed as an argument to the constructor. If you do not pass an argument it defaults to BGR since that was the most common panel I found on ebay.

For example

// Setup the display instance for RGB color format
LCD_ST7735  screen(
    P0_19,
    P0_20,
    P0_7,
    P0_21,
    P0_22,
    P1_15,
    P0_2,
    LCD_ST7735::RGB
);

OR

// Setup the display instance for BGR color format
LCD_ST7735  screen(
    P0_19,
    P0_20,
    P0_7,
    P0_21,
    P0_22,
    P1_15,
    P0_2,
    LCD_ST7735::BGR
);

Accepted Answer