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

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.

Read extra/mcufriend_how_to.txt

Observe the ID values for R61505 variants: R61505U, R61505V, R61505W The ID values for R61509 variants: R61509U, R61509V, R61509W follow the same pattern.

David.

david_prentice: Read extra/mcufriend_how_to.txt

Observe the ID values for R61505 variants: R61505U, R61505V, R61505W The ID values for R61509 variants: R61509U, R61509V, R61509W follow the same pattern.

David.

Thank you David

What sketch are you trying to compile? What library version numbers are you using? Did you install libraries via the IDE Library Manager?

David.

Hi, thanks for the reply. I found the problem after digging into the files more deeply. The posted code included "myicon" where as the icon.c matrix variable was "myicons".

We don't know what sketch you are trying to build.

graphictest_kbv shows a penguin but you can enable other icons if you edit the sketch

drawBitmap_kbv shows the GFX methods as well as the hardware pushColors() method.

It is always wise to start with library examples. Experiment and adapt for your purposes. Quote the library example that is giving you a problem.

David.

I apologize to David here who has already explained something, but for me it is still unclear how I should connect (Pins) a SPI Beakout card, as in the attached link, to an Arduino, either Uno or Mega, or even ESP.

If anyone can enlighten me, I would be very grateful.

Link: https://www.ebay.com/itm/3-5-inch-480-320-SPI-Serial-TFT-LCD-Module-Display-Screen-Driver-IC-ILI9488/192714343868?var=492856453212

This thread is about MCUFRIEND parallel Shields Your question is about a 3.3V Red SPI display Please ask questions on appropriate threads.

ESP32:
connect TFT_SCK, T_SCK, SD_SCK to GPIO18
connect TFT_SDI, T_SDI, SD_MOSI to GPIO23
connect TFT_SDO, T_SDO, SD_MISO to GPIO19 (omit TFT_SDO for ILI9488)
connect TFT_RST to any GPIO pin
connect TFT_DC to any GPIO pin    (sometimes called TFT_RS or TFT_A0)
connect TFT_CS to any GPIO pin
connect T_CS to any GPIO pin
connect SD_CS to any GPIO pin

ESP8266:
connect TFT_SCK, T_SCK, SD_SCK to D13
connect TFT_SDI, T_SDI, SD_MOSI to D11   (sometimes called TFT_MOSI)
connect TFT_SDO, T_SDO, SD_MISO to D12 (omit TFT_SDO for ILI9488)
connect TFT_RST to any GPIO pin
connect TFT_DC to any GPIO pin    (sometimes called TFT_RS or TFT_A0)
connect TFT_CS to any GPIO pin
connect T_CS to any GPIO pin
connect SD_CS to any GPIO pin

Make sure that you configure correctly in User_Setup.h

I strongly advise to just copy Bodmer's TFT_eSPI default wiring.

Regarding Uno or Mega. This requires using level shifters. Probably too complex for you.

David.