New Old 1.8 128x160 TFT Samsung ST7735 driver problem

Hi!
Recently I have bought an cheap chinese tft display. After a bit of googling I have found many tutorials. Unfornamently no one worked. On forums they have found a soultion. People were using wrong library, so it stayed only white. The right one sloud be modified for that Samsung chip. (QDtech) All people were happy that it is working.

But it was two years ago. I don´t see any newer posts so it looks like that this problem has disapeared. Well it actualy didn't. :frowning: I saw some comments on YouTube and other websites. These people has same problem as me - TFT works, but it just displays "random" colored lines. They are not actually random. They have same patern after every reset. These people have newer found a soultion.

That's why I'm here. They didn't have found soultion. Your response will help many people. If not, it will help at least me. :slight_smile: Thank you.

This thread may help if you have that display.

Unfortunately those displays can be fitted with 3 different controllers and the controller can be connected to the display in different ways. Thus some folk find a solution works for their display but it does not work for someone else. There are also lots of mistakes that can be made, from wiring errors, wrong logic levels, wrong sketch or library settings, wrong driver library, wrong interface settings.

Post a picture of the front and back, or at least a link to the sellers web page for that product, that may help forum readers identify it.

The fact that you got some colours on the screen is promising.

My display on Aliexpress:
http://www.aliexpress.com/item/Smart-Electronics-1-8-Inch-128-160-Serial-SPI-TFT-LCD-Module-Display-PCB-Adapter-Power/32607559110.html?spm=2114.01010208.3.19.UyaYUm&ws_ab_test=searchweb201556_0,searchweb201602_5_10037_10033_507_10032_10020_10017_10021_10022_10009_10008_10018_101_10019,searchweb201603_1&btsid=a567b0f8-da4d-4093-b0ab-585b98b08a99

Hmm, that link has suspiciously big amout of information

OK

That looks just like one I have, that has the Samsung chip (QDtech).

Wire it up as described in Step 1 here and load the libraries attached to Step 2 of the Instructable.

Run an example in the Adafruit_QDTech_AS library and see if it works.

Don't forget the in line resistors to drop the logic level.

I see the ribbon that comes off the display itself is at the opposite end of the PCB to mine. So you may have a different driver.

I have run the Samsung QDTech code with an ST7735 screen attached and I get a lot of stripes on the display. Since you get the same then this suggests you have an ST7735 fitted. So try that library (Adafruit_ST7735_AS) which was also part of the set you downloaded and the rainbow example.

The clock examples will not work as the latest IDEs require one of the functions (i.e. conv2d(const char* p)) to be defined early on in the sketch.

Now it works nearly perfect with the st7735 library. The only problem is that it displays some random pixels on sides. Photo: https://drive.google.com/file/d/0B20kxB_oQWRPaklid3BZQmhSdXc/view?usp=sharing (sorry but it didn't work when I marked it as an photo)
I have actually tried two libraries, so I missed the right one :sweat_smile:

OK

You need to change the display option inside the User_Setup.h file inside the TFT_ST7735 library folder to:

//#define TAB_COLOUR INITB
#define TAB_COLOUR INITR_GREENTAB
//#define TAB_COLOUR INITR_REDTAB
//#define TAB_COLOUR INITR_BLACKTAB
//#define TAB_COLOUR INITR_GREENTAB2

Let me know if that works OK. The TFT_ST7735 library is much faster on an UNO (etc) or Mega.

No, it does not work. I am getting this error.

Arduino: 1.6.9 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp: In constructor 'TFT_ST7735::TFT_ST7735(int16_t, int16_t)':

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:40:11: error: 'TFT_CS' was not declared in this scope

   _cs   = TFT_CS;

           ^

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:41:11: error: 'TFT_DC' was not declared in this scope

   _dc   = TFT_DC;

           ^

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:42:11: error: 'TFT_RST' was not declared in this scope

   _rst  = TFT_RST;

           ^

In file included from C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:18:0:

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.h:83:27: error: the value of 'TFT_DC' is not usable in a constant expression

 #define TFT_DC_D  FastPin<TFT_DC>::hi()

                           ^

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:50:3: note: in expansion of macro 'TFT_DC_D'

   TFT_DC_D;

   ^

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:41:11: note: 'TFT_DC' was not declared 'constexpr'

   _dc   = TFT_DC;

           ^

In file included from C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:18:0:

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.h:83:33: error: could not convert template argument 'TFT_DC' to 'unsigned char'

 #define TFT_DC_D  FastPin<TFT_DC>::hi()

                                 ^

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:50:3: note: in expansion of macro 'TFT_DC_D'

   TFT_DC_D;

   ^

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:50:11: error: invalid type in declaration before ';' token

   TFT_DC_D;

           ^

In file included from C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:18:0:

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.h:82:26: error: the value of 'TFT_CS' is not usable in a constant expression

 #define TFT_CS_H FastPin<TFT_CS>::hi()

                          ^

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:53:3: note: in expansion of macro 'TFT_CS_H'

   TFT_CS_H;

   ^

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:40:11: note: 'TFT_CS' was not declared 'constexpr'

   _cs   = TFT_CS;

           ^

In file included from C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:18:0:

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.h:82:32: error: could not convert template argument 'TFT_CS' to 'unsigned char'

 #define TFT_CS_H FastPin<TFT_CS>::hi()

                                ^

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:53:3: note: in expansion of macro 'TFT_CS_H'

   TFT_CS_H;

   ^

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:53:11: error: invalid type in declaration before ';' token

   TFT_CS_H;

           ^

In file included from C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:18:0:

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp: In member function 'void TFT_ST7735::writecommand(uint8_t)':

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.h:81:27: error: 'TFT_DC' was not declared in this scope

 #define TFT_DC_C  FastPin<TFT_DC>::lo()

                           ^

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.cpp:118:3: note: in expansion of macro 'TFT_DC_C'

   TFT_DC_C;

   ^

C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.h:81:33: error: template argument 1 is invalid

 #define TFT_DC_C  FastPin<TFT_DC>::lo()



C:\Program Files (x86)\ArduinoCC\libraries\TFT_ST7735-master\TFT_ST7735.h:83:33: error: could not convert template argument 'TFT_DC' to 'unsigned char'

 #define TFT_DC_D  FastPin<TFT_DC>::hi()


exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Note: This is shorter version because of character limit.

Ah, it looks like you have deleted everything else in User_Setup.h, that was not the intent!

Use the attached replacement!

User_Setup.h (3.94 KB)

Ok random pixels had disappeared when I have defined screen protector tab color to red.
But some colors are inverted.
I have removed the screen protector, but I think that color of the tab wasn't red.
I'm wondering if it's color wasn't blue...

Hello again,

I have done some tests on a display I have.

Since you found the REDTAB looked OK apart from the colour inversion, then the BLACKTAB option should correct that. So that option section of the User_Setup.h file should look like:

//#define TAB_COLOUR INITB
//#define TAB_COLOUR INITR_GREENTAB
//#define TAB_COLOUR INITR_REDTAB
#define TAB_COLOUR INITR_BLACKTAB
//#define TAB_COLOUR INITR_GREENTAB2

Upload your code with this setting and it should be OK!

Unfortunately red and blue are swapped. I have tried all of these options, but there is no one working right. I think that I need to change color settings of this library to fit my display. But how...

OK, I see there is a bug in the library.

I will fix it but in the meantime use the BLACKTAB option and ensure you set the screen rotation in the setup after tft.init():

  tft.init();
  tft.setRotation(0);

Library has been updated and can be downloaded from here.

Thanks for helping to find this bug.

Blacktab option should work for you now.

Thank you too! Now it works fine.
I was wondering if there is any difference between IDE from arduino.cc and arduino.org, because org's compilation is much smaller than cc. Now I know it, because there are these pixels when it's compiled in org, and when it's compiled in cc they aren't.
Or maybe it is another bug? :slight_smile: I have tried it before this update in both of these programs, and it didn't work.

Great, it is good to hear you have it working fine.

I have .cc's 1.6.9 IDE loaded and .org's 1.7.10 and there is only a tiny difference. Bear in mind that the number of fonts enabled in User_Setup.h and some of the other options makes a big difference to the sketch size.

In IDE 1.6.9 the TFT_graphicstest_PDQ3 example with just the GLCD font enabled reports the size as:

Sketch uses 23,104 bytes (71%) of program storage space. Maximum is 32,256 bytes.
Global variables use 252 bytes (12%) of dynamic memory, leaving 1,796 bytes for local variables. Maximum is 2,048 bytes.

Whereas 1.7.10 reports:

Sketch uses 23,102 bytes (71%) of program storage space. Maximum is 32,256 bytes.
Global variables use 248 bytes (12%) of dynamic memory, leaving 1,800 bytes for local variables. Maximum is 2,048 bytes.

So there is only a small difference. So make sure User_Setup.h is set identically for both IDE's