www.mcufriend.com working in arduino uno and arduino mega

:o
David that is not very constructive, send me the code and i will test it, after i have some sleep

I can not send you anything without an email address.

If you send me a PM with your email, I can send you a ZIP tomorrow.

Sorry, if I sounded grumpy. In the past I have spent time adding support for controllers that a reader owns. And then find that they are not prepared to make a report.

I have quite a few different displays. Since Ebay is a bit of a lottery, I can't rely on receiving a HX8347-A even if I buy from exactly the same advert as you. I might need to make several purchases until I actually get the same one as you.

The Chinese Ebay cycle takes a few weeks. If someone wants a library to support their unusual controller, they either need to wait until I manage to obtain one or they do some remote testing for me. Which may mean one exchange of emails. Or possibly ten exchanges.

David.

Hi again, I have to thank David for his reply, but have to admit I am totally lost!!!!!!.

I have an mcuFRIEND 2.8" that appears to work OK with various libraries.

I can get it to run the example "woof" reading from sd card to screen, using the Adafruit library and example without needing to use MCUFRIEND.kbv providing I have everything set up as a breakout.

The screen fills, then the image shifts, multiplies and rotates (as I assume it is supposed to in this case).

What I am trying to do is create a slide show using images in the root directory, one after another (without shift rotate etc).

After my joy at seeing "woof" work, I didn't think this would be too difficult to hunt down a slideshow sketch.

How wrong I was.

I know I am totally new to this but being off work sick I have spent a full 3 days trying to get every sketch I can find trying to "Read sd file, display, read next sd file, display", I can't even get half of them to compile!!

Can anyone please help in laymans language.

Rob.

jdp229:
After months of trying to get this display to work, I was finally successful. Can't thank you enough.

ivconic (or anyone else that has the inversion problem), someone else found a solution to this at

2.4 inch TFT touch LCD Screen Module For Arduino UNO R3 SD low price jocks - Displays - Arduino Forum post#118

Basically, change

  p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);

p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);




to



p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
 p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());




At least it worked for me with the 9341 chip, hope it can help someone else.

It worked for me too

Roblegion:
After my joy at seeing "woof" work, I didn't think this would be too difficult to hunt down a slideshow sketch.

How wrong I was.

I know I am totally new to this but being off work sick I have spent a full 3 days trying to get every sketch I can find trying to "Read sd file, display, read next sd file, display", I can't even get half of them to compile!!

Can anyone please help in laymans language.

Rob.

Is this any help?

It currently works on a Due but WAS working on a Mega before. It gives you an option to "list" the files or display a slideshow (current setting). It "Lists" into sub directories but does NOT slideshow into sub directories. Meant to extend this but I'm happy just using the root directory at the moment.

It uses the "drawBitmap.ino" file which I haven't included. Shout if you need this....

Enjoy....

(Please don't fault my formatting (multiple statements on one line) as that is how MY mind works.... :wink: ) OR doesn't work :wink:

/***************************************************
  Mega/Due BangGood 3.2 TFT LCD with Rowboteer's library.

  Changed from nominated files to slideshow Louis 25/01/13
  
  Modified "mySDListfiles2LCD" into MegaBGslideshow
  after abandoning the sketch developed from scratch.

  The original sketch had all the correct "looping"
  logic working (with a buzzer).

  29/01/16 Works but does NOT "enter" subdirectories   :(
           drawBMP routine removed and put into its' own "ino" file
           Eventually we will do the same with the drawJPG routine  :)  Done!
           Added rowboteer's JPG routine but not like over large files
           Modified to fix but causes a "hang"!?
  02/02/16 Putting in a LIST option to "list" files
           Problem in drawSdJpeg method!?
           Cut the crap out of it - arrayrender, createArray, showTime
           and now it is back to "working" status   :)
           But when in a subdirectory files are "not found"  :(
  09/02/16 The basic routine was modified (by rowboteer) to abandon
           decoding when the painting "dropped" off the bottom. Because
           of the progressive nature of the image nothing can be done
           about painting past the RHS of the image.
  
 ****************************************************/

#define LIST 0//List of files or slideshow

#include <SPI.h>
#include <arduino.h>
// Select the library depending on the "Tools => Board" selection in the IDE
#ifdef __SAM3X8E__ //For Due
  #include <SdFat.h>             // Use the SdFat library for the Due
  SdFat SD;                      // Permit SD function call for the Due
  #include <TFT_HX8357_Due.h>//Hardware-specific library
  TFT_HX8357_Due tft = TFT_HX8357_Due();//Invoke ARM (Due) custom library
  #undef __FlashStringHelper::F(string_literal)
  #define F(string_literal) string_literal
#else//All others, Mega specifically
  #include <SD.h>                // Use the SD library for the Mega
  #include <TFT_HX8357.h>//Hardware-specific library
  TFT_HX8357 tft = TFT_HX8357();//Invoke AVR custom library
#endif
#include <JPEGDecoder.h>// JPEG decoder library

//TFT display and SD card will share the hardware SPI interface.
//Hardware SPI pins are specific to the Arduino board type and
//cannot be remapped to alternate pins without "soft" SPI.

#define SD_CS 53//Mega CS pin for standard SPI....

File root;

int lnno;

long Filesize, Headersize; char entryname[30]; char extension[10];
int imgWidth, imgHeight; uint32_t drawTime;

void setup() {
  tft.begin();
  tft.setRotation(3);//For both modes
  tft.fillScreen(TFT_BLACK);
  tft.setTextSize(2);//20 lines down, 39 characters across

  if (!SD.begin(SD_CS)) {//The SD routine uses standard (Mega) hardware SPI.
    tft.println("Initializing Failed!");
    return;
  }
  tft.println("Initialization OK"); tft.println(" ");

  root = SD.open("/");//Open "root directory"
}

void loop() {
  tft.setCursor(0, 0);
  tft.fillScreen(TFT_BLACK);
  if(LIST) {
    lnno = 0;
    printDirectory(root, 0);//Print files in root directory
    delay(10000);
  } else {
    ScanDirectory(root);//Scan files in root directory
    delay(500);
  }
  root.rewindDirectory();//Rewind and start again, endlessly
}

//Starting from "/" (root) list (recursively) ALL files.
//Works perfectly but, no buts
void printDirectory(File dir, int numTabs) {
  while (true) {
    File entry =  dir.openNextFile();
    if (!entry) break;// no more files
    entry.getName(entryname, 29);
    //strcpy(entryname, entry.name());
    if(lnno<9) tft.print(" ");
    tft.print(++lnno); tft.print(". ");
    for(uint8_t i=0; i<numTabs; i++) tft.print("  ");
    //tft.print(entry.name());
    tft.print(entryname);
    if (entry.isDirectory()) {
      tft.println(" ");
      printDirectory(entry, numTabs+1);
    } else {
      int skip = 38-(4+strlen(entryname)+(numTabs*2)+6);//Number of
      for(uint8_t i=0; i<skip; i++) tft.print(" ");//spaces to insert
      tft.println(entry.size(), DEC);//before the file size
    }
    if(!(lnno%20)) {//Page full?
      delay(5000);
      tft.fillScreen(TFT_BLACK);
      tft.setCursor(0, 0);
    }
    entry.close();
  }
} 

char* getext(char* file){//used to send back .EXT, NOW only EXT  :)
  for(int i=strlen(file)-1; i> 0; i--) if( file[i] == '.' ) return file+i+1;
  return file;
}

//Starting from "/" (root) scan for and display ALL BMP/RAW/JPG files
//There is SOME code to indicate where to "trim" over large files
//In our case, anything over 480X320 in size....
//The code will recurse into all directories. The second argument
//was "numTabs" to indent the file list but this is irrelevent now
//as we are NOT listing the files.
void ScanDirectory(File dir) {
  while(true) {     
    File entry =  dir.openNextFile();
    if (!entry) break;// no more files
    //strcpy(entryname, entry.name());
    entry.getName(entryname, 29);
    bool displayed = false;
    if (entry.isDirectory()) {
      tft.print("Entering "); tft.println(entryname); delay(3000);
      ScanDirectory(entry);//Display files in THIS directory too
    } else {
      Filesize = entry.fileSize();
      drawTime = millis(); // For comparison purpose the draw time is measured
      strcpy(extension, getext(entryname));//extract file extension
      if(strcmp(extension, "bmp") == 0) {bmpDraw(entryname, 0 ,0); displayed = true;}
      if(strcmp(extension, "jpg") == 0) {drawSdJpeg(entryname, 0, 0); displayed = true;}
      if(strcmp(extension, "raw") == 0) {rawDraw(entryname, 0 ,0, 480, 320); displayed = true;}
    }
    entry.close();
    if(displayed) {
      tft.setCursor(0, 0); tft.println(entryname);
      tft.print("File size: "); tft.println(Filesize);
      tft.print("Image size: "); tft.print(imgWidth); tft.print('x'); tft.println(imgHeight);
      tft.print("Loaded in "); tft.print(millis() - drawTime); tft.println(" ms");
      delay(3000);
    }
  }
}

david_prentice:
Put the correct pins into the new Calibration sketch that I posted yesterday.
See if you get sensible results.

Always restore shared control pins like A2, A3 to OUTPUT HIGH after any access to the Touch library.

David.

Sorry .. took me a few days to get back at the Project .. which Sketch do you mean ?

Volker

Any sketch that uses the TouchScreen.h library should restore the shared pins after any access.
It looks as if you have identified the Touch pins that are used.

Just look at the examples. And if you write a new sketch, I suggest that you add the explanatory comments.

David.

Well up to now the Paint-Program works kinda .. but the Y-Coorinate is twisted .. as soon as it works I'll post a Sketch + SomeImages of the Serial/Production Number of the TFT

How can you twist a Y coordinate?

If the stylus moves horizontally and the spot draws vertically, you swap X, Y.
If the spot moves left when the stylus moves right, you swap TS_LEFT and TS_RIGHT.

I have no control of how your Touch panel is wired. In fact you seem to use A2, A3, 8, 9 whereas most 2.4"displays use A1, A2, 7, 6.

The ILI9341 displays seem to come in every possible Touch flavour. So if you are lucky, yours matches the example. If not, you have to edit for your particular pins and wiring.

David.

david_prentice:
Sorry, if I sounded grumpy. In the past I have spent time adding support for controllers that a reader owns. And then find that they are not prepared to make a report.

Unlike me that gave extensive information but it seems to have gone quiet on the western front... Have you given up?

Regards,

Graham

Graham,

I spent a large part of yesterday in the pub.

I will send you a revised version with ML=0. Probably this evening.

David.

I think you deserved it in fairness!!! I did say have a stiff whiskey before bed :wink: :stuck_out_tongue:

By the way, I gave you a mention in one of my posts on the UTFT_GHL thread.... readGram is great :smiley:

Regards,

Graham

Ok ... I bought this TFT - UNO R3 USB Development Board With 2.8 Inch TFT Touch Display Module Geekcreit fo Sale - Banggood USA sold out-arrival notice-arrival notice

Made it run (tft_paint_shield_kbv) by setting the Following Parameters:

uint8_t YP = A2; // must be an analog pin, use "An" notation!
uint8_t XM = A3; // must be an analog pin, use "An" notation!
uint8_t YM = 8; // can be a digital pin
uint8_t XP = 9; // can be a digital pin
uint8_t Landscape = 1;

uint16_t TS_LEFT = 920;
uint16_t TS_RT = 150;
uint16_t TS_TOP = 940;
uint16_t TS_BOT = 120;

and changing
p.x = 226 - map(p.x, TS_LEFT, TS_RT, 0, tft.width());

Now the Paint Thingie Works =)

Any Ideas why I have to modify the inverted X-Corrdinates ?

Volker

It is pretty simple. A Touch screen has 4 wires. They could connect to any of the Shield pins. Admittedly, two of the pins must be "Analog".

You have determined that your shield uses A2, A3, 8, 9 pins.

I really do not understand your

p.x = 226 - map(p.x, TS_LEFT, TS_RT, 0, tft.width());

Personally, I would map the Touch TSPoint values to regular pixel coordinates. e.g.

pixel_X = map(p.x, TS_LEFT, TS_RT, 0, tft.width());
pixel_Y = map(p.y, TS_TOP, TS_BOT, 0, tft.height());

After all, you generally want to know whether a button is touched or the screen location of your stylus.

David.

LaermTot:
Well the Resistance between A2 and D8 (LC_D0) is 330Ohm the rest is 0 ..
How or better where do I apply this Result to the Problem ?

Ok seems that modifying the "touchscreendemo" with
#define YP A2 // must be an analog pin, use "An" notation!
#define XM A3 // must be an analog pin, use "An" notation!
#define YM 8 // can be a digital pin
#define XP 9 // can be a digital pi
has done the Trick ..

kinda .. but some of the Results are quite off

If you really got 300 ohms between A2 (LCD_RS) and D8 (LCD_D0) it would imply:
XM=A2, XP=8

I am guessing that you would get 500 ohms between A3 (LCD_CS) and D9 (LCD_D1):
YP=A3, YM=9

Only you can measure the resistance of your Touch pins.
Only you can determine the values of TS_LEFT, TS_RIGHT, ...

If you look at the examples that come with the Library, you will see that the Shields can be very different.
I have 3 different "wiring" for 3 different ILI9341 Shields.

David.

It seems that the touch-inpiut coordinates in my are not relative to the display 0/0 Point
therefore I have to convert p.x and p.y to

p.x = width - (((width * (p.x-TS_RT))/(TS_LEFT-TS_RT)));
p.y = ((height/(TS_TOP-TS_BOT)) * (p.y-TS_BOT));

where width is a float width tft.width() and height is a float with tft.height();

at this Display the 0/0 Point is at Top/Left and 240/320 is a the Bottom/Right

whereas the Touch Minimum Value (180/180) is at Top/Right (925/180) is a Top(Left)
and (925/925) is a Bottom/left and (180/925) ist a Bottom/Right

But with the Code above it works fine =)

Rubbish. Think about it. You just want to map the LEFT and RT values to the screen X coordinate.

The map() function looks after the sign and the maths. So it really does not matter if LEFT is greater than RT. You will still get the correct X coordinate.

Typical values for left and right are 120, 900 or 900, 120.
Obviously a calibration might get more accurate values but the most important thing is to get the correct direction.

If your left and right values are not near these typical values, there is something wrong.

David.

You can find several demonstrations, tutorials and source code for this TFT here:

That link only works for you (it even says so).

I can't imagine anything good originating from that site by the way (that's why i tried clicking that link, to see if i'm ever going to be wrong with that).

By reading that link as plain text (which it is after all), i suspect it leads to some page published by yourself.
Are you trying to get as many views as possible in the shortest time frame by any chance ?

hi all!

I was having the white screen problem with this tft.
After searching a bit online, i've found this link:

libraries here:

https://drive.google.com/file/d/0B_xVV-sUK15zbHBmVUxSRXRRSGc/view

downloaded the libraries, and it worked right off the bat. :slight_smile:

Enjoy