3.95 mcu_friend 320x480 TFT mirrored screen in portrait orientation

Dear all,

Figure 1: Just before Christmas my new mcu_friend 3.95 inch 320x480 TFT UNO-shield/screen arrived, bought via Aliexpress. The Aliexpress website claims that an ILI 9488 is on board. Figure 1 shows the back of the shield.

The new 3.95 TFT shield replaces a similar shield that I bought one year ago that had a cracked screen upon arrival. The cracked TFT works properly although it has a large defect in the screen; graphicstest-kbv reports ID=0x84880. The cracked 3.95 TFT has no problems at all with tests in landscape and portrait mode operation. I want to use the TFT specifically in portrait orientation to monitor temperatures in my central heating system. I even constructed a complete display board equipped with a 3.5 inch 320x480 shield (see http://www.zonnepanelen.wouterlood.com/index.php/hobby-elektronica)

After placing the new shield/screen on an Uno and running the graphicstest_kbv script (from mcu_friend.kbv 2.9), I noted that the test reports an ID = 0x9486

Running next the graphicstest_kbv script with the ID hard coded to 0x9486 produces color inverted screens, with text normally oriented in landscape mode (tft.setRotation(0) but with mirrored text in portrait mode.

Figures 2 and 3: Running the same test with a hard coded ID=0x9488 produces the normal test results of graded colors, graphics, et cetera in landscape mode, but also mirrored text in portrait mode.

Other IDs, e.g. 0x9481, 0x6814, 0x9341, 0x9327 produced with this test either nothing or something with inverted colors and in portrait mode an additional mirrored screen.

Figures 4 and 5: Apparently the controller is not a 0x9486 nor a 0x9488 but something else (newer? counterfeit?) that accepts instructions as 0x9488 and then works fine ---- only in landscape but not in my favorite portrait orientation: everything is then mirrored.

I wrote a test sketch in which I force an ID=0x9488 in line 60 and then run this test in landscape orientation (see line 67). The graphics and colors are OK and I can use the TFT for my thermal sensor readouts, however only in portrait orientation ( :o ). The script attisched is "text_mcu_friend_3_95_tft.ino"

On the forum I noted a long and intense discussion on the topic "ili9488 with tuoch screen". Mentioning in the post of July 23 of was made of

" In the archives of the Library folder are supported ili9341 240x320, ili9488 480x320, for quite uncomment the desired resolution and compile the sketch. http://178.130.34.198/adafruit/adafruit.rar

However, this url is not available any more. Does one of the forum readers have this rar available?

The post of July 26, 2015 has an attachment 'tftpaint2_9327.ino. When that script is run, and iD=0x9341 is reported plus on screen a primary color bar appears correct (full width in landscape) white on tft.setRotation (0) the text is mirrored in this portratit mode and no color bar is seen.

As I am out of possibilities, hence, please help me with suggestions that might lead to a solution.

report LCD_ID_reader .txt (1.61 KB)

test_mcu_friend_3_95_tft.ino (13.7 KB)

3_95_inch_tft_mcu_friend_files.zip (413 KB)

I suggest that you delete your current library and install the v2.9.1-Beta from GitHub.

Since you have a Uno shield, you can identify the controller with tft.readID()
Or if you are suspicious, run the LCD_ID_readreg.ino sketch.

Ah-ha, I see that your TXT file identifies a 0x6814 controller.
The first people with 0x6814 required reg(0x3A) to hold 0x66 (which is very strange)
If your new screen does not work with ID=0x6814, you should add the statements that I posted in the main thread. This changes reg(0x3A) to 0x55 (that I would expect)

David.

Thanks David!

So it is this line in the txt file among the abacadabra that identifies the controller:

reg(0x00BF) FF FF 68 14 00 FF ILI9481, HX8357-B

That makes life easier. Big smile. Let's get to work on that interesting TFT. I like the size of the gadget, ideal for displays.
regards, floris Wouterlood aka photoncatcher

Yes, that is the correct line.
Note that there is another line:

reg(0x00D3) 00 00 94 86	ILI9341, ILI9488

When the first 0x6814 displays appeared on Ebay/Ali they were identified as 0x9486
In fact, the Raydium datasheet does not even document reg(0xBF)

Different displays come onto the market. Often with unknown controllers. Certainly with mendacious descriptions from the Ebay/Ali vendors.

And often with manufacturing defects.
For example, the early 0x6814 displays needed reg(0x3A)=0x66 when they should use 0x55.

Please tell me if your 0x6814 wants 0x66 or 0x55.

David.

Dear David,

I would like first to update the library. I assume that the MCUFRIEND_kbv at GitHub - prenticedavid/MCUFRIEND_kbv: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields (May 5, 2016) is version beta 2.91? (I can't find a version number in readme.md and in history.txt)

Floris

The version number is in MCUFRIEND_kbv.h:

#define MCUFRIEND_KBV_H_   291

The ZIP file in message#0 of this thread is v2.9.0
It should be fine for most 2.4", 2.8" shields

A lot of weird and wonderful 3.5", 3.6", 3.95" display shields have appeared since May 2016.
Note that I do not own most of these new ones.
I would like to purchase an 0x1511 display. My attempts have always resulted in different controllers.
I would also like to distinguish between 0x6814 displays. i.e. ask 0x66 owners and 0x55 owners to run some tests.

One day, I will do some serious tidying up of the Beta. And do a proper new Release. Ideally with a foolproof 0x1511 and 0x6814.

David.

Dear David,

I found line 2 in MCUFRIEND_kbv,h:

#define MCUFRIEND_KBV_H_ 291

that's r=the rev number you are referring to. Great.

Actually the Arduino instructions say a multitude of things about installing a library, but there is nothing about removing libraries from the library folder. Simply del*.* I guess, or in case of upgrading, simply overwriting old files with new ones.

regards, Floris

btw I published some of my early Arduino projects on https://thesolaruniverse.wordpress.com/

hers is also the narrative of the construction of my (3.5 inch TFT) multitemperature display showing floor heating loop circulating water temps.

Exit the IDE. Browse for the MCUFRIEND_kbv folder in libraries. Delete the folder.

Download ZIP from GitHub. Start IDE. Add ZIP library from the IDE.

Yes, folders will probably merge ok with the Beta.
But when I tidy up for the next Release, the files will be arranged dfferently. You will have to delete the old folder.

David.

Dear David,

With the v. 2.91 beta of mcufriend_kbv installed and no forced ID in the script I get the letters and numbers correct in portrait orientation, however in black and white. A good beginning. The next step is per your advice to try to tweak register reg(0x3A).

Here is a picture of the screen with my little test sketch and v. 2.91 beta of the library:

regards, Floris

Dear David,

You advised: "If your new screen does not work with ID=0x6814, you should add the statements that I posted in the main thread. This changes reg(0x3A) to 0x55 (that I would expect)""

I have been searching in vain for the statements posted in the main thread. I am not sure what the main thread is (! one of these funny things when one is a newbie). Can you provide a sketch snippet to help me further on the path to success?

regards, Floris

The sequence in setup() would be somethign like this:

     uint16_t ID = tft.readID();
     tft.begin(ID);           // detect and start with correct ID
     uint8_t pixfmt = 0x55;             // regular 565 format
     if (ID == 0x6814) tft.pushCommand(0x3A, &pixfmt, 1); // and write to the register

I have every sympathy. Although this subject has come up several times, there are a lot of messages in the "main library thread" e.g. MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields

David.

Dear David,

Thanks for the snippet. I wrote a new, ultraminimalist sketch to test what it is all about with this 3.95 mcu_friend TFT screen. (sketch: minimal_test_TFT.ino). It switches a white "Hello World" message on a blue screen in landscape to the same text in black on a green background.

Next I inserted your snippet into the setup part (minimal_test_TFT_with_register_03A_wite.ino) and tested with both pixfmt = 0x55 and pixfmt = 0x66. There are (unfortunately) no noticeable changes in the performance of the TFT. Even wicth exotic values for pixfmt as 0A or 00. Nope results.

A stubborn TFT ! Maybe I am overlooking something or my programming is missing something essential. Maybe you have more tricks in the big hat ?

attached: (1) minimal_test_TFT.ino, (2) minimal_test_TFT_with_register_03A_wite.ino, figure_07_6814_landscape.png and figure_08_6814_portrait.ino (no differences between the twop ino's
regards, Floris

minimal_test_TFT.ino (1.44 KB)

minimal_test_TFT_with_register_03A_wite.ino (1.83 KB)

You have put the pixfmt statements in the wrong place. Your setup() should be:

void setup(void)
{
 
     uint16_t id = tft.readID();  // you must detect the correct controller
     
     Serial.begin(9600);
 
     tft.reset();
     Serial.print("Controller ID = ");   
     Serial.println(id, HEX);
     Serial.println(""); 

     tft.begin(id);      // use the CORRECT id
     tft.setRotation(0);

     //***********************  David Prentice's suggested insert **************
     uint8_t pixfmt = 0x55;                                  // regular 565 format
     if (id == 0x6814) {
         tft.pushCommand(0x3A, &pixfmt, 1);   // write to the register
         Serial.println("insert done"); 
     }
     //*********************** end of insert ***********************************
}

Incidentally, the tft.reset() is unnecessary. Likewise setRotation(0).
The begin() method sets up the controller registers including 0x3A.
So you must do any changes after the begin().

David.

Dear David,

Thanks for your assistance. I copied the above snippet right in place in the minimal_test_TFT script, but alas, big disappointment ------- still the mirrorred text in portrait orientation.

I also inserted the snippet in the expanded test sketch (yesterday's) - no improvement: in Portrait orientation, letters are correctly represented, although in greyscale only. The upper 2/3rd of screen is correctly built up while lower 1/3 remains in a previous mode.

In Landscape, a correct buildup is produced, in greyscale. No colors

I also wrote 66 to register 0x03A. No changes.

A real stubborn TFT. Why are manufacturers doing these things?

Oh dear!

I see I come to this thread a bit late, but my experience is similar to photoncatcher.

I bought a 3.5" TFT LCD on eBay and it came in a flimsy plastic bag with no protection, and surprise surprise the screen was badly cracked! The shield was made by mcufriend and the controller chip was HX8357D. Much worked, but colours were inverted and the cracks made the screen unusable.

I requested a well packaged replacement, which arrived on an mcufriend shield, but it has controller 6814 - not from the advertised selection of ili9481 ili9468, ili9488 hx8357, or r61581. The colours are correct, but in some attempts at orientation the text is mirror image, and I can't get the touch screen to work.

Hopefully by now someone has sorted this chip on this forum but I have been unable to find it. Will someone kindly point me in the right direction?

Many thanks

Please run the Library Manager.

The current library Release is v2.9.8
It should work fine with Raydium RM68140 controller.
Or with ILI9486, HX8357C, HX8357D, ...

Over the years there have been shields with "wrongly configured" screens.
For example a RM68140 with the wrong PIXFMT.

As far as I know current shields should work out of the box on Uno and Mega.
If you have a Due or fast Cortex-M4 please say. (The RM68140 timing is a little different)

David.

Wow! Thanks David, what a speedy reply!

Thanks especially for identifying the controller - where Google had failed me.

Afraid I am just signing off*, but can I ask you if Library Manager only runs through the libraries in the 'Arduino' ' folder? Over the years the libraries I have downloaded I have put in a separate folder near my sketches. But the driver code I have only just downloaded, so assumed they would be up to date.

Thanks again for your help.

  • it is 10pm here in UK and I have been on here far too long!

I strongly recommend that you sort out your libraries.

The IDE installs a handful under the main "system" directory e.g.
C:\Program Files (x86)\Arduino-1.8.1\libraries\SD

All User libraries should go into your User directory e.g.
C:\Users\David Prentice\Documents\Arduino\libraries\Adafruit_GFX_Library

Examine your PC to see if you have any "user" libraries under "Program Files"
Check that each library is available via the Library Manager.

Leave the IDE. Delete the "wrong" library directory(s).
Start the IDE. Install each library properly via the Library Manager.

This PC is still using IDE v1.8.1.
It is probably wise to upgrade to the current IDE v1.8.7 one day.

If you select Verbose Compile in Preferences, each build will report which library versions were used (and where they live on your PC)
You get a whole load of dross but the last few lines that report memory and library use are very helpful.

David.

Thanks David.

My libraries are in the same structure as yours. I have 40 in my user directory, and 19 in the Arduino system directory - none of which are mine. But I am not clear which library I should be using with this shield.

Currently I am using #include <MCUFRIEND_kbv.h> and #include <Adafruit_GFX.h> but setRotation brings up a landscape view for odd numbers and a portrait view (with mirror text) for zero and even numbers. The orientation is just +/- 90 degrees - not the four quadrants I get on the original screen

You earlier mentioned the Library release number, but where is that? When I go to Sketch | Include library | Manage libraries it brings up Library Manager but with no release number.

A random search with Library Manager for some of my libraries shows that it has them, but is there a more rigorous way to check they are all there?

BTW my IDE is 1.8.5

Thanks for the reminder about verbose. It has just solved a problem I was having with uploading to one of my clone UNOs - presumably by slowing down the action. I will study the output.

IDE Library Manager is reached by: Sketch->Include library->Manage libraries

Enter a wildcard e.g. GFX or kbv to home in on a library.

Then select the library that interests you. It will show the installed version. And any updates/versions
If you click on [More] it takes you to the GitHub page.

In practice, you simply check for Updates. Install with a click. No need to study anything.

The verbose compile is the most useful. Here are the "interesting" lines from a recent build:

Using library Adafruit_GFX_Library at version 1.3.1 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Adafruit_GFX_Library 
Using library Adafruit_ST7735_and_ST7789_Library at version 1.2.4 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Adafruit_ST7735_and_ST7789_Library 
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino-1.8.1\hardware\arduino\avr\libraries\SPI 
Sketch uses 16508 bytes (51%) of program storage space. Maximum is 32256 bytes.
Global variables use 772 bytes (37%) of dynamic memory, leaving 1276 bytes for local variables. Maximum is 2048 bytes.

You don't need to know what it means. But if users always quoted these lines when they have a problem it gives me LOTS of information.

David.