mcufriend 2.8 tft 0139

Hi everyone,

Anyone had any luck with the mcufriend.com LCD with ID 0x0139 ?

I currently use the most recent version of the mcufriend_kbv and they marked it in the MCUFRIEND_kbv.cpp file as "not working +238 bytes".

When I run the graphictest.kbv, it seems to run through all the tests but only display the first pixels line for every test (the rest of the screen remains white). then, after a few times, the test with "Hello World", "123.45", "DEADBEEF" and the "linux pingouin" is displayed, and disappears.

It's like the display tries to show outside the LCD on lines that doean't exists...

Any idea?

Thanks
Francois

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) 01 39 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 00 00 00 Status Register
reg(0x000A) 00 00 Get Power Mode
reg(0x000C) 00 00 Get Pixel Format
reg(0x0061) 00 22 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 00 00 00 00 RD_DDB SSD1963
reg(0x00B0) 00 00 RGB Interface Signal Control
reg(0x00B4) 00 00 Inversion Control
reg(0x00B6) 00 00 00 00 00 Display Control
reg(0x00B7) 00 00 Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00 ILI9481, HX8357-B
reg(0x00C0) 00 00 00 00 00 00 00 00 00 Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA
reg(0x00CC) 00 00 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 00 00 NVM Read
reg(0x00D3) 00 00 00 00 ILI9341, ILI9488
reg(0x00D4) 00 00 00 00 Novatek ID
reg(0x00DA) 00 00 RDID1
reg(0x00DB) 00 00 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-N
reg(0x00EF) 00 00 00 00 00 00 ILI9327
reg(0x00F2) 00 00 00 00 00 00 00 00 00 00 00 00 Adjust Control 2
reg(0x00F6) 00 00 00 00 Interface Control

Woo-hoo. You have a Samsung S6D0139. I have never seen this controller.
You must enable SUPPORT_0139 macro.

Only one user called Mohamed has ever had a S6D0139. I never completed tests with him.

If you are prepared to do some tests, we can probably get you going.

If your shield is a recent purchase there may be a batch appearing on Ebay soon. So it would help any new owners.

David.

Thanks for the fast reply. Yes I'm up to do some testing with you to get it working.

Already activated #define SUPPORT_0139 on the MCUFRIEND_kbv.cpp file.

Here's 2 close-up pictures of the board so you can see the controllers' numbers.

20180412_155446.jpg

I presume you are in France or Belgium. i.e. similar Timezone to the UK.

Please run the graphictest_kbv and the diagnose_controller sketch.

Make notes about what works and what goes wrong.
Or make a video of graphictest_kbv. (Easier than typing notes)

Your photos show a regular Blue 2.8 inch Mcufriend Shield.
It has two 74HC245 buffers and a AMS1117 voltage regulator (for the backlight)

David.

Edit. It was Mamdouh Mahmoud and not Mohammed. And he has a video
It almost works but the Power Control settings are not correct.

I'm actually from Quebec (Canada). Haven't had time to change my profile settings yet.

graphictest_kbv :
Serial Monitor output shows :

Serial took 0ms to start
ID = 0x139

Note : Video link coming soon. I have really slow internet here :wink:

Where should I find the diagnose_controller sketch? I only find diagnose_TFT_support :

Serial Monitor output shows :

Diagnose whether this controller is supported
There are FAQs in extras/mcufriend_how_to.txt

tft.readID() finds: ID = 0x139

MCUFRIEND_kbv version: 2.9.8

PORTRAIT is 240 x 320

Run the examples/graphictest_kbv sketch
All colours, text, directions, rotations, scrolls
should work. If there is a problem, make notes on paper
Post accurate description of problem to Forum
Or post a link to a video (or photos)

I rely on good information from remote users

Yes, diagnose_TFT_support sketch. I could not remember the name.

Quebec is different time. I am going to bed!

David.

Thanks David.

Here's a link to the video I took from the graphictest_kbv

@Francois,

I have put a test_0139 Branch on GitHub.
If you have forked as a GitHub project, you can just change branches.

If you have only installed from the Manager, leave IDE, delete the directory, start IDE, download "test_0139" branch as ZIP. Install from ZIP.

If you find it easier with email, PM me with your email.

David.

Wow thanks. It's working great now (except I think I have a dead pixels row but probably a deffect on the lcd...)

Tested almost all the sketches and even the sdcard is working.

Here is the video of the graphictest_kbv

Really awsome to see you supporting poeples like that :slight_smile:

@Francois,

I don't know if you are using GitHub. Please try this to alter the scan lines:
from this:

            WriteCmdData(0x01, GS | SS_v | (_lcd_ID == 0x0139 ? 0x27 : 0x28));       // set Driver Output Control

replace with this:

            WriteCmdData(0x01, GS | SS_v | (_lcd_ID == 0x0139 ? 0x28 : 0x28));       // set Driver Output Control

The S6D0139 Vertical Scroll works differently. The datasheet is unclear.
from this:

    case 0x0139:
#if 0                                   //disable scroll
        WriteCmdData(0x42, sea);        //SEA
        WriteCmdData(0x43, top);        //SSA
        WriteCmdData(0x41, vsp - top);  //VL# check vsp
#endif
        break;

to this:

    case 0x0139:
#if 1                                   //enable scroll
        WriteCmdData(0x42, sea);        //SEA
        WriteCmdData(0x43, top);        //SSA
        WriteCmdData(0x41, vsp - top);  //VL# check vsp
#endif
        break;

You may need to uncomment VLE1:

//            0x0007, 0x0217,     //Display Control: VLE1=1, SPT=0, GON=1, REV=1, D=3
        };
        init_table16(S6D0139_regValues, sizeof(S6D0139_regValues));

I am assuming you know how to edit a file. Life is much simpler if you could say whether you have a GitHub client.

David.

I do have github account. I'll install it on my computer.

I'm currently uploading new video of graphictest_kbv with the modifications you sent me. Will post you the link in about 40 min... (really slow internet access here sorry).

Thanks
Francois

Here's the link to the video

So you still have the same missing scan lines. The first edit makes no difference.

The second edit just shows Partial Display without any Vertical Scroll.

Did you make the VLE1 edit?

Both videos show bad "SOFTWARE SCROLL".

If you have a slow internet connection, you can either change the delay times to make a shorter video.
Or simply video a shorter sequence e.g. just the Penguin screens.

One single photo of readpixel_kbv in PORTRAIT mode would show the readPixel problem.

I will post some changes directly on the test_0139 Branch tomorrow.

David.

Yes the test is with VLE1 uncommented.

Here's pictures from readpixel_kbv sketch

thanks
francois

Remove the AUTO_READINC atttribute e.g.

#ifdef SUPPORT_0139
    case 0x0139:
        _lcd_capable = REV_SCREEN | XSA_XEA_16BIT;    //remove AUTO_READINC

I am worried about your single white scanline. It makes your display useless.
Try changing from

            0x0008, 0x0808,     //Blank Period:  FP=98, BP=8

to

            0x0008, 0x0303,     //Blank Period:  FP=3, BP=3 as used in S6D0154

Most programs can live without Vertical Scroll.

What difference does VLE1=0 or VLE1=1 make?

It is my bedtime. I will put something on GitHub tomorrow.

David.

Here's the 4 videos for my 4 different tests :
NOTE : On the 2 last videos, the white line at the really beginning seems to display some colors... makes me think it might not be dead pixels after all

_lcd_capable = AUTO_READINC | REV_SCREEN | XSA_XEA_16BIT;
0x0008, 0x0808, //Blank Period: FP=98, BP=8
// 0x0007, 0x0217, //Display Control: VLE1=1, SPT=0, GON=1, REV=1, D=3

Video link : mcufriend 0x0139 vid3 - YouTube


_lcd_capable = AUTO_READINC | REV_SCREEN | XSA_XEA_16BIT;
0x0008, 0x0808, //Blank Period: FP=98, BP=8
0x0007, 0x0217, //Display Control: VLE1=1, SPT=0, GON=1, REV=1, D=3

Video link : mcufriend 0x0139 vid4 - YouTube


_lcd_capable = REV_SCREEN | XSA_XEA_16BIT; //remove AUTO_READINC
0x0008, 0x0303, //Blank Period: FP=3, BP=3 as used in S6D0154
0x0007, 0x0217, //Display Control: VLE1=1, SPT=0, GON=1, REV=1, D=3

Video link : mcufriend 0x0139 vid5 - YouTube


_lcd_capable = REV_SCREEN | XSA_XEA_16BIT; //remove AUTO_READINC
0x0008, 0x0303, //Blank Period: FP=3, BP=3 as used in S6D0154
0x0007, 0x0217, //Display Control: VLE1=0, SPT=0, GON=1, REV=1, D=3

Video link : mcufriend 0x0139 vid6 - YouTube

vid3 and vid4 look the same to me. i.e. VLE1 makes no difference
vid5 and vid6 look the same to me. Software Scroll is working fine.
vid6 has a "different" white scan line #184 @ 0:04s

I have concluded that your hardware is permanently broken at scan line #184. It remains white when INVERT SCREEN is shown @ 4:03s

I have also concluded that the S6D0139 can display two Partial Screens but is not capable of doing a "BAND SCROLL"

I will post a sketch shortly to show the Partial Screens (and hopefully a VERTICAL SCROLL)
Many ILI9320 style controllers can do Partial Screens. Some can do one, others can do two. So at least I can try the sketch before I post it.

David.

I have updated the test_0139 Branch on GitHub.

Please try this sketch:

#include <Adafruit_GFX.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

// Assign human-readable names to some common 16-bit color values:
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

void setup(void);
void loop(void);

uint16_t ID;

void setup(void)
{
    ID = tft.readID();
    tft.begin(ID);
    tft.setRotation(0);
    tft.setTextColor(BLACK);
    tft.setTextSize(2);
    switch (ID) {
        case 0x0139:
            break;
        case 0x0154:
            break;
        // 9320 style controllers
        case 0x1505:
        case 0xB505:
        case 0xC505:
        case 0x1580:
        case 0x6809:
        case 0x5408:
        case 0x7783:
        case 0x8230:
        case 0x9320:
        case 0x9325:
        case 0x9328:
            break;
        default:
            tft.fillScreen(MAGENTA);
            tft.println("Not Supported");
            while (1) ;
            break;
    }
}

void base_screen(char *msg)
{
    partial(1, 0, 0, 319);
    partial(2, 0, 0, 319);
    show_partial(0);    //BASEE
    tft.fillScreen(GREEN);
    tft.fillRect(0, 48, 240, 16, RED);
    tft.fillRect(0, 240, 240, 64, BLUE);
    tft.setCursor(0, 0);
    for (int line = 1; line <= 15; line++) {
        if (line < 10) tft.print("0");
        tft.print(line);
        tft.println((line == 4) ? ": IMAGE 1" : ":");
    }
    tft.println("PARTIAL 2 fixed here");
    tft.print("ID = 0x");
    tft.println(ID, HEX);
    tft.println(msg);
}

void partial(int n, int pos, int SA, int EA)
{
    if (ID == 0x7783) pos -= SA;
    switch (n) {
        case 1:
            switch (ID) {
                case 0x0139:
                    tft.WriteCmdData(0x43, SA);           //2
                    tft.WriteCmdData(0x42, EA);        //317
                    break;
                case 0x0154:
                    tft.WriteCmdData(0x35, SA);           //2
                    tft.WriteCmdData(0x34, EA);        //317
                    break;
                default:                       //9320 style
                    tft.WriteCmdData(0x80, pos);
                    tft.WriteCmdData(0x81, SA);           //2
                    tft.WriteCmdData(0x82, EA);        //317
                    break;
            }
        case 2:
            switch (ID) {
                case 0x0139:
                    tft.WriteCmdData(0x45, SA);           //2
                    tft.WriteCmdData(0x44, EA);        //317
                    break;
                case 0x0154:
                    // nuffink.  only one Partial
                    break;
                default:                       //9320 style
                    tft.WriteCmdData(0x83, pos);
                    tft.WriteCmdData(0x84, SA);           //2
                    tft.WriteCmdData(0x85, EA);        //317
                    break;
            }
    }
}

void show_partial(int mode)
{
    switch (ID) {
        case 0x0139:
            mode = (mode & 2) ? 0x0100 : 0;   //SPT
            tft.WriteCmdData(0x07, mode | 0x0033); //
            break;
        case 0x0154:
            break;
        default:                       //9320 style
            if (mode == 0) mode = 0x0100; //BASEE
            else mode = mode << 12;   //PTDEn
            tft.WriteCmdData(0x07, mode | 0x0033); //PTDE0=1, PTDE1=1
            break;
    }
    delay(1000);   //handy pause
}

void scroll_0139(void)
{
    partial(1, 0, 0, 319);
    partial(2, 0, 0, 319);
    tft.WriteCmdData(0x07, 0x0233); // VLE1=1
    for (int VL = 1; VL < 320; VL++) {
        tft.WriteCmdData(0x41, VL);
        delay(20);
    }
    delay(1000);
    tft.WriteCmdData(0x41, 0);
    tft.WriteCmdData(0x07, 0x0233); // VLE1=0
}

void loop(void)
{
    base_screen("Move IMAGE from GRAM");
    partial(1, 0x80, 0x30, 0x3F);
    partial(2, 240, 240, 303);
    show_partial(1);    //Partial 1
    show_partial(3);    //Bofe
    for (int pos = 0x80; pos < 224; pos++) {
        partial(1, pos, 0x30, 0x3F);
        partial(2, 240, 240, 303);
        delay(50);
    }
    //    show_partial(3);    //Bofe
    delay(1000);
    base_screen("Move GRAM to Screen");
    show_partial(3);    //Bofe
    for (int SA = 0x80; SA < 224; SA++) {
        partial(1, 0x30, SA, SA + 15);
        partial(2, 240, 240, 303);
        delay(50);
    }
    delay(1000);
    base_screen("Vertical Scroll");
    if (ID == 0x0139) scroll_0139();
    else {
        for (int VL = 1; VL <= 320; VL++) {
            tft.vertScroll(0, 320, VL);
            delay(20);
        }
    }
    delay(1000);
}

Please report back.

I would expect a BLUE message with a moving GREEN line and a stationary RED line "IMAGE 1" on a WHITE background.
An ILI9320 should give a moving RED line and a stationary GREEN line (with changing contents)

The "Vertical Scroll" may or may not work.

David.

Sorry for the late reply. We had really bad icestorm here and haven't had electricity for 3 days. It's now back up.

Here's the new video from your recent sketch :

Colors seems inverted (red line image1 is blue).

Also like you said the white line is probably permanently broken.

thanks
Francois