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

First off. Does the project work 100% on your real hardware?

I am intrigued by your Online problem. Please can you do an "Online Build" and Copy-Paste the Memory + Library Use lines e.g. like I did.

If it fails, Copy-Paste the whole Error report to a .TXT file. Then attach this file.

It would be interesting to know the Pros and Cons of an Online Build.

David.

I can do that but schedule won’t allow me to until tomorrow. I did have the same failure both online and with 1.8.5 and 1.8.9 which makes me think I didn’t have the right or all libraries needed. And it looks like all routines and sub routines are working as they should.

Hi to all I just got an MCUFRIEND 2.4" Shield. I am trying to make it work with the graphics test project. I get a white screen. I have read many posts from here. I tried to change the ID in tft.begin and made the ID 9320. In this case i get some colors in the display but not right, Also i can not see any text from the example. I think that it is a driver problm. So please if anyone can help me. I post the serial monitor output from the LCD ID readreg example.

Read Registers on MCUFRIEND UNO shield
controllers either read 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) 97 97   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 97 97 97 97 Manufacturer ID
reg(0x0009) 97 97 97 97 97  Status Register
reg(0x0061) 97 97   RDID1 HX8347-G
reg(0x0062) 97 97   RDID2 HX8347-G
reg(0x0063) 97 97   RDID3 HX8347-G
reg(0x0064) 97 97   RDID1 HX8347-A
reg(0x0065) 97 97   RDID2 HX8347-A
reg(0x0066) 97 97   RDID3 HX8347-A
reg(0x0067) 97 97   RDID Himax HX8347-A
reg(0x0070) 97 97   Panel Himax HX8347-A
reg(0x00A1) 97 97 97 97 97  RD_DDB SSD1963
reg(0x00B0) 97 97   RGB Interface Signal Control
reg(0x00B4) 97 97   Inversion Control
reg(0x00B6) 97 97 97 97 97  Display Control
reg(0x00B7) 97 97   Entry Mode Set
reg(0x00BF) 97 97 97 97 97 97   ILI9481, HX8357-B
reg(0x00C0) 97 97 97 97 97 97   Panel Control
reg(0x00CC) 97 97   Panel Control
reg(0x00D0) 97 97 97    Power Control
reg(0x00D2) 97 97 97 97 97  NVM Read
reg(0x00D3) 97 97 97 97 ILI9341, ILI9488
reg(0x00DA) 97 97   RDID1
reg(0x00DB) 97 97   RDID2
reg(0x00DC) 97 97   RDID3
reg(0x00EF) 97 97 97 97 97 97   ILI9327
reg(0x00F2) 97 97 97 97 97 97 97 97 97 97 97 97 Adjust Control 2
reg(0x00F6) 97 97 97 97 Interface Control

You have a Solomon SSD1297 controller. It is not supported by the regular v2.9.8 Release. Look in extras/mcufriend_how_to.txt

You need to install the Beta from GitHub. 1. Leave IDE. 2. Delete the MCUFRIEND_kbv directory. 3. Start IDE. 4. Download ZIP from GitHub. 5. Install from ZIP. 6. read extras/mcufriend_how_to.txt 7. Edit MCUFRIEND_kbv.cpp to #define SUPPORT_1289

David.

Thank you David for the answer. I see that in latest library version these is s define for 1289. Where can I get the beta version? In GitHub I found only the latest version. Thank you.

Go to https://github.com/prenticedavid/MCUFRIEND_kbv/

There is a Green box on the top right of screen [Clone or Download] On the top left there is a box saying [Branch: master]

Click on Green box. Select [Download ZIP] Save to your PC.

IDE->Sketch->Include Library->Add .ZIP library Browse to your downloaded .ZIP

David.

p.s. you should always use a "Release" unless advised.

The "master" Branch is always the default branch referred as Beta. you never use other branches unless advised.

The IDE Library Manager always uses a Release. The IDE Library Manager can install different Release versions

The IDE Library Manager does not like you using Beta branches. It is wise to delete any existing library before any manual installation.

Thank you very much David. Now the 2 displays i have works perfectly. The garphics test is OK in all screens as i can see. Your advices were very helpful to me.

Now i am trying the touch screen example for calibration. That seems that doesn't work. I can not select other color than red and when i try to touch and draw a line the display draw line in other position than the position where i put the stylus. Any help for this?

OK i solved it out after some search. I had to see what are the touch pins. So after running the example to see touch pins (diagnose_Touchpins) for my display touchpins are:

XM,XP (A1,D7) YP,YM (A2,D6)

This is for anyone who may have the same problem.

Thank again for all your help.

Now I have another problem. I am testing an other display that made it work with the beta library. The problem I have is that I can not calibrate touch screen. In the the diagnose_touch example I get the same values for XM,XP,YM,YP But when I change them in the touchscreen example the touch does not work as it should. I put the stylus at the bottom and I get the line I draw at the top of the display. Any help? Thank you.

jxid: Now i am trying the touch screen example for calibration. That seems that doesn't work. I can not select other color than red and when i try to touch and draw a line the display draw line in other position than the position where i put the stylus. Any help for this?

Please can you explain. It is useful to number each step as you go e.g.

  1. Plug shield into Arduino Uno.
  2. Run TouchScreen_Calibr_native.ino
  3. Open the Serial Terminal (9600)
  4. It should diagnose the Touch Pins to Serial.
  5. The TFT should prompt for "start"
  6. The TFT should show several cross-hairs. One will be highlighted.
  7. [Press] the stylus on the highlighted cross-hair until [Release]
  8. the highlight moves to the next cross-hair
  9. rinse and repeat for all cross-hairs.
  10. the TFT shows a brief report.
  11. the Serial Terminal shows a full report.
  12. you only need to copy-paste two lines from the Serial Terminal.

e.g.

const int XP=7,XM=A1,YP=A2,YM=6; //240x320 ID=0x9797
const int TS_LEFT=893,TS_RT=182,TS_TOP=858,TS_BOT=210;
  1. it is wise to save the calibrations in a file if you have several different screens.
  2. if you have a problem, copy-paste the whole Serial Terminal to a message on the Forum.

I would dearly love to get feedback. Which step is difficult? Do the cross-hairs show? Do you copy-paste from Serial?

Note that you can't diagnose Touch pins with an ARM or ESP But you can still calibrate if you edit the sketch for your manually diagnosed Touch pins (i.e. with a DMM)

David.

david_prentice: Please can you explain. It is useful to number each step as you go e.g.

  1. Plug shield into Arduino Uno.
  2. Run TouchScreen_Calibr_native.ino
  3. Open the Serial Terminal (9600)
  4. It should diagnose the Touch Pins to Serial.
  5. The TFT should prompt for "start"
  6. The TFT should show several cross-hairs. One will be highlighted.
  7. [Press] the stylus on the highlighted cross-hair until [Release]
  8. the highlight moves to the next cross-hair
  9. rinse and repeat for all cross-hairs.
  10. the TFT shows a brief report.
  11. the Serial Terminal shows a full report.
  12. you only need to copy-paste two lines from the Serial Terminal.

e.g.

const int XP=7,XM=A1,YP=A2,YM=6; //240x320 ID=0x9797
const int TS_LEFT=893,TS_RT=182,TS_TOP=858,TS_BOT=210;
  1. it is wise to save the calibrations in a file if you have several different screens.
  2. if you have a problem, copy-paste the whole Serial Terminal to a message on the Forum.

I would dearly love to get feedback. Which step is difficult? Do the cross-hairs show? Do you copy-paste from Serial?

Note that you can't diagnose Touch pins with an ARM or ESP But you can still calibrate if you edit the sketch for your manually diagnosed Touch pins (i.e. with a DMM)

David.

I did the steps you mentioned. The cross-hairs is OK. I press al cross-hairs one by one. ( i can not see any highlited cross-hair) I press them one by one starting from the top at the left. Then i upload the touch_shield_new.ino to test. Nothing working. I can even press the EXIT on the first screen. The output from serial monitor:

const int XP=7,XM=A1,YP=A2,YM=6; //240x320 ID=0x9340
const int TS_LEFT=584,TS_RT=482,TS_TOP=685,TS_BOT=665;

.

I press al cross-hairs one by one. ( i can not see any highlited cross-hair)

I love you. No one has ever said anything before!

Please can you edit TouchScreen_Calibr_native.ino

...
#define RED   0xF800
#define GRAY  0x001F  //.kbv was 0x8410
...
    centerprint("* RELEASE *", text_y_center);
    drawCrossHair(x, y, RED);  //.kbv was GRAY
...

This will draw 8 BLUE cross-hairs. A highlighted cross-hair is WHITE A finished cross-hair turns RED

Any normal calibration will be ~800 between TS_LEFT and TS_RT

If you get something different, please copy-paste the whole Serial Terminal.

David.

Thank for this David.
I was looking in the code to make these changes in order to change the colors.
But i don’t know much about C programming. (You see i am not a programer just learn thinks by myself)
Anyway now the calibration test example works fine and it is shown cross-hair as you say (all blue , highligtede white and finished red)
After tha the serial monitor shows me:

TouchScreen.h GFX Calibration
Making all control and bus pins ITouchScreen.h GFX Calibration
Making all control and bus pins INPUT_PULLUP
Typical 30k Analog pullup with corresponding pin
would read low when digital is written LOW
e.g. reads ~25 for 300R X direction
e.g. reads ~30 for 500R Y direction

Testing : (A1, D7) = 26
Testing : (A2, D6) = 45
Diagnosing as:-
XM,XP:  (A1, D7) = 26
YP,YM:  (A2, D6) = 45
ID = 0x9340
TouchScreen.h GFX Calibration
Making all control and bus pins INPUT_PULLUP
Typical 30k Analog pullup with corresponding pin
would read low when digital is written LOW
e.g. reads ~25 for 300R X direction
e.g. reads ~30 for 500R Y direction

Testing : (A1, D7) = 26
Testing : (A2, D6) = 45
Diagnosing as:-
XM,XP:  (A1, D7) = 26
YP,YM:  (A2, D6) = 45
ID = 0x9340

cx=217 cy=207 cz=627 LEFT, TOP, Pressure
cx=213 cy=512 cz=557 LEFT, MIDH, Pressure
cx=204 cy=792 cz=401 LEFT, BOT, Pressure
cx=554 cy=218 cz=695 MIDW, TOP, Pressure
cx=539 cy=790 cz=483 MIDW, BOT, Pressure
cx=872 cy=219 cz=702 RT, TOP, Pressure
cx=879 cy=503 cz=648 RT, MIDH, Pressure
cx=875 cy=789 cz=557 RT, BOT, Pressure
MCUFRIEND_kbv ID=0x9340  240 x 320

const int XP=7,XM=A1,YP=A2,YM=6; //240x320 ID=0x9340
const int TS_LEFT=180,TS_RT=905,TS_TOP=194,TS_BOT=809;
PORTRAIT CALIBRATION     240 x 320
x = map(p.x, LEFT=180, RT=905, 0, 240)
y = map(p.y, TOP=194, BOT=809, 0, 320)
Touch Pin Wiring XP=7 XM=A1 YP=A2 YM=6
LANDSCAPE CALIBRATION    320 x 240
x = map(p.y, LEFT=194, RT=809, 0, 320)
y = map(p.x, TOP=905, BOT=180, 0, 240)

After copy-paste the 2 const int lines in the Touch_Shield_new.ino example everythig seems to works fine.
Now my display works as it should.

Thank you David for your help and your great library and examples.

Yannis.

Your calibration looks normal:

const int XP=7,XM=A1,YP=A2,YM=6; //240x320 ID=0x9340
const int TS_LEFT=180,TS_RT=905,TS_TOP=194,TS_BOT=809;

I think BLUE->WHITE->RED looks fairly good Would RED->WHITE->GREEN be more intuitive? Would BLUE->WHITE->GREEN look better?

David.

I think that colors is OK.
For my eyes i mean.

Another question David, Is there is any easy (or not) way to determine what controller does a display use?

Yes, tft.readID() The clue is in the name.

I can identify the controller mounted on the TFT panel. (You can't see it with your eyes) I can't tell the geometry of the TFT panel.

Run the diagnose_TFT_support.ino from the examples. This makes geometry errors easy to see. e.g. your (mystery) screen

I would appreciate feedback. e.g. 1. suggestions for improvng examples 2. suggestions for improving extra/mcufriend_how_to.txt

I will put the improved TouchScreen_Calibr_native sketch onto the GitHub Beta. It is simple ideas that make a big difference.

David.

Please let me understand. I run diagnose_TFT_support.ino for a display i have and i got ID=0XB509 I know that the IC driver is R61509V How does it comes from B509?

david_prentice: I will put the improved TouchScreen_Calibr_native sketch onto the GitHub Beta. It is simple ideas that make a big difference.

Yes that would be very helpful since as i told you there are not shown highlighted Cross-hairs. Thank myou for that mod.