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

Barry_S:
Thanks for all your hard work David. If it wasn't for your MCUFriend library I would have never gotten my display to do anything. I'm fairly new to programming and It’s probably obvious to most, but after searching for several weeks I'm still trying to figure out the significance of the # that precedes many of the keyword2's in the Mcufriend_kbv keywords.txt file.

My sketch begins with:

#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

and the examples show that one preceeds the keywords without an # with tft. but how does one use the keywords with an #. In particular I’ve been trying to make use of printNumF, but all I ever get is errors, such as 'class MCUFRIEND_kbv' has no member named 'printNumF'. (I’m guesing some other library is also needed.)

MCUFRIEND_kbv uses regular "Print.h" methods e.g.
tft.print(0.1234567) and tft.print(9.87654, precision)
You have to use tft.setTextCursor() to position where to start printing.
Obviously there is also println() which positions the cursor to the next line afterwards.

UTFTGLUE has a method called printNumF() with a description in the UTFT docs.

I suggest that you stick to the regular Adafruit_GFX.h and Print.h methods in new projects.

Only use UTFTGLUE if you have a legacy UTFT program.

If you want help, post a link to the original working UTFT sketch.
Or explain what you want to do for a new project.

David.

Greetings David,

I tried to run your graphicstest om my arduino Uno but it keeps on failing to build, could you help me please as i'm quite new to this.

This is the Error i get while building:

 C:\Users\User\AppData\Local\Temp\Temp1_MCUFRIEND_kbv-2.9.3.zip\MCUFRIEND_kbv-2.9.3\examples\graphictest_kbv\graphictest_kbv.ino: In function 'void loop()':

C:\Users\User\AppData\Local\Temp\Temp1_MCUFRIEND_kbv-2.9.3.zip\MCUFRIEND_kbv-2.9.3\examples\graphictest_kbv\graphictest_kbv.ino:141:5: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     };

     ^

C:\Users\User\AppData\Local\Temp\Temp1_MCUFRIEND_kbv-2.9.3.zip\MCUFRIEND_kbv-2.9.3\examples\graphictest_kbv\graphictest_kbv.ino:141:5: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

C:\Users\User\AppData\Local\Temp\Temp1_MCUFRIEND_kbv-2.9.3.zip\MCUFRIEND_kbv-2.9.3\examples\graphictest_kbv\graphictest_kbv.ino:141:5: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

C:\Users\User\AppData\Local\Temp\Temp1_MCUFRIEND_kbv-2.9.3.zip\MCUFRIEND_kbv-2.9.3\examples\graphictest_kbv\graphictest_kbv.ino:141:5: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

C:\Users\User\AppData\Local\Temp\Temp1_MCUFRIEND_kbv-2.9.3.zip\MCUFRIEND_kbv-2.9.3\examples\graphictest_kbv\graphictest_kbv.ino:142:58: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     char *colorname[] = { "BLUE", "GREEN", "RED", "GRAY" };

                                                          ^

C:\Users\User\AppData\Local\Temp\Temp1_MCUFRIEND_kbv-2.9.3.zip\MCUFRIEND_kbv-2.9.3\examples\graphictest_kbv\graphictest_kbv.ino:142:58: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

C:\Users\User\AppData\Local\Temp\Temp1_MCUFRIEND_kbv-2.9.3.zip\MCUFRIEND_kbv-2.9.3\examples\graphictest_kbv\graphictest_kbv.ino:142:58: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

C:\Users\User\AppData\Local\Temp\Temp1_MCUFRIEND_kbv-2.9.3.zip\MCUFRIEND_kbv-2.9.3\examples\graphictest_kbv\graphictest_kbv.ino:142:58: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

C:\Users\User\AppData\Local\Temp\cceWWwOn.ltrans0.ltrans.o: In function `pushColors':

C:\Users\User\Documents\Arduino\libraries\MCUFRIEND_kbv/MCUFRIEND_kbv.cpp:664: undefined reference to `penguin'

C:\Users\User\Documents\Arduino\libraries\MCUFRIEND_kbv/MCUFRIEND_kbv.cpp:664: undefined reference to `penguin'

C:\Users\User\Documents\Arduino\libraries\MCUFRIEND_kbv/MCUFRIEND_kbv.cpp:665: undefined reference to `penguin'

C:\Users\User\Documents\Arduino\libraries\MCUFRIEND_kbv/MCUFRIEND_kbv.cpp:665: undefined reference to `penguin'

collect2.exe: error: ld returned 1 exit status

And this is what the LCD_ID_readreg gives:
Attached picture of it.

Edit: Finally got it loaded onto my arduino by moving the files. Still problem remains that my screen stays full white.

Thanks in advance.

Hello David,
i am back to you with my problems.
I wish to write programs for 2 differents displays in the same time and i have a libraries problem.
First : i use 2,4" TFT LCD Shield from mcufriend (Ili9325 and ST7789V) with the the latest versions of Adafruit_GFX.h and MCUFRIEND_kbv.h without any problems. Fine.

Second : i want to use OPEN-SMART shield with larger display

Dealextreme link
not running. Screen is white and "flash" from time to time.
I found their libraries and example here :

Google Drive link
They use the same libraries as you but not the same size ???
Their MCUFRIEND_kbv.cpp is 93560 and your is 114219
Their MCUFRIEND_kbv.h is 2227 and your is 2550
Same for Adafruit_GFX
Their Adafruit_GFX.cpp is 16213 and the latest official revision is 43410
Their Adafruit_GFX.h is 3944 and the latest official revision is 7554
Their cards use "ILI9327 Special" and "HX8352B" chips (i have one of each).
Open-Smart shields used a different wiring as Mcufriend but are directly plugable on Aduino Uno board.

My request :
Where is the "link" between the library and the electrical wiring ?
Did you have any idea how to solve my problem ?

Many thanks in advance
Jacques

Apologies for my bad English, i am french (belgian) user

Bfortbattle:
Greetings David,

I tried to run your graphicstest om my arduino Uno but it keeps on failing to build, could you help me please as i'm quite new to this.

This is the Error i get while building:

 C:\Users\User\AppData\Local\Temp\Temp1_MCUFRIEND_kbv-2.9.3.zip\MCUFRIEND_kbv-2.9.3\examples\graphictest_kbv\graphictest_kbv.ino: In function 'void loop()':

...

Please Install/Upgrade your library with the Library Manager. The current version is v2.9.7

I do not recognise your controller from the LCD_ID_readreg sketch.
Perhaps the current library can find the ID.
Please copy-paste from the Serial Terminal instead of posting a screenshot.

David.

JMe87:
Hello David,
i am back to you with my problems.
I wish to write programs for 2 differents displays in the same time and i have a libraries problem.
First : i use 2,4" TFT LCD Shield from mcufriend (Ili9325 and ST7789V) with the the latest versions of Adafruit_GFX.h and MCUFRIEND_kbv.h without any problems. Fine.

Second : i want to use OPEN-SMART shield with larger display

You can use OPEN-SMART with a Uno or Mega by editing these files:
MCUFRIEND_kbv.cpp: #define SUPPORT_8352A
mcufriend_shield.h: #define USE_SPECIAL
mcufriend_special.h: #define USE_OPENSMART_SHIELD_PINOUT

The "editing" involves removing the two slash characters on those lines.

When you are building for the OPEN_SMART boards, define USE_SPECIAL
When you are building for the regular Shields, comment the USE_SPECIAL define

You can leave the other edits unchanged.

The ILI9327 should work by default. I am not sure whether the HX8352-B will work with my HX8352-A code. Please let me know.

David.

I updated my library from V2.9.5 to V2.9.6 which is the latest one for me (I can't find V2.9.7)
Still no succes, display stays white.

I ran the LCD_ID_readreg once again, results below:

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) 04 04 04 04	Manufacturer ID
reg(0x0009) 09 09 09 09 09	Status Register
reg(0x000A) 0A 0A	Get Powsr Mode
reg(0x000C) 0C 0C	Get Pixel Format
reg(0x0061) 61 61	RDID1 HX8347-G
reg(0x0062) 62 62	RDID2 HX8347-G
reg(0x0063) 63 63	RDID3 HX8347-G
reg(0x0064) 64 64	RDID1 HX8347-A
reg(0x0065) 65 65	RDID2 HX8347-A
reg(0x0066) 66 66	RDID3 HX8347-A
reg(0x0067) 67 67	RDID Himax HX8347-A
reg(0x0070) 70 70	Panel Himax HX8347-A
reg(0x00A1) A1 A1 A1 A1 A1	RD_DDB SSD1963
reg(0x00B0) B0 B0	RGB Interface Signal Control
reg(0x00B4) B4 B4	Inversion Control
reg(0x00B6) B6 B6 B6 B6 B6	Display Control
reg(0x00B7) B7 B7	Entry Mode Set
reg(0x00BF) BF BF BF BF BF BF	ILI9481, HX8357-B
reg(0x00C0) C0 C0 C0 C0 C0 C0 C0 C0 C0	Panel Control
reg(0x00C8) C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8	GAMMA
reg(0x00CC) CC CC	Panel Control
reg(0x00D0) D0 D0 D0	Power Control
reg(0x00D2) D2 D2 D2 D2 D2	NVM Read
reg(0x00D3) D3 D3 D3 D3	ILI9341, ILI9488
reg(0x00DA) DA DA	RDID1
reg(0x00DB) DB DB	RDID2
reg(0x00DC) DC DC	RDID3
reg(0x00E0) E0 E0 E0 E0 E0 E0 E0 E0 E0 C0 C0 C0 C0 C0 C0 C0	GAMMA-P
reg(0x00E1) E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 C1 C1	GAMMA-N
reg(0x00EF) EF EF EF EF EF EF	ILI9327
reg(0x00F2) F2 F2 F2 F2 F2 F2 F2 F2 F2 F0 F0 F0	Adjust Control 2
reg(0x00F6) F6 F6 F6 F6	Interface Control

It is a 2.8 inch TFT touch display from MCUfriend.com

Thanks in advance.

Hi David, how are you?

My chinese 3.5 tft blue shield (pict attached) just arrived. I runned "LCD_ID_readreg" and received this:

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 00 00 00 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x000A) 08 08 Get Power Mode
reg(0x000C) 66 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 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 02 04 94 81 FF ILI9481, HX8357-B
reg(0x00C0) 00 10 3B 00 02 11 00 00 00 Panel Control
reg(0x00C8) 00 00 44 06 11 44 55 0A 08 17 33 77 11 GAMMA
reg(0x00CC) 00 00 Panel Control
reg(0x00D0) 00 00 43 Power Control
reg(0x00D2) 00 01 22 00 00 NVM Read
reg(0x00D3) 00 01 22 00 ILI9341, ILI9488
reg(0x00D4) 00 01 22 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

Could you please help me to correctly identify the Controller (ID)? Is it compatible with your library? Hope it is...

Many thanks my friend!!!

foto TFT 35-BACK.jpg

It is an Ilitek ILI9481.

reg(0x00BF) 00 02 04 94 81 FF ILI9481, HX8357-B

It should work with the library. Note that that particular screen is prone to overheat.

David.

Thank you very much for the help and for the warning!!!

"tft.begin(0x8357)" and it seemed to work. Is it OK?

No. It is an Ilitek ILI9481. The ID is 0x9481. That is why there is a tft.readID() method.

The HX8357-B is a different make and model. (but very similar)

David.

david_prentice:
Please Install/Upgrade your library with the Library Manager. The current version is v2.9.7

I do not recognise your controller from the LCD_ID_readreg sketch.
Perhaps the current library can find the ID.
Please copy-paste from the Serial Terminal instead of posting a screenshot.

David.

After some more research i think my display has the hx8347-g chip, i couldn't find much about it, do you have any idea?

Thanks in advance.

My IDE is Arduino 1.8.3 Look on the title of every sketch window.

I suggest that you install v2.9.7 from the Library Manager. It gives specific instructions for HX8347 variants.

If your IDE or Library is out of date, update it. Definitely replace any v1.7.x IDE.
Don't worry about the very latest IDE. Anything later than 1.6.12 should be ok.

David.

Its Ok, I understand. But when I run your "showBMP_not_Uno" (that contains "tft.readID()") the display shows all images like color "negative" (X-ray). Do you know what am I doing wrong?

Thanks!!!

Please run the graphictest_kbv sketch.
What ID is reported on the Serial Terminal?

The HX8352-A has ID=0x5252
The HX8352-B has ID=0x6565 (and is not supported)

You should try tft.begin(0x5252);

Report any mirrored text or wrong colours. e.g. BLUE BAND mirrored text.

David.

david_prentice:
My IDE is Arduino 1.8.3 Look on the title of every sketch window.

I suggest that you install v2.9.7 from the Library Manager. It gives specific instructions for HX8347 variants.

If your IDE or Library is out of date, update it. Definitely replace any v1.7.x IDE.
Don't worry about the very latest IDE. Anything later than 1.6.12 should be ok.

David.

My IDE is Arduino 1.8.5 (latest)
The mcufriend library is v2.9.6, there is no 2.9.7 in library manager available for me.
It gives me device ID: 0xD3D3

Im really confused about what driver chip my screen has now, as no information was given about it. i really appreciate the help.

Thanks in advance.

Well, I released v2.9.7 a few weeks ago. My Library Manager offers v2.9.2-Beta through to v2.9.7

Looking at your LCD_ID_readreg report. It is complete garbage. Just like you would get from a write-only shield. Please note:

Read Registers on MCUFRIEND UNO shield

Please post a link to the actual shield that you have on your desk. e.g. Ebay link or your own photo of the pcb.

David.

david_prentice:
Well, I released v2.9.7 a few weeks ago. My Library Manager offers v2.9.2-Beta through to v2.9.7

Looking at your LCD_ID_readreg report. It is complete garbage. Just like you would get from a write-only shield. Please note:
Please post a link to the actual shield that you have on your desk. e.g. Ebay link or your own photo of the pcb.

David.

The seller i got it from: https://www.wish.com/c/57bfbef60423c3503682071b

There is no pictures on the back, but all that's on the back is an SD card reader and two sum74hc245t chips, no resistors no nothing. just the text www.mcufriend.com and 2.8" TFT LCD Shield.

I really appreciate the help thank you very much.

Your link shows a 2.8" Blue Mcufriend Uno shield with description "2.8 TFT Touch Screen with SD Card Socket for Arduino Board Module (Color: Black) "

So it should work in any Uno,Mega, Due, Zero, ...

  1. what colour is the pcb?
  2. does it look like the photos in your link?
  3. have you plugged it into your Uno? (all the male pins should mate with corresponding female sockets)

David.

Hi David, I runned the graphictest_kbv sketch and:

  • Serial Terminal reported ID = 0x9481.
  • Nothing mirrored but colours changed e.g. RED->CYAN, BLACK->WHITE, GREEN->MAGENTA, YELLOW->BLUE,...

Then I tried tft.begin(0x5252) and the result was only "black screen".

Then I tried tft.begin(0x8357) and colours seemed to be OK but some texts were mirrored (picts attach):

  • TEXTS MIRRORED: First Text, BLUE and RED color grades.
  • TEXTS OK: GREEN and GRAY color grades

Thanks David!!!

IMG_20171116_000812416.gif

IMG_20171116_000842821.gif

IMG_20171116_000851806.gif

IMG_20171116_000921726.gif

IMG_20171116_000940075.gif

Display looks exactly as the one pictured in the shop, it just seems that i have less things on the back then other people do. A mystery to me :confused:

i attached pictures of it below.

Thanks in advance.