Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with ILI9163 128x128 display? #10

Closed
larsenglund opened this issue Apr 14, 2017 · 16 comments
Closed

Not working with ILI9163 128x128 display? #10

larsenglund opened this issue Apr 14, 2017 · 16 comments

Comments

@larsenglund
Copy link

larsenglund commented Apr 14, 2017

Hi! I'm trying to use this library with a 128x128 ILI9163 display. The display works fine with this library: https://github.com/sumotoy/TFT_ILI9163C (my display is just like the one in the picture in the readme for that library, red pcb with blue tab on the display protector). I have set #define ILI9163_DRIVER in User_Setup.h and I am overriding the width in the constructor with TFT_eSPI tft = TFT_eSPI(128, 128);. I am using the following pin defines:

#define TFT_CS   15  // Chip select control pin
#define TFT_DC   0  // Data Command control pin
#define TFT_RST  -1  // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST

And GPIO12 (MISO) is unconnected since the display does not have that pin.
TFT_RST of the display is pulled up to 3.3V via a 10k resistor.
In setup() I turn the power to the display on right before calling tft.init();
I have the Arduino IDE set to NodeMCU 1.0 & 160MHz.
I have tried a couple of the examples (TFT_Print_Test, TFT_Ellipse, TFT_Starfield) but I only get a pure white display. Any thoughts on what might be the problem?

(Note: When using sumotoy:s library i use #include "../_display/TFT_ILI9163C_RED_PCB_OLD.h" in _settings/TFT_ILI9163C_settings.h)

@Bodmer
Copy link
Owner

Bodmer commented Apr 15, 2017

A white screen means the TFT is not being configured correctly at start up.

Do you mean you power the display at the start of setup? If so try waiting for say 200ms after switching on the display before trying to initialize it.

I had a quick look at the sumotoys library, I don't see #include "../_display/TFT_ILI9163C_RED_PCB_OLD.h" in _settings/TFT_ILI9163C_settings.h) so I can't check the config settings and see if mine are the same. If you do get it running it should run a bit faster than the Teensy 3 performance figures I see are quoted.

@larsenglund
Copy link
Author

Thanks for the quick reply!
Yes I power the display on at the start of setup() (using a mosfet) and I have tried adding 1 second delay after (even though It's not needed when using sumotoys library).

Sorry, forgot to mention that I use the Pre-Release-1.0p7 branch. The header is available here:
https://github.com/sumotoy/TFT_ILI9163C/blob/Pre-Release-1.0p7/_display/TFT_ILI9163C_RED_PCB_OLD.h

@Bodmer
Copy link
Owner

Bodmer commented Apr 15, 2017

OK, thanks.
I had a look at the configuration file and it is different to the one used in the TFT_eSPI library.

So it looks like the TFT_eSPI library will not work with your particular display setup. This situation may change in the future but at the moment I do not have a similar display to develop and test.

@Bodmer Bodmer closed this as completed Apr 15, 2017
@larsenglund
Copy link
Author

Hmm, ok, how would you go about adapting to the display if you had one? I could give it a try but could use som pointers. I'm guessing it's more to it than taking your ILI9163-config and exchanging some register definitions..

@Bodmer
Copy link
Owner

Bodmer commented Apr 16, 2017

All the TFT driver specific stuff is in the TFT_Drivers folder, for each chip designation there are 3 files. X_defines which set up register names etc, X_init which is the display initialisation code run at startup and X_rotation which handles the register changes and offsets needed when the diplay orientation is changed.

So those are the key files to adapt.

I have updated my copy of the library recently to add support for a ST7735 128x128 display I will upload to Github later today. This will handle the offsets needed for certain display rotations If I have time I will make a "best guess" update for your display for you to try, based on the sumotoy code, but this will be untested.

@larsenglund
Copy link
Author

Awesome, I hope you do get the time, looking forward to trying it out!

@Bodmer
Copy link
Owner

Bodmer commented Apr 18, 2017

Hi can you try 2 things:

  1. Load the Read_ID_bitbash sketch in the ILI9341 example set, change the pin settings in the sketch and report the output seen on the Serial Terminal (115200 baud)
  2. Try the S6D02A1 driver (typically this works OK with an ILI9163C)

@Bodmer Bodmer reopened this Apr 18, 2017
@larsenglund
Copy link
Author

Hi! Read ID gives me this:

tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld
TFT driver register values:
===========================
Register 0x01: 0x00
Register 0x04: 0x548066
Register 0x09: 0x4510000
Register 0x0A: 0x08
Register 0x0B: 0x08
Register 0x0C: 0x05
Register 0x0D: 0x00
Register 0x0E: 0x00
Register 0x0F: 0x00
Register 0x2E: 0x00
Register 0x3F: 0xFFFFFFFF
Register 0xDA: 0x54
Register 0xDB: 0x80
Register 0xDC: 0x66
===========================

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

The S6D02A1 driver gives me a dark grey display on the same examples as I tried before that gave me a white screen.

@Bodmer
Copy link
Owner

Bodmer commented Apr 18, 2017

I have made a minor change to the file here so sleep mode exit is enabled.

Can you test it with this updated file?

@larsenglund
Copy link
Author

larsenglund commented Apr 18, 2017

It works!... almost perfect - set rotation seems to still think the display is 128x160 even though I have set it to 128x128 in ILI9163_Defines.h and the TFT_eSPI constructor. When using this code:

for (int i = 0; i < 4; i++)
  {
    tft.setRotation(i);
    tft.fillScreen(TFT_DARKGREEN);
    tft.drawRect(0,0,128,128, TFT_YELLOW);
    tft.fillRect(2,2,10,10, TFT_RED);
    tft.fillRect(128-12,128-12,10,10, TFT_BLACK);
    tft.setCursor(12, 128/2, 1);
    tft.setTextColor(TFT_WHITE,TFT_BLUE);  tft.setTextSize(1);
    tft.println("Hello World!");
    delay(2000);
  }

I get this:
Image of Yaktocat

Besides the rotation problem I can happily report that I don't need a delay between powering the TFT on and calling init:

pinMode(TFT_PWR_EN, OUTPUT);
digitalWrite(TFT_PWR_EN, 0);
tft.init();

And that it seems to init the display a bit faster than other libraries.
Thanks alot for your time and the quick fix!

@Bodmer
Copy link
Owner

Bodmer commented Apr 18, 2017

OK, the offsets are expected.
Now I know the display driver works OK with your display. I will update the library later to correct those.

@larsenglund
Copy link
Author

Awesome, thanks again!

@Bodmer
Copy link
Owner

Bodmer commented Apr 18, 2017

OK, have uploaded the offset fix.

You need to define the display size in the setup.h file inside the library for this to work, e.g. in "User_Setup.h" (or in you custom user setup file in the "User_Setups" folder).

@Bodmer Bodmer closed this as completed Apr 18, 2017
@larsenglund
Copy link
Author

larsenglund commented Apr 19, 2017

Hi, the image it is constantly cropped now instead of only being cropped at certain rotations. These are the correct offsets:

// This is the command sequence that rotates the ILI9163 driver coordinate frame

  rotation = m % 4;

  writecommand(TFT_MADCTL);
  switch (rotation) {
    case 0:
      writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
      _width  = TFT_WIDTH;
      _height = TFT_HEIGHT;
	  #ifdef CGRAM_OFFSET
        colstart = 0;
        rowstart = 0;
	  #endif
      break;
    case 1:
      writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR);
      _width  = TFT_HEIGHT;
      _height = TFT_WIDTH;
	  #ifdef CGRAM_OFFSET
        colstart = 0;
        rowstart = 0;
	  #endif
      break;
    case 2:
      writedata(TFT_MAD_BGR);
      _width  = TFT_WIDTH;
      _height = TFT_HEIGHT;
	  #ifdef CGRAM_OFFSET
        colstart = 0;
        rowstart = 32;
	  #endif
      break;
    case 3:
      writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
      _width  = TFT_HEIGHT;
      _height = TFT_WIDTH;
	  #ifdef CGRAM_OFFSET
        colstart = 32;
        rowstart = 0;
	  #endif
      break;
  }

@Bodmer
Copy link
Owner

Bodmer commented Apr 19, 2017

OK, thanks. It was a 50:50 guess which end of the display CGRAM the vendor had wired the pixels!

@Bodmer
Copy link
Owner

Bodmer commented Apr 23, 2017

The offsets have been corrected in the master library. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants