ILI9225

does anyone how to change the default background color in a tft ILI9225? to any other colors. the default is set to black.

thanks

The TFT_22_ILI9225 library that you have chosen has "unusual" methods. I would choose a GFX style library. Then you can port examples from other GFX style libraries quite easily.

All the same. Post your particular sketch. Explain what background colour you would like. Then someone can show you how to use the methods from your particular library.

David.

Hello,

This topic is a bit old, so you probably found the solution in a meanwhile, but this can help other people:

void setBackgroundColor(uint16_t color = COLOR_BLACK);

Nevertheless, this does not work with every methods. for example, the following code writes a text in yellow and white, but draws in ... black and white:

tft.setBackgroundColor(COLOR_YELLOW);

tft.setFont(Terminal6x8); tft.drawText(10, 10, "Draw"); delay(1000);

tft.drawBitmap(0, 0, tux, 180, 220, COLOR_WHITE); delay(1000);

I strongly advise you to use an "Adafruit_GFX" style library. It would make your life easier.

However the TFT_22_ILI9225 class does have methods to suit your requirements. e.g.

        void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg);

So you would just say:

  tft.drawBitmap(0, 0, tux, 180, 220, COLOR_WHITE, COLOR_YELLOW);

if you want to draw the solid background colour. and

  tft.drawBitmap(0, 0, tux, 180, 220, COLOR_WHITE);

if you want to draw a transparent bitmap.

Drawing WHITE text with a solid YELLOW background seems unusual. Hey-ho, it is your eyesight.

Untested. I might this later. That is how Adafruit_GFX draws bitmaps. Adafruit lets you draw transparent text or text with a solid background.

David.

Thank you David.

I just picked yellow and white at random. I agree it wasn't the best choice :-p !

The method you provide for drawBitmap indeed draws in the whished colors, but it doesn't use the defined default background. By providing only one color, I would expect the method to use the defined background. drawText does, but not drawBitmap.

That's not an issue anyway, as there are many ways to workaround (including your suggestion). It was just a quick comment to make Jafleu and other readers notice that the use of the defined background is not straitforward in every drawing methods.

The setBackgoundColor() is intended for text not graphics.

i.e. like you would say in Adafruit_GFX:

    tft.setTextColor(TFT_WHITE, TFT_YELLOW);  //white text on yellow background
    tft.setTextColor(TFT_RED);  //red text on transparent background
    tft.setTextColor(TFT_RED, TFT_RED);  //foreground == background means transparent

Using the full-fat drawBitmap() method is relatively slow in Adafruit_GFX. It is faster to draw a rectangle in the background colour. Then plot drawBitmap() transparently.

Some hardware libraries will provide a hardware drawBitmap() for the full-fat foreground and background.

David.

Thank you, David!