Go Down

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

david_prentice

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.

jxid

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.

david_prentice

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.

jxid

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.

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?

jxid

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.

jxid

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.

david_prentice

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.
Code: [Select]

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;


13. it is wise to save the calibrations in a file if you have several different screens.
14. 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.

jxid

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.
Code: [Select]

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;


13. it is wise to save the calibrations in a file if you have several different screens.
14. 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:
Code: [Select]
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;

.

david_prentice

Quote
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

Code: [Select]

...
#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.

jxid

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:
Code: [Select]
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.

david_prentice

Your calibration looks normal:
Code: [Select]

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.


jxid


jxid

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

david_prentice

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.

Go Up