Go Down

Topic: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields (Read 219853 times) previous topic - next topic

david_prentice

#MCUFRIEND_kbv
Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend  Shields

1. The Arduino Library Manager should find and install MCUFRIEND_kbv library

2. Install the Adafruit_GFX library if not already in your User libraries.

3. Insert your Mcufriend style display shield into UNO.   Only 28-pin shields are supported.

4. Build any of the Examples from the File->Examples->Mcufriend_kbv menu.  e.g.

graphictest_kbv.ino: shows all the methods.

LCD_ID_readreg.ino:  diagnostic check to identify unsupported controllers.

MCUFRIEND_kbv inherits all the methods from
the Adafruit_GFX class: https://learn.adafruit.com/adafruit-gfx-graphics-library/overview
and Print class: https://www.arduino.cc/en/Serial/Print

The only "new" methods are hardware related:
vertScroll(), readGRAM(), readPixel(), setAddrWindow(), pushColors(), readID(), begin()

readReg(), pushCommand() access the controller registers

The File layout changed with v2.9.3.   If replacing a pre-v2.9.3 library:
Please leave IDE.  Delete the existing MCUFRIEND_kbv folder.  Start the IDE.  Install from Library Manager.

HOW TO INSTALL AND USE: is now in "mcufriend_how_to.txt"

CHANGE HISTORY:         is now in "mcufriend_history.txt"

david_prentice

#1
Dec 17, 2015, 11:05 am Last Edit: Dec 17, 2015, 11:11 am by david_prentice
I have moved the library from there to this new Thread.
 
Please post questions here.

David.

Melandr

Good day. The text direction is not correct when using the library, what should be changed in the library to properly display text? The text prints right to left and have the left-to-right.

david_prentice

First off.    Is it an ILI9331 ?   What does graphictest_kbv say ?   What did the Serial Terminal say ?

I do not currently support a 9331 but do have 9320, 9325, 9335.   What did you use with tft.begin() ?

Yes,   it should be easy to add support for the 9331.

1. could you confirm whether the PORTRAIT, LANDSCAPE, PORTRAIT_REV, LANDSCAPE_REV are correct.
2. does Vertical scroll work?
3. does Software scroll work?

David.

Melandr

I slightly changed Your library by adding the initialization code of the ILI9331 display that displays the serial port

TFT LCD test
Using Adafruit 2.8" TFT Breakout Board Pinout
TFT size is 240x320
Found ILI9331 LCD driver
Benchmark Time (microseconds)
Screen fill 1717572
Text 366476
Lines 2297612
Horiz/Vert Lines 177060
Rectangles (outline) 142544
Rectangles (filled) 3574852
Circles (filled) 2359488
Circles (outline) 1002960
Triangles (outline) 728860
Triangles (filled) 2385364
Rounded rects are (outline) 409180
Rounded rects are (filled) 4459388
Done!

Don't know how to attach Your modified source code.

david_prentice

You appear to be running "graphicstest" and not "graphictest_kbv".

Probably on a MEGA2560 because a UNO would be 2.5x faster.

Please could you answer (1), (2), (3).   Then I can add full support for the ILI9331 which would benefit other users.

David.

Melandr

Code: [Select]
case 0x9331:
_lcd_capable = AUTO_READINC | REV_SCREEN;
static const uint16_t ILI9331_regValues[] PROGMEM = {
0x0001,0x0100,    
0x0002,0x0700,    
0x0003,0x8020,    
0x0008,0x0302,    
0x0009,0x0000,   
0x000A,0x0008,    
//*******POWER CONTROL REGISTER INITIAL*******//    
0x0010,0x0790,    
0x0011,0x0005,    
0x0012,0x0000,   
0x0013,0x0000,    
//delayms(50, 
//********POWER SUPPPLY STARTUP 1 SETTING*******//    
0x0010,0x12B0,    
// delayms(50,  
0x0011,0x0007,    
//delayms(50,  
//********POWER SUPPLY STARTUP 2 SETTING******//    
0x0012,0x008C,    
0x0013,0x1700,    
0x0029,0x0022,    
// delayms(50,   
//******GAMMA CLUSTER SETTING******//    
0x0030,0x0000,    
0x0031,0x0505,    
0x0032,0x0205,    
0x0035,0x0206,    
0x0036,0x0408,    
0x0037,0x0000,    
0x0038,0x0504,
0x0039,0x0206,    
0x003C,0x0206,    
0x003D,0x0408,    
// -----------DISPLAY WINDOWS 240*320-------------//    
0x0050,0x0000,
0x0051,0x00EF,   
0x0052,0x0000,   
0x0053,0x013F,   
//-----FRAME RATE SETTING-------//    
0x0060,0xA700,   
0x0061,0x0001,   
0x0090,0x0033, //RTNI setting
//-------DISPLAY ON------//    
0x0007,0x0133,    0x0001,0x0100,    
 0x0002,0x0700,    
0x0003,0x1030,    
0x0008,0x0302,    
0x0009,0x0000,   
0x000A,0x0008,    
//*******POWER CONTROL REGISTER INITIAL*******//    
0x0010,0x0790,    
0x0011,0x0005,    
0x0012,0x0000,   
0x0013,0x0000,    
//delayms(50, 
//********POWER SUPPPLY STARTUP 1 SETTING*******//    
0x0010,0x12B0,    
// delayms(50,  
0x0011,0x0007,    
// delayms(50,  
//********POWER SUPPLY STARTUP 2 SETTING******//    
0x0012,0x008C,    
0x0013,0x1700,    
0x0029,0x0022,    
// delayms(50,   
//******GAMMA CLUSTER SETTING******//    
0x0030,0x0000,    
0x0031,0x0505,    
0x0032,0x0205,    
0x0035,0x0206,    
0x0036,0x0408,    
0x0037,0x0000,    
0x0038,0x0504,
0x0039,0x0206,    
0x003C,0x0206,    
0x003D,0x0408,    
// -----------DISPLAY WINDOWS 240*320-------------//    
0x0050,0x0000,
0x0051,0x00EF,   
0x0052,0x0000,   
0x0053,0x013F, 
//-----FRAME RATE SETTING-------//    
0x0060,0xA700,   
0x0061,0x0001,   
0x0090,0x0033, //RTNI setting
//-------DISPLAY ON------//    
0x0007,0x0133,   
};
init_table16(ILI9331_regValues, sizeof(ILI9331_regValues));
        break;


Added a bit of code in the file MCUFRIEND_kbv, test "graphicstest". There is a video of the test though there is a bit much, don't know where to reset to show. Sorry for bad English, I write through Google translator.

david_prentice

Thanks for your post.    I see that the Power Control registers values are very different to the ILI9325.
The Entry Mode (0x03) is very unusual.

I would appreciate it if you could run the "graphictest_kbv" sketch and answer the 3 questions from message #3.

I manipulate the SS, GS, ORG bits to achieve Rotation in a consistent way.    With the I/D bits set at 11 (i.e. increment horizontal, increment vertical).

It looks as if your JPEG is displaying Portrait mode with GS in the wrong direction.
Note that the graphictest_kbv sketch states each direction and mode.

This should make it easy to say "PORTRAIT is reverse-vertical" to describe your photo.
From your earlier post,   you said "text was reverse-horizontal"

What happens if you simply force tft.begin(0x9320)  in the graphictest_kbv sketch?

I am sure that we can get your Shield displaying 100%.
Do not worry about English translation.    But it would help if you run graphictest_kbv.

David.

Melandr

Thanks for the answer. After recording "tft.begin (0x9320);" to sketch graphictest_kbv, text became displayed correctly. As for the answers to questions (1), (2), (3) after the change of the sketch:
1. Modes PORTRAIT, LANDSCAPE, PORTRAIT_REV, LANDSCAPE_REV were printed correctly.
2. Vertical scroll mode works properly.
3. Software scroll mode works only on EADB red letters in a small window

Melandr

I wanted to also ask, does this mean that my display ILI9331 is compatible with the display ILI9320?

david_prentice

Thanks for your report.

The software scroll only works on that small rectangle.   At the end,   the EADB should still be in Red.   The broken  letters should still be in Yellow.     There should be no flashes of Blue during the scroll.

Please remove the plastic film from your screen.    It distorts the colours.
All the colours and printing should look very bright and clear.   There is a bit of blurring during the Vertical scroll.

Compare the 9320 screen with your 9331 code.
Which looks better?

David.

Melandr

Thanks for the reply. I now understand what is the difference in initializing the display 9320. Also wanted to ask why You said that the display on the UNO Board will run faster than on-Board MEGA 2560.
Also, this question is a bit off topic, but associated with the display. To display the images with the SD card uses the SPI library with hardware support. But since my display Pinout charge made under UNO, it is not the same SPI pins. For UNO - 10, 11, 12, 13, and MEGA - 50, 51, 52, 53. a question arises, is it possible to use software SPI, SPI by assigning findings on 10,11,12,13?

david_prentice

These displays are designed for a Uno.    They work very well on a Uno.

If you use a Mega,   the TFT will be 2.5x slower than a Uno.   You must use Software SPI for the microSD.  e.g. with the SdFat library.

Personally,    I find the SdFat library is not as reliable to use as the regular SD library that comes with your Arduino.

Since Uno clones are so cheap,    I suggest that you use your display with a clone instead of a Mega2560.

From my point of view,    I look forward to hearing whether 0x9320 or 0x9331 gives a better picture.

David.

rahulmr

I got the 3.95LCD from aliexpres which uses IL9488.

I am using the library given here . I am using MEGA as I need other GPIO to be used for other purposes. I can't use the UNO because of this limitation.I don't need touch screen .

I have other modules like the DS3231 ,and ESP8266 connected to the MEGA and this 3.95 LCD connected as well. ESP8266 is powered separately using a 12-5v converted supply. Mega is powered using another source.The normal grapichs test is working in the LCD. I am able to make it work with the nano,uno and mega. Even for mega I am able to write customized messages.

What I intend to do is to update the time in the LCD which is received from the DS3231. It updates the LCD but I see a flickering issue here.

Every update(LCD display function is from the loop which sets the text when there is a second/time/hour difference in the time.) seems like draining more current as the one of the LED connected to MEGA dims, the rx/tx leds also dims.

I am able to get the LCD refreshed but it shows a flickering.I powered the LCD 3.3 and 5v using another separate source but still the small flickering continues.
Moreover all these time I was connected to the MEGA through the USB from the laptop.Once I unplug the USB, LCD starts and shows some update and again become white. This continues and an not able to see anything on LCD there after.

I am not sure why only when the MEGA is connected to USB this LCD works and that too flickering but once the USB is removed the LCD is not working at all.

Can some one please do help me in this ?
 

david_prentice

So your shield works 100% on a Uno and Mega running the library examples.

If you have a problem with your own code,  please post your sketch and a schematic of your wiring.
A simple pencil drawing of your wiring is fine if you attach a good photo.

A written description of your wiring is fine too.   But check it VERY carefully.   The description in your message#13 is not accurate enough.   Put yourself in our shoes.   We do not know whether you have connected GND wires,  what kind of power supply,  what pins are connected  ...

David.

Go Up