Arduino Forum

Using Arduino => Displays => Topic started by: bodmer on Jun 12, 2016, 01:41 pm

Title: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Jun 12, 2016, 01:41 pm
The new library supports low cost S6D02A1 based displays connected to an UNO, Leonardo or Mega via SPI, it is based on the Adafruit GFX library with encoded fonts to save space. The library is highly optimised for AVR processors to boost performance and is 3 to 10 times faster than the basic Adafruit library.

The library can be found on Github. (https://github.com/Bodmer/TFT_S6D02A1)

These are pictures of my display.

(http://i.imgur.com/GVfWRH0.jpg) (http://imgur.com/GVfWRH0)

(http://i.imgur.com/m0Jtl0f.jpg) (http://imgur.com/m0Jtl0f)


Some similar looking displays have the ST7735 driver fitted so a different library is needed (https://github.com/Bodmer/TFT_ST7735).

This display does not tolerate 5V logic signals. A series resistor works but the contrast flickers, so a resistor divider is needed. Connect as follows:



The 22R resistor is needed to limit the LED current to about 55mA.

Please report any bugs here.

Update: It appears this display is fitted with a ILI9163 driver but just happens to work with the S6D02A1 based library.  So I have created a new library specifically for the ILI9163 driver. It is exxentially the same library as the link above but has initialisation code specifically for the ILI9163 driver.  This library can be found here:

TFT_ILI9163 library (https://github.com/Bodmer/TFT_ILI9163)

Note: This library "almost" works with ST7735S based displays but the blue and red colours will be swapped, rotations will not work and the colours will be dull because the Gamma registers will not be setup.

Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 based) TFT displays from eBay
Post by: bodmer on Jun 14, 2016, 11:42 pm
I've updated updated the library on GitHub to improve performance by reducing the number of SPI transactions needed to plot single pixels and lines, this also speeds up other graphics functions like plotting text characters and drawing circle+triangle outlines.

Two new examples "TFT_3d_engine" and "TFT_Starfield" have been added that benefit significantly from this approach.

All this extra effort was just to get a game of "Space Invaders" running smoothly on the UNO... :)
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 based) TFT displays from eBay
Post by: richard_turnnidge on Jun 22, 2016, 04:01 pm
This is a really good library, I have been waiting for something like this. I am only playing with code at the moment, but it seems very fast.

Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 based) TFT displays from eBay
Post by: bodmer on Jun 24, 2016, 12:37 am
Hi Richard,

Thanks for the feedback. I have done some tests and it is significantly faster than the equivalent stock Adafruit library, for example running this 1000 times:

tft.drawLine(0, 0, 100, 20, 0xFFFF);

shows it is 24x faster.

drawPixel is the most fundamental graphics operation and is more than 7x faster.  In cases where the new fastPixel function can be used, it is at least 10x faster.



Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 based) TFT displays from eBay
Post by: slessard on Sep 10, 2016, 09:18 pm
Hello Everyone,

I got the same display from Aliexpress and still unable to have it working on my Mega.
I wired it like suggested.
I first tried with the library for a ST7735 and a got something like Fantawttw from this thread : http://forum.arduino.cc/index.php?topic=388779.0
I had a loop that had "invertDisplay" called every second and it did change the display, although I'm not sure it was really inverting but at least showed me that kind of talk to the module...

Then I tried with the library for the S6D02A1. We are never sure which driver they put in these Chinese builds!
I got really no sign of life with this one.
I tried with a second display, new out of box, same thing.

I've seen people getting good results from these displays but after a lot of attemps I am still stuck.
Am I missing something? Where should I start looking?

Thanks!
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 based) TFT displays from eBay
Post by: bodmer on Sep 10, 2016, 11:10 pm
Which pins on the Mega have you wired up to the display?
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 based) TFT displays from eBay
Post by: slessard on Sep 11, 2016, 03:07 am
I have wired this way
- RESET to 49
- A0 to 47
- SDA to 51
- SCK to 52
- CS to 45

All these with 1K in series. I also tried a voltage divider with a 1.5K that gave me 3V at the pin (should be enough for the logic 1 CMOS level).

Thanks for your help!
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 based) TFT displays from eBay
Post by: bodmer on Sep 11, 2016, 08:00 pm
@slessard

Can you post pictures of the front and back of the display. I may be able to match it to one of the displays I have. Though it might look the same as the one I posted on this thread are subtle differences on the PCB, the display white plastic frame and the ribbon cable that comes off the display that may help narrow down the coice of driver.

If you use the library linked in the original post you do need to configure the pins in the User_Setup.h file within the library folder.

I also have a sketch that reads back the ID so I will see if I can find where I saved it (!) and test it on some of my displays.
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 based) TFT displays from eBay
Post by: slessard on Sep 16, 2016, 02:34 am
Hello Bodmer,

Thanks for your reply. Here is a photo of front and back in attachment.

Yes, I have noticed the instruction in the example and I modified the User_Setup.h according to my IO configuration.

Thanks again!
Simon
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 based) TFT displays from eBay
Post by: bodmer on Sep 16, 2016, 11:56 am
I have wired this way
- RESET to 49
- A0 to 47
- SDA to 51
- SCK to 52
- CS to 45

All these with 1K in series. I also tried a voltage divider with a 1.5K that gave me 3V at the pin (should be enough for the logic 1 CMOS level).

Thanks for your help!
It may be a typo error but you should use SCL not SCK (which is the clock line for the SD Card slot).

The white plastic frame and ribbon cable off the display is different to mine. I will check if that corresponds to one of my displays later today and post a display ID reader. You may have a ST7735 driver or a Hynix driver.
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 based) TFT displays from eBay
Post by: david_prentice on Sep 16, 2016, 12:25 pm
What Hynix controllers are there?
I googled and found that Hynix sold (or were trying to sell) their TFT business in 2001.
Did 128x160 singlechip controllers exist in 2001?

There seem to be several 128x160 controllers from different manufacturers e.g.
ILI9163C  Ilitek
ST7735S  Sitronix
S6D02A1  Samsung

I presume that Renesas, Himax, SolomonSystech, ... have parts too.

David.
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 based) TFT displays from eBay
Post by: slessard on Sep 16, 2016, 02:59 pm
Hello Bodmer,

Yes it was a typo. I use the SCL pin on the TFT side, wired to the SCK on the Mega side. Thanks for pointing out.

David, I tried with library for ST7735S and S6D02A1.
A got at least some basic responding with the ST7735S (I looped over the function InvertDisplay every second and I saw the screen flashing at same frequency. I'm not sure it was actually inverting but it did something).
The call to fill with a solid color didn't filled the entire screen but about 2/3 with some large areas in the middle being unaffected by the command (tried on two different parts).
I got no result with the driver from Samsung so unless drivers have similar command register or I got lucky and the InvertDisplay function was recognized by my display even if I was using the wrong library, I guess that mine is ST7735S.
I can still try with the libs for ILI9163C just in case!

Thanks,
Simon
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 based) TFT displays from eBay
Post by: david_prentice on Sep 16, 2016, 03:21 pm
My comments / questions were directed to Bodmer.   He knows a lot about this class of controller.

If you can diagnose which make of controller is present,   you can use the correct library.    Or configure a universal library to suit your display.

These controllers are readable if you use 3.3V logic.   And readable with 5V logic if you use series resistors.   I have published a sketch before now.   I can't remember which thread(s) that I posted in.

David.
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 based) TFT displays from eBay
Post by: bodmer on Sep 16, 2016, 10:04 pm
@david_prentice: I meant Himax, well spotted! I remember seeing a 1.8" display with a HX---- driver advertised, but I am not sure where I saw it.  Yes you are right, ILI9163/S6D02A1/ST7735 are all options often advertised for 1.8" displays.

@slessard: Your PCB has different track routing to mine.

Below is a sketch that might help identify the driver. I have used the ID's from the data sheets for the ILI9163/S6D02A1/ST7735S drivers.

Code: [Select]

// Read the ID from the TFT controller
// The sketch only supports displays with a bi-directional SPI data line (often labelled SDA)

// Bit bashes SPI so it does NOT assume hardware SPI wired up
// No other libraries are needed

// Original author unknown
// Adapted by Bodmer 22/5/16, updated 16/9/16

// Change the pin settings to suit your hardware

// UNO etc
//#define TFT_MOSI  11
//#define TFT_SCK 13
//#define TFT_CS 9
//#define TFT_DC  8
//#define TFT_RESET 7

//Mega
#define TFT_MOSI  51
#define TFT_SCK 52
#define TFT_CS 47
#define TFT_DC  48
#define TFT_RESET 44

/* Example Serial Monitor output:

TFT driver register values:
===========================
Register 0x01: 0x00
Register 0x04: 0x548066
Register 0x09: 0x610000
Register 0x0A: 0x08
Register 0x0B: 0x00
Register 0x0C: 0x06
Register 0x0D: 0x00
Register 0x0E: 0x00
Register 0x0F: 0x00
Register 0x2E: 0x1834B4
Register 0xDA: 0x54
Register 0xDB: 0x80
Register 0xDC: 0x66
===========================

Looks like driver chip is: ILI9163 (based on datasheet ID)

*/

char *chip = "Unknown                                                                                           ";


uint32_t readwrite8(uint8_t cmd, uint8_t bits, uint8_t dummy)
{
    uint32_t ret = 0;
    uint8_t val = cmd;
    int cnt = 8;
    digitalWrite(TFT_CS, LOW);
    digitalWrite(TFT_DC, LOW);
    pinMode(TFT_MOSI, OUTPUT);
    for (int i = 0; i < 8; i++) {   //send command
        digitalWrite(TFT_MOSI, (val & 0x80) != 0);
        digitalWrite(TFT_SCK, HIGH);
        digitalWrite(TFT_SCK, LOW);
        val <<= 1;
    }
    if (bits == 0) {
        digitalWrite(TFT_CS, HIGH);
        return 0;
    }
    pinMode(TFT_MOSI, INPUT_PULLUP);
    digitalWrite(TFT_DC, HIGH);
    for (int i = 0; i < dummy; i++) {  //any dummy clocks
        digitalWrite(TFT_SCK, HIGH);
        digitalWrite(TFT_SCK, LOW);
    }
    for (int i = 0; i < bits; i++) {  // read results
        ret <<= 1;
        if (digitalRead(TFT_MOSI)) ret |= 1;;
        digitalWrite(TFT_SCK, HIGH);
        digitalWrite(TFT_SCK, LOW);
    }
    digitalWrite(TFT_CS, HIGH);
    return ret;
}

void showreg(uint8_t reg, uint8_t bits, uint8_t dummy)
{
    uint32_t val;
    val = readwrite8(reg, bits, dummy);

    Serial.print("Register 0x");
    if (reg < 0x10) Serial.print("0");
    Serial.print(reg , HEX);
    Serial.print(": 0x");
    if (val < 0x10) Serial.print("0");
    Serial.println(val, HEX);
}

void setup() {
    // put your setup code here, to run once:
    uint32_t ID = 0;
    Serial.begin(9600);
    Serial.println("TFT driver register values:");
    Serial.println("===========================");
    digitalWrite(TFT_CS, HIGH);
    //    digitalWrite(TFT_SCK, HIGH);
    pinMode(TFT_CS, OUTPUT);
    pinMode(TFT_SCK, OUTPUT);
    pinMode(TFT_MOSI, OUTPUT);
    pinMode(MISO, INPUT_PULLUP);
    pinMode(TFT_DC, OUTPUT);
    pinMode(TFT_RESET, OUTPUT);
    digitalWrite(TFT_RESET, HIGH);
    digitalWrite(TFT_RESET, LOW);   //Hardware Reset
    delay(50);
    digitalWrite(TFT_RESET, HIGH);
    showreg(0x01, 0, 0);            //Software Reset
    delay(100);
    ID = readwrite8(0x04, 24, 1);

    if ((ID & 0xFF8000) == 0x5C8000uL) chip = "ST7735 (based on datasheet ID)";
    if (ID == 0x7C89F0uL) chip = "ST7735 (empirical value)";
    if (ID == 0x548066uL) chip = "ILI9163 (based on datasheet ID)";
    if (ID == 0x5C0000uL) chip = "S6D02A1 (based on datasheet ID)";
 
    showreg(0x04, 24, 1);   //RDDID
    showreg(0x09, 32, 1);   //RDSTATUS
    showreg(0x0A, 8, 0);
    showreg(0x0B, 8, 0);
    showreg(0x0C, 8, 0);
    showreg(0x0D, 8, 0);
    showreg(0x0E, 8, 0);
    showreg(0x0F, 8, 0);
    showreg(0x2E, 24, 8);   //readGRAM
    showreg(0xDA, 8, 0);
    showreg(0xDB, 8, 0);
    showreg(0xDC, 8, 0);

    Serial.println("===========================");
    Serial.println();
    Serial.print("Looks like driver chip is: " );Serial.println(chip);
}

void loop() {

}




Interestingly it reports my display as having an ILI9163 but I am using initialisation code from this library (https://github.com/zigwart/Adafruit_QDTech) for a S6D02A1 and it works OK but that may just be by luck and a degree of initialisation address compatibility.

Can you tell me where you got your display and what the ID reading sketch reports in the Serial Monitor window (9600 baud)?
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Sep 17, 2016, 06:29 pm
The ID reader code in post #13 above indicates I have a ILI9163 driver on my display but this just happens to work OK with the S6D02A1 library!

So I have created a specific library for the ILI9163 (https://github.com/Bodmer/TFT_ILI9163) and it is working fine.  It retains the high plotting performance and is suited to AVR processors only (UNO, Mega, Leonardo etc) because of the way the performance enhancements have been done.

Report any bugs here.

Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: slessard on Sep 18, 2016, 02:58 am
Hello Bodmer,

Yes it was a typo. I use the SCL pin on the TFT side, wired to the SCK on the Mega side. Thanks for pointing out.

David, I tried with library for ST7735S and S6D02A1.
A got at least some basic responding with the ST7735S (I looped over the function InvertDisplay every second and I saw the screen flashing at same frequency. I'm not sure it was actually inverting but it did something).
The call to fill with a solid color didn't filled the entire screen but about 2/3 with some large areas in the middle being unaffected by the command (tried on two different parts).
I got no result with the driver from Samsung so unless drivers have similar command register or I got lucky and the InvertDisplay function was recognized by my display even if I was using the wrong library, I guess that mine is ST7735S.
I can still try with the libs for ILI9163C just in case!

Thanks,
Simon
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: slessard on Sep 18, 2016, 03:13 am
Hello bodmer,

Thanks for the script! Pretty effective... I just ran it and here is the output :

Code: [Select]
TFT driver register values:
===========================
Register 0x01: 0x00
Register 0x04: 0x548066
Register 0x09: 0x610000
Register 0x0A: 0x08
Register 0x0B: 0x00
Register 0x0C: 0x06
Register 0x0D: 0x00
Register 0x0E: 0x00
Register 0x0F: 0x00
Register 0x2E: 0x482020
Register 0xDA: 0x54
Register 0xDB: 0x80
Register 0xDC: 0x66
===========================

Looks like driver chip is: ILI9163 (based on datasheet ID)


The one I haven't tried yet, so there is hope!
I also went back to the description of the TFT part I bought and it says ST7735... we always have surprises with these products from China!
I will try your lib and give you some news.

Thanks again!

Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Sep 18, 2016, 01:40 pm
@slessard

OK, it looks like you have an ILI9163 based display then.  The results indicate you have got the connections right.

You will need a resistor divider on the logic lines with that driver to avoid brightness modulation (happens when the display is being updated), I use 1k2 and 2k2 as I have lots of those values. Power the display from 5V, I notice that my display is fitted with a 3.0V regulator.

I intend to make a minor tweak to the library later today to add a "belt and braces" software reset at the start of initialisation.
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Sep 19, 2016, 03:45 am
I tested another display that I thought had a S6D02A1 and this does indeed seem to be the case as it only works with the TFT_S6D02A1 library and no others.  Whereas the ILI9163 based display works fine with either the TFT_ILI9163 or the S6D02A1 library!

PS The TFT_ILI9163 library has been updated to add a software reset at the start of initialisation. This will help in cases where a display does not have a hardware reset pin.
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: slessard on Sep 20, 2016, 02:53 am
It's starting to give some results!
Apparently my TFT that was identified to be built with driver ST7735 by the vendor was finally made from ILI9163...
Although it is not perfect, I have a good start see attached.
The background is weird and the two bright stripes we can see is like those I got when I was using the library for the ST7735 but at this time it was two solid color areas, not pixelized like that and obviously without the text.

Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Sep 21, 2016, 12:33 am
@slessard

That looks like the random startup state of the graphics RAM that is inside the display chip.

In setup() or somewhere else in your sketch, after tft.init(), you must clear the screen to the desired background colour, say with:

Code: [Select]
tft.fillScreen(TFT_BLACK);

Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: medina on Oct 11, 2016, 11:01 pm
@slessard

OK, it looks like you have an ILI9163 based display then.  The results indicate you have got the connections right.

You will need a resistor divider on the logic lines with that driver to avoid brightness modulation (happens when the display is being updated), I use 1k2 and 2k2 as I have lots of those values. Power the display from 5V, I notice that my display is fitted with a 3.0V regulator.

I intend to make a minor tweak to the library later today to add a "belt and braces" software reset at the start of initialisation.
Bodmer GOOD PLACE IS NECESSARY FOR THE DRIVER ST7735 RESISTENCIAS?
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Oct 12, 2016, 12:57 am
For 5V Arduino's a 1K2 series resistor can be used to interface with a ST7735 driver.

Example connections at the end of step 1 here (http://www.instructables.com/id/Arduino-TFT-display-and-font-library/).
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: dad5019 on Jan 19, 2017, 02:49 am
bodmer;

My ST7735 TFT is working like a champ.  You sir are a genius among geniuses.
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Jan 19, 2017, 11:01 pm
@dad5019

Thanks for the feedback. Good luck with your project!
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: suculent on Mar 05, 2017, 09:37 pm
What's the reason this does not work on ESP8266-based MCUs? Regardless the speed, should I use the Adafruit ST7735 lib? Does it support I2C?
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Mar 06, 2017, 02:21 am
It is optimised for the AVR processors and uses machine coded sections to improve rendering speeds. This makes it 3 to 12 times faster depending on the graphics functions used.

If you wish to usse the display with an ESP8266 then you could try this library (https://github.com/Bodmer/TFT_eSPI).  It is optimised for the ESP8266.

Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: kacitran on Jun 18, 2017, 09:37 pm
This is the information dump
Code: [Select]
Looks like driver chip is: Unknown                                                                                          
`Hú5BþÿTFT driver register values:
===========================
Register 0x01: 0x00
Register 0x04: 0xE38835
Register 0x09: 0x610000
Register 0x0A: 0x08
Register 0x0B: 0x00
Register 0x0C: 0x06
Register 0x0D: 0x00
Register 0x0E: 0x00
Register 0x0F: 0x00
Register 0x2E: 0xFFFFFF
Register 0xDA: 0xE3
Register 0xDB: 0x88
Register 0xDC: 0x35
===========================

Looks like driver chip is: Unknown


(http://i.imgur.com/GVfWRH0.jpg)


(http://i.imgur.com/m0Jtl0f.jpg)



Can help me identify

Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Jun 19, 2017, 01:53 am
Can help me identify

I do not recognize the returned codes. Post pictures of your display, that may help (You seem to have copied my pictures from the original thread)!

You could just try different libraries and see which one works. The test results show you have got the connections working.
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: kacitran on Jun 23, 2017, 11:04 am
These are my photos


(http://img.fenixzone.net/i/nMEzYKN.jpeg)


LCD is a surprise, but the circuit board is the same

(http://img.fenixzone.net/i/a21RblO.jpeg)


thanks for your reply
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Jun 26, 2017, 01:33 am
@kacitran

The display PCB is visually similar to mine but has a different TFT screen. I can only suggest you different graphics drivers to try to find one that works.
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: garystofer on Jul 14, 2017, 10:22 pm
Hey Bodmer,

I tried this library on the boards I got from CN the other day.  I get it almost to work with the 7735 library, The colors show up correctly, but a couple of inconsistencies exist when running the simple graphics test from your examples.

The first column and row of the display is not getting cleared or drawn.
There are some spurious horizontal lines in the multiple font test in the letter H of "Hello" .
There are some spurious horizontal lines in the testlines(ST7735_YELLOW), They are in different locations from the Hello test. One line at row 2, about 3/4 the lenght of the display, one about in the middle and about 5 short sections toward the bottom of the screen 

I tried the Adafruit 7735 lib on the same device and it does not have the flaws mentioned above, but as you mentioned is a lot slower.

Any suggestions other than using the slow adafruit lib ?

Gary
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Jul 15, 2017, 01:00 pm
@garystofer

How is the display wired to the Arduino board?

Which Arduino board are you using?
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: scargill on Aug 28, 2017, 11:01 pm
Has anyone gotten to the point of putting side by side comparisons for using these chips  - I have a driver (C not C#) for the S6D02a1 with fonts etc.... and I really don't want to re-invent the wheel to get the others running if someone has already done this...

Pete.
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Aug 29, 2017, 04:18 am
@scargill You can find the init code for the.two TFT drivers here:
https//github.com/Bodmer/TFT_eSPI/tree/master/TFT_Drivers
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: scargill on Aug 29, 2017, 10:38 pm
Well I have tried all 3 processor initialisations ( with S6D02A1 general routines) and though I can get text to appear for somewhat less than a second - result is always the same - in less than a second the display fades to white...

Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: scargill on Sep 06, 2017, 08:05 pm
Well with a slight fix I now have one blog reader saying his works perfectly with the ST7735,   I know my 6SD02A1 boards work a treat - but this one - is not having it - I can get the display up most of the time with text and graphics but within a fraction of a second it has faded to white... frustrating.  The driver for the ILI9163 init doesn't do a thing... if anyone knows of ANOTHER chip these things could use - please do let me know.
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: yllawwally on Oct 19, 2017, 10:01 pm
The driver works great. However the black seems to be washed out.  This is certainly an electrical issue.  I put a 1.2k resistor to ground, and one between the nano and the display.  When I disconnect the SDA line, the issue is fixed. Obviously this isn't a solution.  All the color are washed out, and the black is pretty much gray. If I removed the sda line, the colors become crisp.  When the sda line is reconnected it goes back to washed out.  Have any of you seen this issue, and know of a fix?
Title: Re: New library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Oct 19, 2017, 11:19 pm
It appears that the SDA line is supplying current to the display, check the inline resistor values are correct.

If that is OK, then check if the display is still grey after drawing a single black pixel with say a long delay afterwards. Writing black to the screen should set the SDA line low so it does not source power. Also try the same test when drawing a white pixel, this sets the SDA line high. The idea of this test is to see if current being supplied by the SDA line is really affecting the grey level.

Note, if colours are inverse then the SDA line may be low for white and high for black.
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: yllawwally on Oct 20, 2017, 01:14 am
Thanks for your help, I had accidentally put the grounding resistor to the wrong pin.  Once the 1.2k resistor was connected to the proper SDA pin, the colors became vibrant.
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: alexartd on Oct 28, 2017, 12:03 am
Hello I've this display but it show graphics in a bad way, like in revert ecc as you can see here:
https://photos.app.goo.gl/PzSRZzHE5bYfk5UV2 (https://photos.app.goo.gl/PzSRZzHE5bYfk5UV2)
Is display that doesn't work well or I 've connected it in a wrong mode ?
Many thanks
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Oct 28, 2017, 04:16 pm
@alexatd
It is likely the TFT is fine and the good news is that you have connected it up and got communication working. It is probable the display has a different driver chip fitted and thus the initialisation sequence that configures the display is not right.

Which of the two libraries in my original post have you tried? If you have tried only one then try the other.
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: alexartd on Nov 10, 2017, 04:22 pm
@alexatd
It is likely the TFT is fine and the good news is that you have connected it up and got communication working. It is probable the display has a different driver chip fitted and thus the initialisation sequence that configures the display is not right.

Which of the two libraries in my original post have you tried? If you have tried only one then try the other.

You intend these library ?
https://github.com/Bodmer/TFT_S6D02A1
https://github.com/Bodmer/TFT_ST7735

I've this error during compile :
Arduino:1.8.5 (Windows 10), Scheda:"NodeMCU 1.0 (ESP-12E Module), 80 MHz, 921600, 4M (3M SPIFFS)"

In file included from C:\Documents\Arduino\libraries\TFT_S6D02A1-master/TFT_S6D02A1.h:22:0,

                 from C:\Documents\Arduino\libraries\TFT_S6D02A1-master\examples\TFT_Clock_Digital_S6D02A1\TFT_Clock_Digital_S6D02A1.ino:31:

C:\Documents\Arduino\libraries\TFT_S6D02A1-master/TFT_FastPin.h:33:20: fatal error: avr/io.h: No such file or directory

 #include <avr/io.h>

                    ^

compilation terminated.

exit status 1
Errore durante la compilazione per la scheda NodeMCU 1.0 (ESP-12E Module).


Can you help me plese ?
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: alexartd on Nov 10, 2017, 04:42 pm
@alexatd
It is likely the TFT is fine and the good news is that you have connected it up and got communication working. It is probable the display has a different driver chip fitted and thus the initialisation sequence that configures the display is not right.

Which of the two libraries in my original post have you tried? If you have tried only one then try the other.

I've used this library:
https://github.com/Bodmer/TFT_ILI9163

but I've the wrong display view as in my photo.
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Nov 15, 2017, 02:36 pm
You intend these library ?
https://github.com/Bodmer/TFT_S6D02A1
https://github.com/Bodmer/TFT_ST7735

I've this error during compile :
Arduino:1.8.5 (Windows 10), Scheda:"NodeMCU 1.0 (ESP-12E Module), 80 MHz, 921600, 4M (3M SPIFFS)"


Can you help me plese ?
Those libraries are built to run on AVR processors (UNO, Mega, Leonaro etc) and will not compile on an ESP8266 (NodeMCU board).

Try the library here (https://github.com/Bodmer/TFT_eSPI). Note that the are setup files inside the library that must be changed to suit your setup.

I am not sure how you got it running before with reversed text if you were using a NodeMCU!
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Nov 15, 2017, 02:39 pm
I've used this library:
https://github.com/Bodmer/TFT_ILI9163

but I've the wrong display view as in my photo.
Try: https://github.com/Bodmer/TFT_S6D02A1
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: chachajejou on Dec 22, 2017, 01:03 pm
Hello and thanks a lot for this usefull thread,

i get this screen : https://www.ebay.com/itm/1-8-inch-ST7735R-SPI-128-160-TFT-LCD-Display-Module-with-PCB-for-Arduino-51/201013797202
i folow the instruction above putting resistor 1K2 2K2 and 22R.


With TFT_S6D02A1.h, i could see faint images being printed but the display was mostly just a bright white. Looking at the LCD from a very low angle (70 degrees or so, I could cleary see the text and lines being shown looked OK, but it was as if the contrast was extremely low. Everything is just bright white.

The sketch for identify the driver show only some 00 and unknow device.

when i remove de SDA wire, contrast become perfect.
I found the solution putting one more resistor ( 510R )on the SDA wire and evrithing is fine now !!
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Dec 23, 2017, 11:57 am
@chachajejou

Great to hear of your sucess. Can you explain where the two ends of the 510R resistor are connected.
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: chachajejou on Dec 27, 2017, 06:00 am
@chachajejou

Great to hear of your sucess. Can you explain where the two ends of the 510R resistor are connected.
One end go to the Arduino's 11 pin and the the other one goes to 1K2( who is connected to SDA display pin8)

thx again Bodmer :)
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: snc on Dec 31, 2017, 05:46 am
Hello bodmer,

I have the same problem with my display. It looks like one I have has S6D02A1 chip (at least it shows garbage only with ST7735 and ILI9163 drivers). I use display with NodeMCU V2 and TFT_eSPI.

(http://www.sncsoft.com/images/IMG_4420.JPG)

Here is how the pins connected -

// nodeMCU
#define TFT_CS     D8
#define TFT_RESET  D4
#define TFT_DC     D3
#define TFT_SCK    D5   
#define TFT_MOSI   D7

and results of display test from post # 13 -

driver register values:
===========================
Register 0x01: 0x00
Register 0x04: 0x8000
Register 0x09: 0x610000
Register 0x0A: 0x08
Register 0x0B: 0x00
Register 0x0C: 0x06
Register 0x0D: 0x00
Register 0x0E: 0x00
Register 0x0F: 0x00
Register 0x2E: 0x767E3E
Register 0xDA: 0x00
Register 0xDB: 0x80
Register 0xDC: 0x00
===========================

Chip ID: 32768
Looks like driver chip is: Unknown

Picture on the display easily recognizable but barely visible, very bright and milky. Here is the picture -

(http://www.sncsoft.com/images/IMG_4421.JPG)

and video of the "graphicstest" -

http://www.sncsoft.com/images/IMG_4417.MOV (http://www.sncsoft.com/images/IMG_4417.MOV)

Any suggestions?

By the way, other displays with ST7735 working fine with the same setup (yes, I select proper driver in User_Setup.h. :-)

Thank you!





Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: Palirose on Jan 01, 2018, 01:43 pm
Hi, We have this LCD:
(http://s8.picofile.com/file/8315685068/2_QryT13VUre.jpg)

and arrange wires in this way:
(http://s9.picofile.com/file/8315685092/unotft_N6ib65wiAQ.png)

Then we use TFT.h library (if you don't see it in the list of examples, search on sketh>include library>manage library and install it)

try examples of this library. it works for us :)
besides, "dc" pin is A0

(forget about using the ST7735 library and Adafruit GFX Library. they didn't work for us)
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: hapra on Feb 17, 2018, 11:42 pm
Hi Bodmer,

After many hours I always failed trying with others library, finally I found this thread.

At first, I identified this driver with your code (msg #13) and showed driver chip ILI9163.
Then, I tested TFT_Char_times.ino and TFT_ILI9163 library, more than 1 hour running without any problem.

I dont use resistor divider on the logic lines, except resistor 47 ohm to feed LED+ from 5V.
Fyi, I dont try SD card yet, coz still trying for TFT only, is it possible to use SD library ?

Thank you very much Bodmer.
You are a genius among geniuses !
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Feb 22, 2018, 02:13 am
@hapra

Thanks for the feedback and the connection image. Great to hear it works for you.

Yes, you can use the SD card with the TFT library. You need to configure the chips slectect and enable transaction support in the setup file.
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: kinvolute on Mar 14, 2018, 04:17 pm
Bodmer,

Thank you for your time and patience in posting and troubleshooting these displays.  It looks like there are several iterations of this display using the same designations.  Unfortunately, I'm still struggling to get mine to work. I am getting streaking, static, and ghosts.

All,
I bought several of the "KMR-1.8 SPI" "ST7735" displays from eBay. The parts bags have the following identifiers: SKU276159 EVK  122--300503--300503."  The display itself has the following  identifier on the top edge: MYT-1610-180-M2015-10-27" Please help me get this display running.

I am using an Uno clone.

Using the identification script (post #13) My display comes up as "unknown"
TFT driver register values:
===========================
Register 0x01: 0x00
Register 0x04: 0x9102
Register 0x09: 0x610000
Register 0x0A: 0x08
Register 0x0B: 0x00
Register 0x0C: 0x06
Register 0x0D: 0x00
Register 0x0E: 0x00
Register 0x0F: 0x00
Register 0x2E: 0xFFFFFF
Register 0xDA: 0x00
Register 0xDB: 0x91
Register 0xDC: 0x02
===========================

Looks like driver chip is: Unknown

Wiring:
Uno                       Display
8 (DC)                   A0
9 (RST)                 RESET
10 (CS)                 CS
11 (MOSI)             SDA
13 (SCLK)             SCL

GND                      GND
5V                         VCC

GND                      LED-
3.3V                      LED+ Note: this is temporary LED will be PWM on pin 3 eventually with a resistor inline (R value unknown)

Drivers attempted:
TFT_ST7735.h   (INITB, GREENTAB, REDTAB, BLACKTAB, GREENTAB2)
TFT_S6D02A1.h
TFT_ILI9163.h
ADAFruit ST7735

TFT_ST7735.h BLACKTAB worked the "best" but none were right.  

I also tried adding a 1K2 (1.25k 1%)Resistors on 8,9,10,11 and 13. Unfortunately, not will all drivers. Alas, no worky.

As a neophyte and have been researching to make as much progress as I can.  But, I'm at an impasse. Driver code doesn't appear to work properly and I'm struggling with the resistors.  Do I need them? on which leads? I have not yet tried a voltage divider. Do I need a voltage divider?


Attached are front of display, rear of display, flex circuit of display, and an example of the display errors.

Thanks in advance.

Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: Endian on Mar 14, 2018, 05:20 pm
I have not come across that chip ID before.

It could be a Galaxy Core GC9102 driver as that fits the screen resolution. Unfortunately if this is the case then it may need a different setup command set and that is why the display appears corrupted.

Can you provide a link to the seller?

Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: kinvolute on Mar 14, 2018, 05:46 pm
https://www.ebay.com/itm/391595425518
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: kinvolute on Mar 14, 2018, 06:51 pm
I have not come across that chip ID before.

It could be a Galaxy Core GC9102 driver as that fits the screen resolution. Unfortunately if this is the case then it may need a different setup command set and that is why the display appears corrupted.

Can you provide a link to the seller?


IF it is GC9102, This is the only spec I can find. 
http://www.melt.com.ru/docs/GC9102DS_V100_20130410.pdf
It is Greek to me.
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: bodmer on Mar 17, 2018, 02:04 am
Unfortunately I do not recognise that TFT ID code. It may need a different inialisation sequence that is not supported by the library.

Sometimes these displays do not work porpoerly unless driven by 3.3V logic (a standard  UNO is 5V), so adding a resistor divider on all used UNO digital output pins may solve the problem, as described here (https://www.instructables.com/id/Arduino-TFT-display-and-font-library/).  You may need a series resistor and one down to GND as descrived for the ILI9341 display is Step 1 of the Instructable.
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: DoggleDragon on Aug 09, 2018, 07:26 am
Thank you so much Bodmer!
This totally saved me!
Title: Re: Graphics library for cheap KMR-1.8 SPI (S6D02A1 and ILI9163) TFT displays
Post by: kroschka on Feb 05, 2019, 09:10 pm
Hi Bodmer,
thank you very much for your work.

I have one Problem.
Is it possible to change CS Pin that i can connect more Displays.
For my Project i need to connect 4 TFTs.

I searched the Web, but i didnt found something.

It would be great if you have a answer for me.