nopnop2002 / Raspberry-ili9325

Parallel TFT Shield Library for wiringPi
64 stars 14 forks source link

ili9486 8 Bit Parallel - Raspberry Pi #31

Closed CoolCheesecake784 closed 3 years ago

CoolCheesecake784 commented 3 years ago

Hello nopnop2002,

I have been trying to find a way to get my 3.5" ili9486 8 Bit Parallel display to work with my Raspberry Pi. The closest I have been to succeeding is with the drivers I have found in your Raspberry-ili9325.

I initially tried running my screen as an ili9341, this worked to a degree, when I ran ./demo the screen flickered and showed a few rectangles, the word "ili9431" and the centre of some circles. certainly not perfect but better than I had achieved before. the ili9481 drivers didn't seem to be as good.

So I looked at the code in "ili93xx.c", "demo.c", "draw.c" and "pin.conf" and thought it wouldn't be too difficult to include ili9486 as a new display. I think I have succeeded with this but the screen is still not working properly, I get rectangles of the correct size and more colours now, but still not getting the demo I am expecting. I seem to be able to make it worse and better by changing the init sequence.

The init sequence I am using is one I found in your file "STM32_TFT_8bit.cpp", I wonder if you had any ideas on what parameters would be worth tweaking to try and get this screen working?

Many thanks

// ILI9486
  } else if (_model == 0x9486) {
   static const uint8_t regValues[] = {
            0xC0, 2, 0x0d, 0x0d,        //Power Control 1 [0E 0E]
            0xC1, 2, 0x43, 0x00,        //Power Control 2 [43 00]
            0xC2, 1, 0x00,      //Power Control 3 [33]
            0xC5, 4, 0x00, 0x48, 0x00, 0x48,    //VCOM  Control 1 [00 40 00 40]
            0xB4, 1, 0x00,      //Inversion Control [00]
            0xB6, 3, 0x02, 0x02, 0x3B,  // Display Function Control [02 02 3B]
            0xE0, 15, 0x0F, 0x1F, 0x1C, 0x0C, 0x0F, 0x08, 0x48, 0x98, 0x37, 0x0A, 0x13, 0x04, 0x11, 0x0D, 0x00, 
            0xE1, 15, 0x0F, 0x32, 0x2E, 0x0B, 0x0D, 0x05, 0x47, 0x75, 0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00, 
    };
    init_table(reset_off, sizeof(reset_off));
    init_table(regValues, sizeof(regValues));
    init_table(wake_on, sizeof(wake_on));
nopnop2002 commented 3 years ago

First of all, you need to use this to check if your TFT is really ili9486. https://github.com/nopnop2002/Raspberry_LCD_ID_Reader

This is the ili9486 I have. reg(0x00D3) 00 00 94 86 ILI9341, ILI9488

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)

reg(0x0000) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
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(0x000C) 00 66   Get Pixel Format
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   RDID2 HX8347-G
reg(0x0063) 00 00   RDID3 HX8347-G
reg(0x0064) 00 00   RDID1 HX8347-A
reg(0x0065) 00 00   RDID2 HX8347-A
reg(0x0066) 00 00   RDID3 HX8347-A
reg(0x0067) 00 00   RDID Himax HX8347-A
reg(0x0070) 00 00   Panel Himax HX8347-A
reg(0x00A1) 00 93 30 93 30  RD_DDB SSD1963
reg(0x00B0) 00 00   RGB Interface Signal Control
reg(0x00B4) 00 00   Inversion Control
reg(0x00B6) 00 02 02 3B 3B  Display Control
reg(0x00B7) 00 06   Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00   ILI9481, HX8357-B
reg(0x00C0) 00 0E 0E 0E 0E 0E 0E 0E 0E  Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00  GAMMA
reg(0x00CC) 00 04   Panel Control
reg(0x00D0) 00 00 00    Power Control
reg(0x00D2) 00 00 00 00 00  NVM Read
reg(0x00D3) 00 00 94 86 ILI9341, ILI9488
reg(0x00DA) 00 54   RDID1
reg(0x00DB) 00 80   RDID2
reg(0x00DC) 00 66   RDID3
reg(0x00E0) 00 07 0F 29 0A 1B 0D 69 B3 37 04 07 07 0D 03 0A GAMMA-P
reg(0x00E1) 00 08 3F 2B 05 0F 06 2E 35 26 0D 0E 03 2F 2E 0D GAMMA-N
reg(0x00EF) 00 80 00 10 60 40   ILI9327
reg(0x00F2) 00 18 A3 12 02 B2 12 FF 10 00 00 00 Adjust Control 2
reg(0x00F6) 00 54 80 66 Interface Control
nopnop2002 commented 3 years ago

If your TFT is really ili9486, try this.

    static const uint8_t regValues[] = {
        0xB0, 1, 0x00,              // unlocks E0, F0
        0xB3, 4, 0x02, 0x00, 0x00, 0x00, //Frame Memory, interface [02 00 00 00]
        0xB4, 1, 0x00,              // Frame mode [00]
        //0xB6, 3, 0x02, 0x02, 0x3B,  // Display Function Control [02 02 3B]
        0xB6, 3, 0x02, 0x42, 0x3B,  // Display Function Control [02 02 3B]
        0xD0, 3, 0x07, 0x42, 0x18,
        0xD1, 3, 0x00, 0x07, 0x18,
        0xD2, 2, 0x01, 0x02,
        0xD3, 2, 0x01, 0x02,        // Set Power for Partial Mode [01 22]
        0xD4, 2, 0x01, 0x02,        // Set Power for Idle Mode [01 22]
        //0xC0, 5, 0x10, 0x3B, 0x00, 0x02, 0x11,
        0xC0, 5, 0x14, 0x3B, 0x00, 0x02, 0x11,
        0xC1, 3, 0x10, 0x10, 0x88,  // Display Timing Normal [10 10 88]
        0xC5, 1, 0x03,      //Frame Rate [03]
        0xC6, 1, 0x02,      //Interface Control [02]
        0xC8, 12, 0x00, 0x32, 0x36, 0x45, 0x06, 0x16, 0x37, 0x75, 0x77, 0x54, 0x0C, 0x00,
        0xCC, 1, 0x00,      //Panel Control [00]
        0x36, 1, 0x18, //0x08,
    };
    lcd_write_table(dev, reset_off, sizeof(reset_off));
    lcd_write_table(dev, regValues, sizeof(regValues));
    lcd_write_table(dev, wake_on, sizeof(wake_on));
CoolCheesecake784 commented 3 years ago

I have confirmed that my TFT is indeed an ili9486, I get the same output as yours both from my Ardunio UNO and Raspberry Pi. Whilst trying to confirm my TFT on the RPi I realised that I had not connected the LCD_RD pin! I made a bad assumption that I didn't need to read from the display trying to save on connections.

Now that LCD_RD is connected I get a much better response using my original init sequence. However, the colours were all wrong, so I tested the init sequence you suggested and this gives the colours I was expecting. One issue though is that the image is mirrored?

The demo, draw and me.sh examples seem to run ok now, but everything is mirrored.

I have looked through the datasheet but can't see any reference to mirroring the screen? have you seen this before?

Thank you so much for your help.

nopnop2002 commented 3 years ago

Change either or both of the following:

        //0xB6, 3, 0x02, 0x02, 0x3B,  // Display Function Control [02 02 3B]
        0xB6, 3, 0x02, 0x42, 0x3B,  // Display Function Control [02 02 3B]

        //0xC0, 5, 0x10, 0x3B, 0x00, 0x02, 0x11,
        0xC0, 5, 0x14, 0x3B, 0x00, 0x02, 0x11,

Maybe 0xB6 ....

CoolCheesecake784 commented 3 years ago

I tried swapping the 0xB6 terms as you suggested and it worked, thank you. demo and all other examples run as expected.

I couldn't find 0xD4 in the data sheet for ili9486 so thought I would see what removing it would do? couldn't see any difference with or without it so I have commented it out.

Thank you for all your help.

My working init sequence is:

static const uint8_t regValues[] = {
        0xB0, 1, 0x00,              // unlocks E0, F0
        0xB3, 4, 0x02, 0x00, 0x00, 0x00, //Frame Memory, interface [02 00 00 00]
        0xB4, 1, 0x00,              // Frame mode [00]
        0xB6, 3, 0x02, 0x02, 0x3B,  // Display Function Control [02 02 3B] (Not Mirrored)
        //0xB6, 3, 0x02, 0x42, 0x3B,  // Display Function Control [02 02 3B] (Mirrored)
        0xD0, 3, 0x07, 0x42, 0x18,
        0xD1, 3, 0x00, 0x07, 0x18,
        0xD2, 2, 0x01, 0x02,
        0xD3, 2, 0x01, 0x02,        // Set Power for Partial Mode [01 22]
        //0xD4, 2, 0x01, 0x02,      // Set Power for Idle Mode [01 22]
        //0xC0, 5, 0x10, 0x3B, 0x00, 0x02, 0x11,
        0xC0, 5, 0x14, 0x3B, 0x00, 0x02, 0x11,
        0xC1, 3, 0x10, 0x10, 0x88,  // Display Timing Normal [10 10 88]
        0xC5, 1, 0x03,      //Frame Rate [03]
        0xC6, 1, 0x02,      //Interface Control [02]
        0xC8, 12, 0x00, 0x32, 0x36, 0x45, 0x06, 0x16, 0x37, 0x75, 0x77, 0x54, 0x0C, 0x00,
        0xCC, 1, 0x00,      //Panel Control [00]
        0x36, 1, 0x18, //0x08,
    };
    lcd_write_table(dev, reset_off, sizeof(reset_off));
    lcd_write_table(dev, regValues, sizeof(regValues));
    lcd_write_table(dev, wake_on, sizeof(wake_on));
nopnop2002 commented 3 years ago

The latest version officially supports ili9486 8 Bit Parallel.