TFT with ILI9163C and MCU control

Edit the CPP file. Hint. Look for case 0x9163: and change the lcd_capable line to

#ifdef SUPPORT_9163
    case 0x9163:                //
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | INVERT_GS | READ_24BITS;

I have changed this and there are no changes ... it shows the same.

I don't believe you.
What is printed on the Serial Terminal?

Please copy-paste the lines from your MCUFRIEND_kbv.cpp that correspond to #20.

This is what the whole block should look like:

#ifdef SUPPORT_9163
    case 0x9163:                //
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | INVERT_GS | READ_24BITS;
        static const uint8_t PROGMEM table9163C[] = {
            //  (COMMAND_BYTE), n, data_bytes....
            0x26, 1, 0x04,       // [01] GAMMASET
            0xF2, 1, 0x01,       // [00] GAMRSEL
            0xE0, 16, 0x0f, 0x1a, 0x0f, 0x18, 0x2f, 0x28, 0x20, 0x22, 0x1f, 0x1b, 0x23, 0x37, 0x00, 0x07, 0x02, 0x10,
            0xE1, 16, 0x0f, 0x1b, 0x0f, 0x17, 0x33, 0x2c, 0x29, 0x2e, 0x30, 0x30, 0x39, 0x3f, 0x00, 0x07, 0x03, 0x10,
            0xB1, 2, 0x08, 0x02,  //[0E 14] FRMCTR1 if GM==011 61.7Hz
            0xB4, 1, 0x07,       // [02] INVCTR
            0xC0, 2, 0x0A, 0x02, // [0A 05] PWCTR1 if LCM==10
            0xC1, 1, 0x02,       // [07] PWCTR2
            0xC5, 2, 0x50, 0x63, // [43 4D] VMCTR1
            0xC7, 1, 0,          // [40] VCOMOFFS
            //  0x33, 6, 0, 0, 0, 128 + 0, 0, 0, //VSCLLDEF
        };
        table8_ads = table9163C, table_size = sizeof(table9163C);   //
        p16 = (int16_t *) & HEIGHT;
        *p16 = 160;
        p16 = (int16_t *) & WIDTH;
        *p16 = 128;
        break;
#endif

David.

This is the result on Serial Terminal:

Serial took 0ms to start
ID = 0x9163

This is my code on MCUFRIEND_kbv.cpp:

#ifdef SUPPORT_9163
    case 0x9163:                //
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | REV_SCREEN | READ_24BITS;
        static const uint8_t PROGMEM table9163C[] = {
            //  (COMMAND_BYTE), n, data_bytes....
            0x26, 1, 0x04,       // [01] GAMMASET
            0xF2, 1, 0x01,       // [00] GAMRSEL
            0xE0, 16, 0x0f, 0x1a, 0x0f, 0x18, 0x2f, 0x28, 0x20, 0x22, 0x1f, 0x1b, 0x23, 0x37, 0x00, 0x07, 0x02, 0x10,
            0xE1, 16, 0x0f, 0x1b, 0x0f, 0x17, 0x33, 0x2c, 0x29, 0x2e, 0x30, 0x30, 0x39, 0x3f, 0x00, 0x07, 0x03, 0x10,
            0xB1, 2, 0x08, 0x02,  //[0E 14] FRMCTR1 if GM==011 61.7Hz
            0xB4, 1, 0x07,       // [02] INVCTR
            0xC0, 2, 0x0A, 0x02, // [0A 05] PWCTR1 if LCM==10
            0xC1, 1, 0x02,       // [07] PWCTR2
            0xC5, 2, 0x50, 0x63, // [43 4D] VMCTR1
            0xC7, 1, 0,          // [40] VCOMOFFS
            //  0x33, 6, 0, 0, 0, 128 + 0, 0, 0, //VSCLLDEF
        };
        table8_ads = table9163C, table_size = sizeof(table9163C);   //
        p16 = (int16_t *) & HEIGHT;
        *p16 = 160;
        p16 = (int16_t *) & WIDTH;
        *p16 = 128;
        break;
#endif

And this is my screen:
screen1_.jpg

screen1_.jpg

Your version with inverted colours (REV_SCREEN) and upside down printing

        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | REV_SCREEN | READ_24BITS;

My version with correct colours and correct Gate Scan

        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | INVERT_GS | READ_24BITS;

I am 99.9% confident that this should fix the display.

Does the Vertical Scroll and Band Scroll work ?
I am not sure if you will be able to see Software Scroll.
I was expecting to see the "WiFi Full" icon instead of a Penguin.
Or was it too big for your Pro Mini? (the Pro Mini bootloader is bigger than a Uno bootloader)

David.

I got it!!! :grinning:

Right, that was the problem. I don't know why the changes had not been saved and the previous version was running.

This is the result:

f_1.jpg

Thank you very much for your help David! It has been very useful.

f_1.jpg

Please run the examples. Make notes.

Does Vertical Scroll work?
Your photo seems to show a stationary image.

Many examples will adjust to the screen dimensions.
I have only used MCUFRIEND_kbv with 176x220, 240x320, 240x400, 320x480, 800x480

I would like to know if and how they work on your 128x160 display.

A recent question seems to be about a Mcufriend 1.8 inch display.
Your experience can help me answer.

David.

I have executed different examples and it works. Yes, vertical scroll works. I think I have to modify some elements to adjust it exactly to 1.8 '', since I believe that some elements are possibly lost by the difference in screen size. Correct me if I'm wrong.

In this link you can see a short video of the working screen:

https://we.tl/t-92KoqhX0gX

tractor.jpg

tractor.jpg

Looking at your photo, the ribbon comes out of the screen on the right hand side.
If you rotate the photo 90 degrees clockwise, the ribbon comes out of the bottom of the screen. Your cables come out of the top of the screen.

Your video is showing vertical scroll in the wrong direction.
For Landscape (GREEN) I would expect UP to show the screen moving right to left.
For Portrait (BLUE) I would expect UP to show the screen moving from bottom to top

I only have SPI 128x128 ILI9163C
I have an SPI 128x160 ST7735
I will run the "drawBitmap_kbv" example on the SPI screens. (with my SPI kbv library not parallel MCUFRIEND_kbv)

I am not sure why the scroll directions are wrong.

David.

I will continue working on this. If you have news please let me know.

Thanks!

Nuria.

Sorry about forgetting you. I have updated the Branch on GitHub.

Please can you try it. I hope that it corrects the scroll directions.

David.

Previously I had download "test_9163" Branch and it doesn't works. Then I downloaded "master" and modified code in this and finally it works, but how you say, showing vertical scroll in the wrong direction.

Now I have tried both methods for test it but I can't get it to work, the screen is in white color. Could you tell me what lines do you have modified now and I try to modify it in my previous version?

I would expect the "test_9163" to work because I have already enabled SUPPORT_9163 for you.
I would expect the "master" to work if you enable SUPPORT_9163 in MCUFRIEND_kbv.cpp

The change that I made was to

    case 0x9163:                //
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | READ_24BITS;
        static const uint8_t PROGMEM table9163C[] = {
            //  (COMMAND_BYTE), n, data_bytes....
            0x26, 1, 0x04,       // [01] GAMMASET
            0xF2, 1, 0x01,       // [00] GAMRSEL
            0xE0, 16, 0x0f, 0x1a, 0x0f, 0x18, 0x2f, 0x28, 0x20, 0x22, 0x1f, 0x1b, 0x23, 0x37, 0x00, 0x07, 0x02, 0x10,
            0xE1, 16, 0x0f, 0x1b, 0x0f, 0x17, 0x33, 0x2c, 0x29, 0x2e, 0x30, 0x30, 0x39, 0x3f, 0x00, 0x07, 0x03, 0x10,
            0xB1, 2, 0x08, 0x02,  //[0E 14] FRMCTR1 if GM==011 61.7Hz
            0xB4, 1, 0x07,       // [02] INVCTR
            0xB8, 1, 0x01,       // [00] GSCTRL
            0xC0, 2, 0x0A, 0x02, // [0A 05] PWCTR1 if LCM==10
            0xC1, 1, 0x02,       // [07] PWCTR2
            0xC5, 2, 0x50, 0x63, // [43 4D] VMCTR1
            0xC7, 1, 0,          // [40] VCOMOFFS
            //  0x33, 6, 0, 0, 0, 128 + 0, 0, 0, //VSCLLDEF
        };

If you have a white screen, change it back to

    case 0x9163:                //
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | INVERT_GS | READ_24BITS;
        static const uint8_t PROGMEM table9163C[] = {
            //  (COMMAND_BYTE), n, data_bytes....
            0x26, 1, 0x04,       // [01] GAMMASET
            0xF2, 1, 0x01,       // [00] GAMRSEL
            0xE0, 16, 0x0f, 0x1a, 0x0f, 0x18, 0x2f, 0x28, 0x20, 0x22, 0x1f, 0x1b, 0x23, 0x37, 0x00, 0x07, 0x02, 0x10,
            0xE1, 16, 0x0f, 0x1b, 0x0f, 0x17, 0x33, 0x2c, 0x29, 0x2e, 0x30, 0x30, 0x39, 0x3f, 0x00, 0x07, 0x03, 0x10,
            0xB1, 2, 0x08, 0x02,  //[0E 14] FRMCTR1 if GM==011 61.7Hz
            0xB4, 1, 0x07,       // [02] INVCTR
//            0xB8, 1, 0x01,       // [00] GSCTRL
            0xC0, 2, 0x0A, 0x02, // [0A 05] PWCTR1 if LCM==10
            0xC1, 1, 0x02,       // [07] PWCTR2
            0xC5, 2, 0x50, 0x63, // [43 4D] VMCTR1
            0xC7, 1, 0,          // [40] VCOMOFFS
            //  0x33, 6, 0, 0, 0, 128 + 0, 0, 0, //VSCLLDEF
        };

and I will have to find another way to fix the scroll direction.

David.

Edit. I have changed GSCTRL on an SPI ILI9163 and it works fine. So I see no problem.

The first steps in ANY test is to read the ID and any messages written on the Serial Terminal.
Then make careful notes on paper about what you have done.

Life is much simpler (for me) if you are a GitHub member and have cloned the project. You can access my Branch at any time.

You can always re-install a library from GitHub and start again.

I have run SUPPORT_9163.

This is the result. But I am not sure what you say that it's not ok.

https://we.tl/t-TejTbMAji8

The scroll directions are still wrong.

BLUE SCROLL DN moves up (instead of DOWN)
BLUE BAND moves down (instead of UP)
GREEN SCROLL UP is to the right (instead of to the left)
GREEN SCROLL DN is to the left (instead of to the right)
RED SCROLL UP moves down (instead of UP)
RED BAND moves down (instead of UP)

I presume that you have used today's "master" from GitHub (with SUPPORT_9163)

Thanks for the feedback. I will have to think hard !!

David.

I was looking at the ILI9163 data sheet and noticed that you reported:

reg(0x00D3) 00 91 63 00 ILI9341, ILI9488
reg(0x00D4) 00 00 00 00 Novatek ID
reg(0x00DA) 00 54 RDID1
reg(0x00DB) 00 80 RDID2
reg(0x00DC) 00 66 RDID3

The ILI9163 datasheet says that reg(0xD3) should be

reg(0x00D3) xx 01 21 YY xx    //RDID4 where YY is Driver IC version ID

So perhaps your controller was not made by Ilitek.

Unfortunately I can only read certain registers with the SPI interface. e.g. 0x04, 0xDA, 0xDB, 0xDC which are all correct.
I would be very interested in reading all the other registers via LCD_ID_readreg. This is only possible with a parallel interface.

Yes, I can correct the directions in #34 on my SPI ILI9163.
Did you make the video in #33 with the current "test_9163" Branch from GitHub?
This branch has already enabled SUPPORT_9163

David.

Yes, the video in #33 is done with "test_9163" Branch from GitHub.

I will continue trying it, if I have news I say to you.

Thanks!

Please can you run the LCD_ID_readnew.ino sketch from the examples.
Replace setup() with this function.

void setup()
{
    Serial.begin(9600);
    while (!Serial) ;
    Serial.println(F("Read Registers on MCUFRIEND UNO shield"));
    Serial.println(F("controllers either read as single 16-bit"));
    Serial.println(F("e.g. the ID is at readReg(0)"));
    Serial.println(F("or as a sequence of 8-bit values"));
    Serial.println(F("in special locations (first is dummy)"));
    Serial.println(F(""));
    lcdInit();
    lcdReset();      //ensures that controller is in default state
    //    unlock = unlock_1520;
    //    unlock = unlock_1526;
    //    unlock = unlock_8357;
    //    unlock = unlock_5310;
    //    page_N = d5310_1_in;
    //    for (uint16_t i = 0x00; i <= 0xFE; i++) readReg(i, 10, "f.k");
//    read_regs("diagnose any controller");
    //    read_xxxx("mystery");
    //    read_5310_P0("NT35310 P0");
    //    read_5310_P1("NT35310 P1");
    //    read_61509("R61509 / ILI9326");
    //    read_61526("R61520 / R61526");
    //    read_8357("HX8357X");
    //    read_9320("ILI9320");
    //    read_9327("ILI9327");
    read_9338("ILI9302 / ILI9329 / ILI9338 / ILI9341");
    //    read_9481("ILI9481 / HX8357-B / R61581");
    //    read_9486("ILI9486 / 1LI9488");
}

Copy-paste the Serial Terminal to your message.

Then run the sketch in the attachment.
I suspect that all the scroll directions will be wrong. Which are correct?
Please observe Marilyn. Different Gammas (1 - 4) are used. Which is the best picture?

David.

diagnose_rotation.zip (20.5 KB)

I have tested LCD_ID_readnew.ino with replacement, this is the message in Serial Terminal.

Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

ILI9302 / ILI9329 / ILI9338 / ILI9341
reg(0x0004) 00 54 80 66	Manufacturer ID
reg(0x0009) 00 00 61 00 00	Status Register
reg(0x000A) 00 08	Get Powsr Mode
reg(0x000B) 00 00	Get Address Mode
reg(0x000C) 00 06	Get Pixel Format
reg(0x000D) 00 00	Get Display Mode
reg(0x000E) 00 00	Get Signal Mode
reg(0x000F) 00 00	Get Diagnostic Result
reg(0x00B0) 00 00	Interface Mode
reg(0x00B1) 00 0E 14	Frame Rate Normal
reg(0x00B2) 00 0E 14	Frame Rate Idle
reg(0x00B3) 00 0E 14	Frame Rate Partial
reg(0x00B4) 00 02 02	Inversion Control
reg(0x00B5) 00 08 03 00 00	Blanking Porch
reg(0x00B6) 00 06 02 02	Display Control
reg(0x00B7) 00 00	Entry Mode Set
reg(0x00C0) 00 0A	Power Control 1
reg(0x00C1) 00 05	Power Control 2
reg(0x00C2) 00 00	Power Control 3
reg(0x00C3) 00 00	Power Control 4
reg(0x00C4) 00 00	Power Control 5
reg(0x00C5) 00 3C 48	VCOM Control 1
reg(0x00C7) 00 40	VCOM Control 2
reg(0x00D2) 00 00 00	NVM Status
reg(0x00D3) 00 91 63 00	RDID4
reg(0x00DA) 00 54	RDID1
reg(0x00DB) 00 00	RDID2
reg(0x00DC) 00 66	RDID3
reg(0x00E0) 00 0F 1A 0F 18 2F 08 20 22 1F 1B 23 37 00 07 02	GAMMA-P
reg(0x00E1) 00 0F 1B 0F 17 33 0C 29 2E 30 10 39 3F 00 07 03	GAMMA-N
reg(0x00F2) 00 00	GAMMA-3G
reg(0x00F6) 00 00 00 00	Interface Control

This is a video of the result of the attached example.
https://we.tl/t-gEOOPFJQ46

It's ok, true?

Woo-hoo. The Rotations are correct. The Directions are correct.

Gamma set #2 looks best from the video. Which is best from your real-life eyes ?

Please edit the setGamma() function to change to tft.pushCommand(0xF2, &on, 1);
Run the sketch again. It will use the Gamma settings from begin() instead of the fixed curves.

I am a little surprised by reg(0xDB). I expected to see 0x80

reg(0x0004) 00 54 80 66	Manufacturer ID
...
reg(0x00DA) 00 54	RDID1
reg(0x00DB) 00 00	RDID2
reg(0x00DC) 00 66	RDID3

Thanks for the feedback.

David.