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

@dnh,

If you get a datasheet, you will deserve a medal.

@Mattty5,

A Uno shield will plug into any Arduino e.g. Uno, Leo, Mega, Zero, ... as well as many other boards.

Yes, you can re-wire the data pins to use digital 22-29 on a Mega. And re-wire 11-13 to 50-52 for hardware SPI.
I use a Protoshield. But it is not as neat as buying a proper Mega Display Shield in the first place.

Yes, you can access non-shield pins by using angle-header strip. Or mount extra electronics on the Protoshield.

@daviten,

Please post a link to the actual shield that you have bought.
Mega shields often have an XPT2046 Touch controller.

David.

@daviten,

publique un enlace al escudo real que ha comprado.
Los mega escudos a menudo tienen un controlador tƔctil XPT2046.

I do not understand what I have to do.

You bought the shield from Ebay, AliExpress, ...

Post a link to the item e.g. Ebay sale

Even if you bought from a local shop, you can find the same item online.
If you post a link to the "same item", we can identify it by the pcb photo.

David.

Here I took pictures ...

Thank you for your swift reply, that’s brilliant news.

I’m learning as I go, this one seems pretty tough.

Considering more or less the most I’ve done re display libs is change ID to myscreenID and configured the touch within my sketches,
Im not sure where to start

Am I going down the route of define mega Proto and then something else or actually writing code for port and pin out?

Just to reiterate my main reason for this is to get it fast like it is on the UNO and I understand that ports make the difference?
If I find an equivalent that is intended for the mega I will certainly look at getting it, so far no joy.

Please correct me if I’m wrong?
Matt

Edit; the picture above looks like the pinout I want?!?

It is only the pcb photo that I need.

You have a Mega Shield with 8-bit parallel data bus, XPT2046 Touch Controller, microSD card.

TFT: define USE_SPECIAL, USE_MEGA_8BIT_SHIELD
Touch: use URTouch.h library
SD card: SD_CS=53. Use regular <SD.h> library. (It might be unreliable because the Resistor Pack has a high value)

It is not possible to read the controller ID.
If it has an ILI9488 controller (0x9488) graphictest_kbv should work 100% except for ID and SOFTWARE SCROLL.

David.

I do not understand what I have to do ... sorry for my English, I am from Argentina.

Download the following library: GitHub - f1rmb/URTouch: Fork of Arduino/chipKit library support for Color TFT LCD Touch screens from Henning Karlsen

But I don't know how to join the 2 libraries, is there no example to make it work?

Run the example ā€˜TouchScreen_Calibr_native’ from mcu lib.
Save the serial output

Next open button_simple example sketch and paste the results in place of the dummy ones ie const int XP = 6, XM = A2 etc etc
Then run it
If not try diagnose_touchpins.
Hope that helps...
In the end simple button is your example of more than one library used in a sketch.

Mr P, in relation to my project I don’t really know how. Yours is the only library that I’ve had any success with in getting the screen to operate, so I’m starting here.

So far I have added cables to prove all connections are good and allow for testing different pin configs but anything other than the vanilla arrangement and the screen does not work so far.

As stated before aim is to improve performance over stock uno shield on mega2560.
I intended to put together a custom header board once it works on the bench.

Please may I have some baby step guidance.
Many thanks,
Matt

@Mattty5,

You say that you have bought a Uno shield. It should run out of the box on your Mega. (but will be SLOWER than a Uno)

Run all the MCUFRIEND_kbv examples.
Quote which example has a problem. (just quote the example name)

It is much easier to buy a ready-made Mega Shield than to re-route Uno Shield via a Protoshield.
Doing anything with trailing wires is a recipe for disaster.

David.

daviten:
Download the following library: GitHub - f1rmb/URTouch: Fork of Arduino/chipKit library support for Color TFT LCD Touch screens from Henning Karlsen

But I don't know how to join the 2 libraries, is there no example to make it work?

URTouch is written by Henning Karlsen (the author of UTFT). You should install URTouch from his website

Your shield has a XPT2046 Touch Controller on pins 2-6.
URTouch examples can be "run" fairly easily with UTFTGLUE:

  1. edit MCUFRIEND_kbv library for USE_SERIAL, USE_MEGA_8BIT_SHIELD
  2. edit UTFTGLUE.h for your controller ID e.g.
     if (ID == 0xD3D3) ID = 0x9488;   //write-only controller

run GLUE_Demo_480x320.ino to verify your edit
3. load URTouch_Calibration.ino from URTouch Examples
4. edit UTFT -> UTFTGLUE and comment the font statement e.g.

#include <UTFTGLUE.h>   //change from UTFT.h
#include <URTouch.h>
...
// Remember to change the model parameter to suit your display module!
UTFTGLUE    myGLCD(0x9488,38,39,40,41);   //change from UTFT

// Initialize touchscreen
// ----------------------
// Set the pins to the correct ones for your development board
...
URTouch  myTouch( 6, 5, 4, 3, 2);    //these should be correct for your shield
...
// Declare which fonts we will be using
//extern uint8_t SmallFont[];           //comment this line
...
  1. Run URTouch_Calibration. Follow instructions

  2. Load URTouch_QuickDraw. Edit UTFT to UTFTGLUE as in (4)

  3. Add a setColor() statement. e.g.

void setup()
{
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myGLCD.setColor(0x001F);    // any visible colour.  (default was BLACK) 

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_MEDIUM);
}
  1. Run URTouch_QuickDraw.
  2. Load URTouch_QuickPaint. Edit UTFT to UTFTGLUE as in (4)
  3. Run URTouch_QuickPaint

Yes, I know that this is fiddly. But you do have a non-Uno shield.
When you have changed a library example save the working sketch in your sketch folder for future reference.

Ask if you have a problem. Quote the step number.
When you have the (edited) URTouch examples working, I will post the URTouch version of "button_simple.ino"

David.

Thanks David,
I did include an ESSAY on why a few posts ago, don’t read it unless you have hot tea.

Everything works out of the box thanks to your libraries, it’s incredible really so thank you very much for that!

I chopped a tiny bit of my program code to fit on an uno and tested it all with only 2 data inputs and the difference is astonishing, I cannot demo my project until I have it running like that on the mega, ideally with rewritten pins/ports as UNO shields are available everywhere very cheap and even previously I ordered for Mega not Uno and still got Uno

Off the bench and in my project enclosure the screen and Arduino may not be mated together anyway,

I’ve been working to find an equivalent shield for Mega (3.2 320x480 with touch, sd or no sd is ok) but not much joy, closest I’ve got is what I hope will arrive as a 16bit mega shield without touch.... I also ordered a touch panel with controller...
Those will be with me in 100 years thanks to Covid-19.
Otherwise it seems like my only option is to understand libraries.

Matt

There are Mega shields with Touch e.g. photo in #2943

Most have 16-bit interface. (7 resistor packs next to 18x2 header)

Most 3.5inch screens are bigger than a mega2560. So the screen is going to take up most of any enclosure front panel. If you re-route signals via a ProtoShield Adapter you just get a deeper sandwich.

I also ordered a touch panel with controller...

A bare Touch panel is very difficult for you to stick to the screen.

A Mega will still have plenty of spare pins even with a shield in place.

David.

Edit: I attempted to attach pics of what I ordered and what I have but the forum doesn’t like it, will try from pc later...

I will hunt for something with touch already on there too now and in the mean time I will continue to try and learn what’s actually going on driver/pin/port assignment wise.
If this project is successful and I somehow get as far as a production model I hope I’ll be able to just spec/order one type of screen and hopefully let experts optimise etc... all will be good but if I wind up making these ad-hoc it would be nice to be flexible on what screen I use...due to cost/avaliability etc. 2.8 touch seems easy to find for mega but really is too small for my application and less than 480 pixels is troublesome because 480 points gives me ~3 seconds worth of data which is exactly what I need to display.

One question, so I’m not chasing geese,
Do the pin/ port assignments all happen inside the mcufriend lib or does some/all happen in the GFX lib? I came across reference to secondary data pins/ports ie 22-29 within the GFX lib which made me realise I don’t know the answer to that question.

Many thanks,
Matt

Pins are determined in mcufriend_shield.h
If USE_SPECIAL is defined, mcufriend_special.h is checked before mcufriend_shield.h

All "common" pinouts are already available in mcufriend_special.h
You just un-comment a define

David.

Thank you Sir!

I had the UNO shield screen working on the Mega with 8bit uno on Mega defined.

Soooo much faster, unlocks a great amount for me so thank you again David!!

Only trouble, I had was with the touch, I think I have to use Analog pins? Anyway I switched pins to Proto variation and change the def,

The touch screen pin diag example didn’t go for that, looks like it only checks sensible pins,

Works now anyway, I set,
XP=22 XM=A2 YP=A1 YM=23 works like a charm, I’m so please to have solved this!

Before I knew I had a problem I was expecting 22,38,40,23

Many thanks,
Matt

I have to redo my bounce and double tap detection now, so much faster...

Hello,

I've been playing with the library for some time with great success (David even included my timings for Teensy in v 2.9.9 beta) Now I encountered a challenge. Not critical but would greatly improve my design if it worked.

Unless I'm wrong, from what I see and understand about the vertScroll method it only works for entire screen.

I'm using the display in horizontal mode and need to scroll an area/window horizontally, which should still follow the hardware direction. I've tried the software method already. What I'm looking here is just confirmation that it's not possible to hardware scroll a defined area of the screen.