3.2" Display with HX8357B has wrong / invers color 320x480

Hello at all,

i had build in 2015 a arduino mega 2560 with an 3.2" TFT with HX8357B chipset. The demoprogramm with UTFT Library works fine. So i had order 5 new tfts for my other megas.

Here is an example that tft i had bought.
ebay

Now i had the probleme that my old tft works fine, but all new received tft dont work. The display show all values, the resolutuin 320x480 works fine but all colors are inverse / strange.

So hier is an example from google wich shows an working Display (my old tft too):

Thats the new 5 Display`s

So whats wrong? Both had the same chipset HX8357B. I cant remeber the lable on the first TFT, but on the new 5 tft on the labele is print: ILI9481 480x320...

I had change my coding from "UTFT myGLCD(HX8357B, 38, 39, 40, 41)" to "UTFT myGLCD(ILI9481, 38, 39, 40, 41)" but nothing will show.

I have noticed that the old tft will be black at startup and the new one will be white at startup.
Are the new tft demaged?

Thank you for reply and regards.

Andy Meyer

Vendors frequently quote one driver chip then supply one that has a different controller.

As the display simply shows inverted colours, it is working fine. It is just that you have not got the right controller selected properly within the library or that controller is not supported in parallel mode.

I have exactly that display and have a support library here.

Even if you do not want to use the library in the end at least it will show the display works correctly.

I'm 99% sure you have the ILI9481 variant of this display. You can use my library here, but you will need to edit the User_Setup.h file within the library so that the display driver selection #defines read:

//#define HX8357B
//#define HX8357C
#define ILI9481

Report any problems you have with it here and I will try to help.

Hi,

the problem is solved. The display has an other controller ILI09481 and the UFTF has compile problem with the cache ov visual studio.

Thanks for your help.

Andy

OK, I'm glad you have solved it.

For correct work this lcd change
UTFT myGLCD(HX8357B, 38, 39, 40, 41); to
UTFT myGLCD(CTE32HR, 38, 39, 40, 41);

and change string #define DISABLE_ILI9481 to
//#define DISABLE_ILI9481 in file memorysaver.h (UTFT library)

hello,

I could not

library TFT_HX8357-master

3.2tft v2.0 hx8357b Colors are reversed (3.2" TFTLCD shield for arduino Mega2560 v2.0)

3.2tft ILI9481 Colors are good (3.2" TFTLCD shield for arduino Mega2560)

I got mine to work by editing UTFT.cpp

I added these changes.

After the heading comments is added these lines

//******************************************************************************************
// WLL
// On some displays, the color is inverted, ie. white is black and black is white, etc.
// To correct the color, define invCol to 0xffff, otherwise set invCol to 0 as the default
// Invert color changes has been tagged with my initals WLL
#define invCol 0xffff
//#define invCol 0
//******************************************************************************************

I then modified these lines

In void UTFT::clrScr()
// WLL
_fast_fill_16(invCol,invCol,((disp_x_size+1)*(disp_y_size+1)));

In void UTFT::fillScr(word color)
// WLL
ch=byte(color>>8 )^invCol;
cl=byte(color & 0xFF)^invCol;

Then grouped together is
void UTFT::setColor(byte r, byte g, byte b)
{
// WLL
fch=((r&248)|g>>5)^invCol;
fcl=((g&28)<<3|b>>3)^invCol;
}

void UTFT::setColor(word color)
{
// WLL
fch=byte(color>>8 )^invCol;
fcl=byte(color & 0xFF)^invCol;
}

word UTFT::getColor()
{
// WLL
return ((fch<<8 ) | fcl)^invCol;
}

void UTFT::setBackColor(byte r, byte g, byte b)
{
// WLL
bch=((r&248)|g>>5)^invCol;
bcl=((g&28)<<3|b>>3)^invCol;
_transparent=false;
}

void UTFT::setBackColor(uint32_t color)
{
if (color==VGA_TRANSPARENT)
_transparent=true;
else
{
// WLL
bch=byte(color>>8 )^invCol;
bcl=byte(color & 0xFF)^invCol;
_transparent=false;
}
}

word UTFT::getBackColor()
{
// WLL
return ((bch<<8 ) | bcl)^invCol;
}

Then in void UTFT::drawBitmap - there are two methods - I modified all LCD_Write_DATA calls like this
// WLL
LCD_Write_DATA((col>>8 )^invCol,(col & 0xff)^invCol);

I could post my file somewhere if needed.

Wayne

wlemmon:
I got mine to work by editing UTFT.cpp

I added these changes.

After the heading comments is added these lines

//******************************************************************************************
// WLL
// On some displays, the color is inverted, ie. white is black and black is white, etc.
// To correct the color, define invCol to 0xffff, otherwise set invCol to 0 as the default
// Invert color changes has been tagged with my initals WLL
#define invCol 0xffff
//#define invCol 0
//******************************************************************************************

I then modified these lines

In void UTFT::clrScr()
// WLL
_fast_fill_16(invCol,invCol,((disp_x_size+1)*(disp_y_size+1)));

In void UTFT::fillScr(word color)
// WLL
ch=byte(color>>8 )^invCol;
cl=byte(color & 0xFF)^invCol;

Then grouped together is
void UTFT::setColor(byte r, byte g, byte b)
{
// WLL
fch=((r&248)|g>>5)^invCol;
fcl=((g&28)<<3|b>>3)^invCol;
}

void UTFT::setColor(word color)
{
// WLL
fch=byte(color>>8 )^invCol;
fcl=byte(color & 0xFF)^invCol;
}

word UTFT::getColor()
{
// WLL
return ((fch<<8 ) | fcl)^invCol;
}

void UTFT::setBackColor(byte r, byte g, byte b)
{
// WLL
bch=((r&248)|g>>5)^invCol;
bcl=((g&28)<<3|b>>3)^invCol;
_transparent=false;
}

void UTFT::setBackColor(uint32_t color)
{
if (color==VGA_TRANSPARENT)
_transparent=true;
else
{
// WLL
bch=byte(color>>8 )^invCol;
bcl=byte(color & 0xFF)^invCol;
_transparent=false;
}
}

word UTFT::getBackColor()
{
// WLL
return ((bch<<8 ) | bcl)^invCol;
}

Then in void UTFT::drawBitmap - there are two methods - I modified all LCD_Write_DATA calls like this
// WLL
LCD_Write_DATA((col>>8 )^invCol,(col & 0xff)^invCol);

I could post my file somewhere if needed.

Wayne

Thank you for your help! I applied your code and display is fixed.

Maybe if someone in here is interested to making a DIY TFT LCD shield from an unknown china phones display like me
check this link

Use google translate for rusian arduino link if your language is english.

Hi I am having the same problem, I have a HX8357B tft board but when I view a bmp file the colors are inverted, also the regular screen colors are not as they claim in the library when called within a program.
I have tried the method above but to no avail. Any ideas?

I have the same problem.
I am using the library GitHub - Bodmer/TFT_HX8357: Arduino library for HX8357 TFT display and I solved it by placing as the first command of setup function:

tft.invertDisplay(1);

It works for me.

1 Like

I had the same problem with HX8357C. I tried all solutions but they wont works. Than I found the code (bellow) in the file initlcd.h (folder Arduino../libraries/utft/tft_drivers/hx8353c) and I changed it. :slight_smile:

Before:

LCD_Write_COM(0x21);//Display inversion ON

After:

LCD_Write_COM(0x20);//Display inversion OFF (0x21 is ON)

I use the TFT_HX8357-master library in combination with a Mega 2560 board.

All mentioned solutions didn't work for me, but the did point out to a solution that works for me.
In the User_Setup.h file I commented out #define HX8357C and commented the other two processors.
Now all colors are OK.

I have the same problem.
I am using the library GitHub - Bodmer/TFT_HX8357: Arduino library for HX8357 TFT display and I solved it by placing as the first command of setup function:

tft.invertDisplay(1);

It works for me.

thank youu gigias, it works for me too

2 Likes